You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
51 lines
1.5 KiB
import React, { useState } from 'react';
|
|
import { Modal } from '@grafana/ui';
|
|
import { css } from '@emotion/css';
|
|
import { SaveDashboardForm } from './forms/SaveDashboardForm';
|
|
import { SaveDashboardErrorProxy } from './SaveDashboardErrorProxy';
|
|
import { useDashboardSave } from './useDashboardSave';
|
|
import { SaveDashboardModalProps } from './types';
|
|
|
|
export const SaveDashboardModal: React.FC<SaveDashboardModalProps> = ({ dashboard, onDismiss, onSaveSuccess }) => {
|
|
const { state, onDashboardSave } = useDashboardSave(dashboard);
|
|
const [dashboardSaveModelClone, setDashboardSaveModelClone] = useState();
|
|
|
|
return (
|
|
<>
|
|
{state.error && (
|
|
<SaveDashboardErrorProxy
|
|
error={state.error}
|
|
dashboard={dashboard}
|
|
dashboardSaveModel={dashboardSaveModelClone}
|
|
onDismiss={onDismiss}
|
|
/>
|
|
)}
|
|
{!state.error && (
|
|
<Modal
|
|
isOpen={true}
|
|
title="Save dashboard"
|
|
icon="copy"
|
|
onDismiss={onDismiss}
|
|
className={css`
|
|
width: 500px;
|
|
`}
|
|
>
|
|
<SaveDashboardForm
|
|
dashboard={dashboard}
|
|
onCancel={onDismiss}
|
|
onSuccess={() => {
|
|
onDismiss();
|
|
if (onSaveSuccess) {
|
|
onSaveSuccess();
|
|
}
|
|
}}
|
|
onSubmit={(clone, options, dashboard) => {
|
|
setDashboardSaveModelClone(clone);
|
|
return onDashboardSave(clone, options, dashboard);
|
|
}}
|
|
/>
|
|
</Modal>
|
|
)}
|
|
</>
|
|
);
|
|
};
|
|
|