Submit
Path:
~
/
/
usr
/
share
/
grafana
/
public
/
app
/
features
/
explore
/
File Content:
correlationEditLogic.ts
import { template } from 'lodash'; import { CORRELATION_EDITOR_POST_CONFIRM_ACTION } from 'app/types'; enum CONSEQUENCES { SOURCE_TARGET_CHANGE = 'cause the query in the right pane to be re-ran and links added to that data', FULL_QUERY_LOSS = 'lose the changed query', FULL_CORR_LOSS = 'cause the correlation in progress to be lost', INVALID_VAR = 'remove the variables, and your changed query may no longer be valid', } // returns a string if the modal should show, with what the message string should be // returns undefined if the modal shouldn't show export const showModalMessage = ( action: CORRELATION_EDITOR_POST_CONFIRM_ACTION, isActionLeft: boolean, dirtyCorrelation: boolean, dirtyQueryEditor: boolean ) => { const messageTemplate = template( '<%= actionStr %> will <%= consequenceStr %>. Would you like to save before continuing?' ); let actionStr = ''; let consequenceStr = ''; // dirty correlation message always takes priority over dirty query if (action === CORRELATION_EDITOR_POST_CONFIRM_ACTION.CLOSE_PANE) { actionStr = 'Closing the pane'; if (isActionLeft) { if (dirtyCorrelation) { consequenceStr = CONSEQUENCES.FULL_CORR_LOSS; } else if (dirtyQueryEditor) { consequenceStr = CONSEQUENCES.SOURCE_TARGET_CHANGE; } else { return undefined; } } else { // right pane close if (dirtyCorrelation) { consequenceStr = CONSEQUENCES.FULL_CORR_LOSS; } else if (dirtyQueryEditor) { consequenceStr = CONSEQUENCES.FULL_QUERY_LOSS; } else { return undefined; } } } else if (action === CORRELATION_EDITOR_POST_CONFIRM_ACTION.CHANGE_DATASOURCE) { actionStr = 'Changing the datasource'; if (isActionLeft) { if (dirtyCorrelation) { consequenceStr = CONSEQUENCES.FULL_CORR_LOSS; } else { return undefined; } } else { // right datasource change if (dirtyQueryEditor) { consequenceStr = CONSEQUENCES.FULL_QUERY_LOSS; } else { return undefined; } } } else if (action === CORRELATION_EDITOR_POST_CONFIRM_ACTION.CLOSE_EDITOR) { actionStr = 'Closing the editor'; if (dirtyCorrelation) { consequenceStr = CONSEQUENCES.FULL_CORR_LOSS; } else if (dirtyQueryEditor) { consequenceStr = CONSEQUENCES.INVALID_VAR; } else { return undefined; } } return messageTemplate({ actionStr, consequenceStr }); };
Submit
FILE
FOLDER
INFO
Name
Size
Permission
Action
ContentOutline
---
0755
FlameGraph
---
0755
Graph
---
0755
Logs
---
0755
NodeGraph
---
0755
PrometheusListView
---
0755
RawPrometheus
---
0755
RichHistory
---
0755
Table
---
0755
TraceView
---
0755
__mocks__
---
0755
extensions
---
0755
hooks
---
0755
spec
---
0755
state
---
0755
utils
---
0755
CorrelationEditorModeBar.tsx
10676 bytes
0644
CorrelationHelper.tsx
9880 bytes
0644
CorrelationTransformationAddModal.tsx
8532 bytes
0644
CorrelationUnsavedChangesModal.tsx
967 bytes
0644
CustomContainer.tsx
1867 bytes
0644
ElapsedTime.tsx
942 bytes
0644
ErrorContainer.test.tsx
1737 bytes
0644
ErrorContainer.tsx
748 bytes
0644
Explore.test.tsx
6031 bytes
0644
Explore.tsx
27115 bytes
0644
ExploreActions.tsx
3705 bytes
0644
ExploreDrawer.tsx
2043 bytes
0644
ExplorePage.tsx
4146 bytes
0644
ExplorePaneContainer.tsx
2847 bytes
0644
ExploreQueryInspector.test.tsx
4831 bytes
0644
ExploreQueryInspector.tsx
3900 bytes
0644
ExploreTimeControls.tsx
3147 bytes
0644
ExploreToolbar.tsx
12603 bytes
0644
FeatureTogglePage.tsx
700 bytes
0644
LiveTailButton.tsx
2144 bytes
0644
MetaInfoText.test.tsx
1115 bytes
0644
MetaInfoText.tsx
1844 bytes
0644
NoData.tsx
921 bytes
0644
NoDataSourceCallToAction.tsx
1524 bytes
0644
QueryRows.test.tsx
2757 bytes
0644
QueryRows.tsx
3023 bytes
0644
ResponseErrorContainer.test.tsx
1958 bytes
0644
ResponseErrorContainer.tsx
636 bytes
0644
SecondaryActions.test.tsx
2734 bytes
0644
SecondaryActions.tsx
2390 bytes
0644
ShortLinkButtonMenu.tsx
4937 bytes
0644
SupplementaryResultError.test.tsx
1267 bytes
0644
SupplementaryResultError.tsx
2158 bytes
0644
Time.tsx
812 bytes
0644
TimeSyncButton.test.tsx
674 bytes
0644
TimeSyncButton.tsx
736 bytes
0644
correlationEditLogic.test.ts
5061 bytes
0644
correlationEditLogic.ts
2481 bytes
0644
useLiveTailControls.ts
2035 bytes
0644
N4ST4R_ID | Naxtarrr