mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboards: load from storage (#51949)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { useAsync } from 'react-use';
|
||||
|
||||
import { Drawer, Tab, TabsBar } from '@grafana/ui';
|
||||
import { Drawer, Spinner, Tab, TabsBar } from '@grafana/ui';
|
||||
import { backendSrv } from 'app/core/services/backend_srv';
|
||||
|
||||
import { jsonDiff } from '../VersionHistory/utils';
|
||||
@@ -70,6 +70,14 @@ export const SaveDashboardDrawer = ({ dashboard, onDismiss, onSaveSuccess, isCop
|
||||
return <SaveDashboardDiff diff={data.diff} oldValue={previous.value} newValue={data.clone} />;
|
||||
}
|
||||
|
||||
if (state.loading) {
|
||||
return (
|
||||
<div>
|
||||
<Spinner />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (isNew || isCopy) {
|
||||
return (
|
||||
<SaveDashboardAsForm
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { CloneOptions, DashboardModel } from 'app/features/dashboard/state/DashboardModel';
|
||||
import { DashboardDataDTO } from 'app/types';
|
||||
|
||||
import { Diffs } from '../VersionHistory/utils';
|
||||
|
||||
@@ -16,6 +17,13 @@ export interface SaveDashboardOptions extends CloneOptions {
|
||||
makeEditable?: boolean;
|
||||
}
|
||||
|
||||
export interface SaveDashboardCommand {
|
||||
dashboard: DashboardDataDTO;
|
||||
message?: string;
|
||||
folderId?: number;
|
||||
overwrite?: boolean;
|
||||
}
|
||||
|
||||
export interface SaveDashboardFormProps {
|
||||
dashboard: DashboardModel;
|
||||
onCancel: () => void;
|
||||
|
||||
@@ -36,6 +36,9 @@ export const useDashboardSave = (dashboard: DashboardModel) => {
|
||||
|
||||
const notifyApp = useAppNotification();
|
||||
useEffect(() => {
|
||||
if (state.error) {
|
||||
notifyApp.error(state.error.message ?? 'Error saving dashboard');
|
||||
}
|
||||
if (state.value) {
|
||||
dashboard.version = state.value.version;
|
||||
dashboard.clearUnsavedChanges();
|
||||
|
||||
Reference in New Issue
Block a user