Rich history: Updates for default settings and starred queries deletion (#25732)

* Update show only queries for current data source to true

* Add confirmation modal when deleting starred queries
This commit is contained in:
Ivana Huckova 2020-06-24 09:50:46 +02:00 committed by GitHub
parent b7d26b12dd
commit f704d103bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View File

@ -88,7 +88,7 @@ class UnThemedRichHistory extends PureComponent<RichHistoryProps, RichHistorySta
datasourceFilters: store.getObject(RICH_HISTORY_SETTING_KEYS.datasourceFilters, null),
retentionPeriod: store.getObject(RICH_HISTORY_SETTING_KEYS.retentionPeriod, 7),
starredTabAsFirstTab: store.getBool(RICH_HISTORY_SETTING_KEYS.starredTabAsFirstTab, false),
activeDatasourceOnly: store.getBool(RICH_HISTORY_SETTING_KEYS.activeDatasourceOnly, false),
activeDatasourceOnly: store.getBool(RICH_HISTORY_SETTING_KEYS.activeDatasourceOnly, true),
};
}

View File

@ -8,7 +8,7 @@ import { GrafanaTheme, AppEvents, DataSourceApi } from '@grafana/data';
import { RichHistoryQuery, ExploreId } from 'app/types/explore';
import { copyStringToClipboard, createUrlFromRichHistory, createQueryText } from 'app/core/utils/richHistory';
import appEvents from 'app/core/app_events';
import { StoreState } from 'app/types';
import { StoreState, CoreEvents } from 'app/types';
import { changeDatasource, updateRichHistory, setQueries } from '../state/actions';
export interface Props {
@ -183,8 +183,22 @@ export function RichHistoryCard(props: Props) {
};
const onDeleteQuery = () => {
updateRichHistory(query.ts, 'delete');
appEvents.emit(AppEvents.alertSuccess, ['Query deleted']);
// For starred queries, we want confirmation. For non-starred, we don't.
if (query.starred) {
appEvents.emit(CoreEvents.showConfirmModal, {
title: 'Delete',
text: 'Are you sure you want to permanently delete your starred query?',
yesText: 'Delete',
icon: 'trash-alt',
onConfirm: () => {
updateRichHistory(query.ts, 'delete');
appEvents.emit(AppEvents.alertSuccess, ['Query deleted']);
},
});
} else {
updateRichHistory(query.ts, 'delete');
appEvents.emit(AppEvents.alertSuccess, ['Query deleted']);
}
};
const onStarrQuery = () => {