ChangeLibraryPanelModal.tsx 943 B

12345678910111213141516171819202122232425262728293031
  1. import React from 'react';
  2. import { ConfirmModal } from '@grafana/ui';
  3. import { PanelModel } from '../../../dashboard/state';
  4. import { isPanelModelLibraryPanel } from '../../guard';
  5. export interface ChangeLibraryPanelModalProps {
  6. panel: PanelModel;
  7. onConfirm: () => void;
  8. onDismiss: () => void;
  9. }
  10. export const ChangeLibraryPanelModal = ({ onConfirm, onDismiss, panel }: ChangeLibraryPanelModalProps): JSX.Element => {
  11. const isLibraryPanel = isPanelModelLibraryPanel(panel);
  12. const title = `${isLibraryPanel ? 'Changing' : 'Replace with'} library panel`;
  13. const body = `${
  14. isLibraryPanel ? 'Changing' : 'Replacing with a'
  15. } library panel will remove any changes since last save.`;
  16. return (
  17. <ConfirmModal
  18. onConfirm={onConfirm}
  19. onDismiss={onDismiss}
  20. confirmText={isLibraryPanel ? 'Change' : 'Replace'}
  21. title={title}
  22. body={body}
  23. dismissText="Cancel"
  24. isOpen={true}
  25. />
  26. );
  27. };