UnsavedChangesModal.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { css } from '@emotion/css';
  2. import React from 'react';
  3. import { Button, Modal } from '@grafana/ui';
  4. import { DashboardModel } from '../../state';
  5. import { SaveDashboardButton } from './SaveDashboardButton';
  6. interface UnsavedChangesModalProps {
  7. dashboard: DashboardModel;
  8. onDiscard: () => void;
  9. onDismiss: () => void;
  10. onSaveSuccess?: () => void;
  11. }
  12. export const UnsavedChangesModal: React.FC<UnsavedChangesModalProps> = ({
  13. dashboard,
  14. onSaveSuccess,
  15. onDiscard,
  16. onDismiss,
  17. }) => {
  18. return (
  19. <Modal
  20. isOpen={true}
  21. title="Unsaved changes"
  22. onDismiss={onDismiss}
  23. icon="exclamation-triangle"
  24. className={css`
  25. width: 500px;
  26. `}
  27. >
  28. <h5>Do you want to save your changes?</h5>
  29. <Modal.ButtonRow>
  30. <Button variant="secondary" onClick={onDismiss} fill="outline">
  31. Cancel
  32. </Button>
  33. <Button variant="destructive" onClick={onDiscard}>
  34. Discard
  35. </Button>
  36. <SaveDashboardButton dashboard={dashboard} onSaveSuccess={onSaveSuccess} />
  37. </Modal.ButtonRow>
  38. </Modal>
  39. );
  40. };