diff --git a/public/app/features/dashboard-scene/saving/SaveDashboardDrawer.tsx b/public/app/features/dashboard-scene/saving/SaveDashboardDrawer.tsx index 9e7ea7c8357..27da5cbbb9a 100644 --- a/public/app/features/dashboard-scene/saving/SaveDashboardDrawer.tsx +++ b/public/app/features/dashboard-scene/saving/SaveDashboardDrawer.tsx @@ -102,7 +102,14 @@ function SaveDashboardDrawerComponent({ model }: SceneComponentProps; + return ( + + ); } if (saveAsCopy || changeInfo.isNew) { diff --git a/public/app/features/dashboard-scene/scene/DashboardScene.tsx b/public/app/features/dashboard-scene/scene/DashboardScene.tsx index a542dd92826..d0fafd6f2bb 100644 --- a/public/app/features/dashboard-scene/scene/DashboardScene.tsx +++ b/public/app/features/dashboard-scene/scene/DashboardScene.tsx @@ -835,7 +835,7 @@ export class DashboardScene extends SceneObjectBase impleme kind: 'Dashboard', metadata: { ...meta.k8s, - name: meta.uid ?? meta.k8s?.name, + name: options.isNew ? undefined : (meta.uid ?? meta.k8s?.name), generateName: options.isNew ? 'd' : undefined, }, spec, diff --git a/public/app/features/dashboard-scene/serialization/DashboardSceneSerializer.ts b/public/app/features/dashboard-scene/serialization/DashboardSceneSerializer.ts index dda09ade2d4..cede8f605a5 100644 --- a/public/app/features/dashboard-scene/serialization/DashboardSceneSerializer.ts +++ b/public/app/features/dashboard-scene/serialization/DashboardSceneSerializer.ts @@ -178,7 +178,7 @@ export class V1DashboardSerializer uid: '', title: options.title || '', description: options.description || undefined, - tags: options.isNew || options.copyTags ? saveModel.tags : [], + tags: options.copyTags === false ? [] : saveModel.tags, }; } @@ -390,7 +390,7 @@ export class V2DashboardSerializer ...saveModel, title: options.title || '', description: options.description || '', - tags: options.isNew || options.copyTags ? saveModel.tags : [], + tags: options.copyTags === false ? [] : saveModel.tags, }; } diff --git a/public/app/features/provisioning/components/Dashboards/SaveProvisionedDashboard.tsx b/public/app/features/provisioning/components/Dashboards/SaveProvisionedDashboard.tsx index fca774ef84c..5c3679ad795 100644 --- a/public/app/features/provisioning/components/Dashboards/SaveProvisionedDashboard.tsx +++ b/public/app/features/provisioning/components/Dashboards/SaveProvisionedDashboard.tsx @@ -10,10 +10,14 @@ export interface SaveProvisionedDashboardProps { dashboard: DashboardScene; drawer: SaveDashboardDrawer; changeInfo: DashboardChangeInfo; + saveAsCopy?: boolean; } -export function SaveProvisionedDashboard({ drawer, changeInfo, dashboard }: SaveProvisionedDashboardProps) { - const { isNew, defaultValues, workflowOptions, readOnly, repository } = useProvisionedDashboardData(dashboard); +export function SaveProvisionedDashboard({ drawer, changeInfo, dashboard, saveAsCopy }: SaveProvisionedDashboardProps) { + const { isNew, defaultValues, workflowOptions, readOnly, repository } = useProvisionedDashboardData( + dashboard, + saveAsCopy + ); if (!defaultValues) { return null; @@ -24,11 +28,12 @@ export function SaveProvisionedDashboard({ drawer, changeInfo, dashboard }: Save dashboard={dashboard} drawer={drawer} changeInfo={changeInfo} - isNew={isNew} + isNew={isNew || !!saveAsCopy} defaultValues={defaultValues} repository={repository} workflowOptions={workflowOptions} readOnly={readOnly} + saveAsCopy={saveAsCopy} /> ); } diff --git a/public/app/features/provisioning/components/Dashboards/SaveProvisionedDashboardForm.tsx b/public/app/features/provisioning/components/Dashboards/SaveProvisionedDashboardForm.tsx index effa2e5c0e7..219bb521111 100644 --- a/public/app/features/provisioning/components/Dashboards/SaveProvisionedDashboardForm.tsx +++ b/public/app/features/provisioning/components/Dashboards/SaveProvisionedDashboardForm.tsx @@ -6,7 +6,7 @@ import { AppEvents, locationUtil } from '@grafana/data'; import { Trans, t } from '@grafana/i18n'; import { getAppEvents, locationService, reportInteraction } from '@grafana/runtime'; import { Dashboard } from '@grafana/schema'; -import { Button, Field, Input, Stack, TextArea } from '@grafana/ui'; +import { Button, Field, Input, Stack, TextArea, Switch } from '@grafana/ui'; import { RepositoryView, Unstructured } from 'app/api/clients/provisioning/v0alpha1'; import kbn from 'app/core/utils/kbn'; import { Resource } from 'app/features/apiserver/types'; @@ -47,6 +47,7 @@ export function SaveProvisionedDashboardForm({ workflowOptions, readOnly, repository, + saveAsCopy, }: Props) { const navigate = useNavigate(); const appEvents = getAppEvents(); @@ -166,7 +167,15 @@ export function SaveProvisionedDashboardForm({ }); // Submit handler for saving the form data - const handleFormSubmit = async ({ title, description, repo, path, comment, ref }: ProvisionedDashboardFormData) => { + const handleFormSubmit = async ({ + title, + description, + repo, + path, + comment, + ref, + copyTags, + }: ProvisionedDashboardFormData) => { // Validate required fields if (!repo || !path) { console.error('Missing required fields for saving:', { repo, path }); @@ -185,7 +194,8 @@ export function SaveProvisionedDashboardForm({ isNew, title, description, - copyTags: true, + copyTags, + saveAsCopy, }); reportInteraction('grafana_provisioning_dashboard_save_submitted', { @@ -287,6 +297,12 @@ export function SaveProvisionedDashboardForm({ isNew={isNew} /> + {saveAsCopy && ( + + + + )} +