/usr/share/grafana/public/app/features/explore
import { template } from 'lodash'; import { CORRELATION_EDITOR_POST_CONFIRM_ACTION } from 'app/types/explore'; 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 }); };
.
Edit
..
Edit
ContentOutline
Edit
CorrelationEditorModeBar.tsx
Edit
CorrelationHelper.tsx
Edit
CorrelationTransformationAddModal.tsx
Edit
CorrelationUnsavedChangesModal.tsx
Edit
CustomContainer.tsx
Edit
ElapsedTime.tsx
Edit
ErrorContainer.test.tsx
Edit
ErrorContainer.tsx
Edit
Explore.test.tsx
Edit
Explore.tsx
Edit
ExploreActions.tsx
Edit
ExploreDrawer.tsx
Edit
ExplorePage.tsx
Edit
ExplorePaneContainer.tsx
Edit
ExploreQueryInspector.test.tsx
Edit
ExploreQueryInspector.tsx
Edit
ExploreRunQueryButton.test.tsx
Edit
ExploreRunQueryButton.tsx
Edit
ExploreTimeControls.tsx
Edit
ExploreToolbar.tsx
Edit
FeatureTogglePage.tsx
Edit
FlameGraph
Edit
Graph
Edit
LimitedDataDisclaimer.tsx
Edit
LiveTailButton.tsx
Edit
Logs
Edit
MetaInfoText.test.tsx
Edit
MetaInfoText.tsx
Edit
NoData.tsx
Edit
NoDataSourceCallToAction.tsx
Edit
NodeGraph
Edit
PrometheusListView
Edit
QueriesDrawer
Edit
QueryLibrary
Edit
QueryRows.test.tsx
Edit
QueryRows.tsx
Edit
RawPrometheus
Edit
ResponseErrorContainer.test.tsx
Edit
ResponseErrorContainer.tsx
Edit
RichHistory
Edit
SecondaryActions.test.tsx
Edit
SecondaryActions.tsx
Edit
ShortLinkButtonMenu.tsx
Edit
SupplementaryResultError.test.tsx
Edit
SupplementaryResultError.tsx
Edit
Table
Edit
Time.tsx
Edit
TimeSyncButton.test.tsx
Edit
TimeSyncButton.tsx
Edit
TraceView
Edit
correlationEditLogic.test.ts
Edit
correlationEditLogic.ts
Edit
extensions
Edit
hooks
Edit
mocks
Edit
spec
Edit
state
Edit
useLiveTailControls.ts
Edit
utils
Edit