The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/dashboard-scene/settings/version-history/RevertDashboardModal.tsx

44 lines
1.4 KiB

import { ConfirmModal } from '@grafana/ui';
import { useAppNotification } from 'app/core/copy/appNotification';
import { DashboardInteractions } from 'app/features/dashboard-scene/utils/interactions';
import { DecoratedRevisionModel } from '../VersionsEditView';
export interface RevertDashboardModalProps {
hideModal: () => void;
onRestore: (version: DecoratedRevisionModel) => Promise<boolean>;
version: DecoratedRevisionModel;
}
export const RevertDashboardModal = ({ hideModal, onRestore, version }: RevertDashboardModalProps) => {
const notifyApp = useAppNotification();
const onRestoreDashboard = async () => {
const success = await onRestore(version);
if (success) {
notifyApp.success('Dashboard restored', `Restored from version ${version.version}`);
DashboardInteractions.versionRestoreClicked({ version: version.version, confirm: true });
} else {
notifyApp.error('Dashboard restore failed', `Failed to restore from version ${version.version}`);
}
hideModal();
};
return (
<ConfirmModal
isOpen={true}
title="Restore Version"
icon="history"
onDismiss={hideModal}
onConfirm={onRestoreDashboard}
body={
<p>
Are you sure you want to restore the dashboard to version {version.version}? All unsaved changes will be lost.
</p>
}
confirmText={`Yes, restore to version ${version.version}`}
/>
);
};