mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
import React from 'react';
|
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
import { reportInteraction } from '@grafana/runtime';
|
|
import { Button, ButtonVariant, ComponentSize, ModalsController } from '@grafana/ui';
|
|
import { DashboardModel } from 'app/features/dashboard/state';
|
|
|
|
import { SaveDashboardDrawer } from './SaveDashboardDrawer';
|
|
|
|
interface SaveDashboardButtonProps {
|
|
dashboard: DashboardModel;
|
|
onSaveSuccess?: () => void;
|
|
size?: ComponentSize;
|
|
}
|
|
|
|
export const SaveDashboardButton = ({ dashboard, onSaveSuccess, size }: SaveDashboardButtonProps) => {
|
|
return (
|
|
<ModalsController>
|
|
{({ showModal, hideModal }) => {
|
|
return (
|
|
<Button
|
|
size={size}
|
|
onClick={() => {
|
|
showModal(SaveDashboardDrawer, {
|
|
dashboard,
|
|
onSaveSuccess,
|
|
onDismiss: hideModal,
|
|
});
|
|
}}
|
|
aria-label={selectors.pages.Dashboard.Settings.General.saveDashBoard}
|
|
>
|
|
Save dashboard
|
|
</Button>
|
|
);
|
|
}}
|
|
</ModalsController>
|
|
);
|
|
};
|
|
|
|
type Props = SaveDashboardButtonProps & { variant?: ButtonVariant };
|
|
|
|
export const SaveDashboardAsButton = ({ dashboard, onSaveSuccess, variant, size }: Props) => {
|
|
return (
|
|
<ModalsController>
|
|
{({ showModal, hideModal }) => {
|
|
return (
|
|
<Button
|
|
size={size}
|
|
onClick={() => {
|
|
reportInteraction('grafana_dashboard_save_as_clicked');
|
|
showModal(SaveDashboardDrawer, {
|
|
dashboard,
|
|
onSaveSuccess,
|
|
onDismiss: hideModal,
|
|
isCopy: true,
|
|
});
|
|
}}
|
|
variant={variant}
|
|
aria-label={selectors.pages.Dashboard.Settings.General.saveAsDashBoard}
|
|
>
|
|
Save as
|
|
</Button>
|
|
);
|
|
}}
|
|
</ModalsController>
|
|
);
|
|
};
|