mirror of https://github.com/grafana/grafana
LibraryPanels: Adds warning when changing to/between library panels (#32892)
* LibraryPanels: Adds warning when changing to/between library panels * Refactor: using ConfirmModal instead * Chore: updates after PR reviewpull/33108/head
parent
4fab30a120
commit
4f3b3b12be
@ -0,0 +1,28 @@ |
||||
import React from 'react'; |
||||
import { ConfirmModal } from '@grafana/ui'; |
||||
|
||||
import { PanelModel } from '../../../dashboard/state'; |
||||
import { isPanelModelLibraryPanel } from '../../guard'; |
||||
|
||||
export interface ChangeLibraryPanelModalProps { |
||||
panel: PanelModel; |
||||
onConfirm: () => void; |
||||
onDismiss: () => void; |
||||
} |
||||
|
||||
export const ChangeLibraryPanelModal = ({ onConfirm, onDismiss, panel }: ChangeLibraryPanelModalProps): JSX.Element => { |
||||
const isLibraryPanel = isPanelModelLibraryPanel(panel); |
||||
const title = `${isLibraryPanel ? 'Changing' : 'Change to'} library panel`; |
||||
const body = `Changing ${isLibraryPanel ? '' : 'to a'} library panel will remove any changes since last save.`; |
||||
return ( |
||||
<ConfirmModal |
||||
onConfirm={onConfirm} |
||||
onDismiss={onDismiss} |
||||
confirmText="Change" |
||||
title={title} |
||||
body={body} |
||||
dismissText="Cancel" |
||||
isOpen={true} |
||||
/> |
||||
); |
||||
}; |
Loading…
Reference in new issue