Files
grafana/public/app/features/dashboard/components/SaveDashboard/SaveDashboardButton.tsx

68 lines
1.9 KiB
TypeScript
Raw Normal View History

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: migrate version history list (#29970) * refactor(dashboard): remove redundant directive code from SaveDashboardAsButton * feat(dashboard): initial commit of rendering version history with react * feat(dashboard): append versions, use historySrv, UI as functional components * feat(dashboard): initial commit of versions settings diff view * refactor(historylist): remove code related to listing versions * refactor(dashboard): use angular directive to render version comparison * refactor(dashboard): clean up versions settings * refactor(dashboard): move version history UI components into own files * refactor(dashboard): update typings for version history react components * feat(dashboard): initial commit of react revert dashboard modal * test(dashboardsettings): clean up historylistctrl tests * chore(dashboardsettings): remove unused state variable * test(dashboardsettings): initial commit of VersionSettings component tests * feat(grafana-ui): add className concatenation on Checkbox label * Apply suggestions from code review Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com> * test(dashboardsettings): add more tests for Versions Settings react component * test(dashboardsettings): add test to assert latest badge in Version history table * fix(dashboardsettings): pass string to getDiff instead of react event object * test(dashboardsettings): remove failing test from versions settings * Moved scroll area to content, and fixed colors * Update public/app/features/dashboard/components/DashboardSettings/VersionsSettings.test.tsx Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com> * style(dashboardsettings): add new lines to versions settings tests Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com> Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2021-01-19 13:19:01 +01:00
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>
);
};