mirror of https://github.com/grafana/grafana
SaveDashboard: remove feature flag for save drawer (#48462)
parent
da1d34e83d
commit
a8f3b17262
@ -1,52 +0,0 @@ |
||||
import { css } from '@emotion/css'; |
||||
import React, { useState } from 'react'; |
||||
|
||||
import { Modal } from '@grafana/ui'; |
||||
|
||||
import { SaveDashboardErrorProxy } from './SaveDashboardErrorProxy'; |
||||
import { SaveDashboardAsForm } from './forms/SaveDashboardAsForm'; |
||||
import { SaveDashboardModalProps } from './types'; |
||||
import { useDashboardSave } from './useDashboardSave'; |
||||
|
||||
export const SaveDashboardAsModal: React.FC< |
||||
SaveDashboardModalProps & { |
||||
isNew?: boolean; |
||||
} |
||||
> = ({ dashboard, onDismiss, isNew }) => { |
||||
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 as..." |
||||
icon="copy" |
||||
onDismiss={onDismiss} |
||||
className={css` |
||||
width: 500px; |
||||
`}
|
||||
> |
||||
<SaveDashboardAsForm |
||||
dashboard={dashboard} |
||||
onCancel={onDismiss} |
||||
onSuccess={onDismiss} |
||||
onSubmit={(clone, options, dashboard) => { |
||||
setDashboardSaveModelClone(clone); |
||||
return onDashboardSave(clone, options, dashboard); |
||||
}} |
||||
isNew={isNew} |
||||
/> |
||||
</Modal> |
||||
)} |
||||
</> |
||||
); |
||||
}; |
||||
@ -1,66 +0,0 @@ |
||||
import { css } from '@emotion/css'; |
||||
import React, { useMemo, useState } from 'react'; |
||||
|
||||
import { Modal } from '@grafana/ui'; |
||||
|
||||
import { SaveDashboardErrorProxy } from './SaveDashboardErrorProxy'; |
||||
import { SaveDashboardForm } from './forms/SaveDashboardForm'; |
||||
import { SaveDashboardModalProps, SaveDashboardOptions, SaveDashboardData } from './types'; |
||||
import { useDashboardSave } from './useDashboardSave'; |
||||
|
||||
export const SaveDashboardModal: React.FC<SaveDashboardModalProps> = ({ dashboard, onDismiss, onSaveSuccess }) => { |
||||
const { state, onDashboardSave } = useDashboardSave(dashboard); |
||||
const [dashboardSaveModelClone, setDashboardSaveModelClone] = useState(); |
||||
const [options, setOptions] = useState<SaveDashboardOptions>({}); |
||||
|
||||
const data = useMemo<SaveDashboardData>(() => { |
||||
const clone = dashboard.getSaveModelClone({ |
||||
saveTimerange: Boolean(options.saveTimerange), |
||||
saveVariables: Boolean(options.saveVariables), |
||||
}); |
||||
|
||||
return { clone, diff: {}, diffCount: 0, hasChanges: true }; |
||||
}, [dashboard, options]); |
||||
|
||||
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} |
||||
saveModel={data} |
||||
options={options} |
||||
onSuccess={() => { |
||||
onDismiss(); |
||||
if (onSaveSuccess) { |
||||
onSaveSuccess(); |
||||
} |
||||
}} |
||||
onSubmit={(clone, options, dashboard) => { |
||||
setDashboardSaveModelClone(clone); |
||||
return onDashboardSave(clone, options, dashboard); |
||||
}} |
||||
onOptionsChange={setOptions} |
||||
/> |
||||
</Modal> |
||||
)} |
||||
</> |
||||
); |
||||
}; |
||||
@ -1,43 +0,0 @@ |
||||
import React from 'react'; |
||||
|
||||
import { config } from '@grafana/runtime'; |
||||
|
||||
import { SaveDashboardAsModal } from './SaveDashboardAsModal'; |
||||
import { SaveDashboardDrawer } from './SaveDashboardDrawer'; |
||||
import { SaveDashboardModal } from './SaveDashboardModal'; |
||||
import { SaveProvisionedDashboard } from './SaveProvisionedDashboard'; |
||||
import { SaveDashboardModalProps } from './types'; |
||||
|
||||
export const SaveDashboardProxy: React.FC<SaveDashboardModalProps> = ({ |
||||
dashboard, |
||||
onDismiss, |
||||
onSaveSuccess, |
||||
isCopy, |
||||
}) => { |
||||
if (config.featureToggles.saveDashboardDrawer) { |
||||
return ( |
||||
<SaveDashboardDrawer dashboard={dashboard} onDismiss={onDismiss} onSaveSuccess={onSaveSuccess} isCopy={isCopy} /> |
||||
); |
||||
} |
||||
|
||||
const isProvisioned = dashboard.meta.provisioned; |
||||
const isNew = dashboard.version === 0; |
||||
const isChanged = dashboard.version > 0; |
||||
|
||||
const modalProps = { |
||||
dashboard, |
||||
onDismiss, |
||||
onSaveSuccess, |
||||
isCopy, |
||||
}; |
||||
|
||||
if (isNew || isCopy) { |
||||
return <SaveDashboardAsModal {...modalProps} isNew />; |
||||
} |
||||
return ( |
||||
<> |
||||
{isChanged && !isProvisioned && <SaveDashboardModal {...modalProps} />} |
||||
{isProvisioned && <SaveProvisionedDashboard {...modalProps} />} |
||||
</> |
||||
); |
||||
}; |
||||
@ -1,14 +0,0 @@ |
||||
import React from 'react'; |
||||
|
||||
import { Modal } from '@grafana/ui'; |
||||
|
||||
import { SaveProvisionedDashboardForm } from './forms/SaveProvisionedDashboardForm'; |
||||
import { SaveDashboardModalProps } from './types'; |
||||
|
||||
export const SaveProvisionedDashboard: React.FC<SaveDashboardModalProps> = ({ dashboard, onDismiss }) => { |
||||
return ( |
||||
<Modal isOpen={true} title="Cannot save provisioned dashboard" icon="copy" onDismiss={onDismiss}> |
||||
<SaveProvisionedDashboardForm dashboard={dashboard} onCancel={onDismiss} onSuccess={onDismiss} /> |
||||
</Modal> |
||||
); |
||||
}; |
||||
Loading…
Reference in new issue