123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import React from 'react';
- import { selectors } from '@grafana/e2e-selectors';
- import { Button, ButtonVariant, ModalsController, FullWidthButtonContainer } from '@grafana/ui';
- import { DashboardModel } from 'app/features/dashboard/state';
- import { SaveDashboardDrawer } from './SaveDashboardDrawer';
- interface SaveDashboardButtonProps {
- dashboard: DashboardModel;
- onSaveSuccess?: () => void;
- }
- export const SaveDashboardButton: React.FC<SaveDashboardButtonProps> = ({ dashboard, onSaveSuccess }) => {
- return (
- <ModalsController>
- {({ showModal, hideModal }) => {
- return (
- <Button
- onClick={() => {
- showModal(SaveDashboardDrawer, {
- dashboard,
- onSaveSuccess,
- onDismiss: hideModal,
- });
- }}
- aria-label={selectors.pages.Dashboard.Settings.General.saveDashBoard}
- >
- Save dashboard
- </Button>
- );
- }}
- </ModalsController>
- );
- };
- export const SaveDashboardAsButton: React.FC<SaveDashboardButtonProps & { variant?: ButtonVariant }> = ({
- dashboard,
- onSaveSuccess,
- variant,
- }) => {
- return (
- <ModalsController>
- {({ showModal, hideModal }) => {
- return (
- <FullWidthButtonContainer>
- <Button
- onClick={() => {
- showModal(SaveDashboardDrawer, {
- dashboard,
- onSaveSuccess,
- onDismiss: hideModal,
- isCopy: true,
- });
- }}
- variant={variant}
- aria-label={selectors.pages.Dashboard.Settings.General.saveAsDashBoard}
- >
- Save As...
- </Button>
- </FullWidthButtonContainer>
- );
- }}
- </ModalsController>
- );
- };
|