From 290deca2eb6071f3c54cfecc4fbd7b18cbdc85ef Mon Sep 17 00:00:00 2001 From: Ezequiel Victorero Date: Thu, 13 Jul 2023 09:10:46 -0300 Subject: [PATCH] Dashboards: Save tags on dashboard creation (#71394) Dashboards: save tags on dashboard creation --- .../SaveDashboard/forms/SaveDashboardAsForm.test.tsx | 4 ++++ .../components/SaveDashboard/forms/SaveDashboardAsForm.tsx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx b/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx index 665251f5c2c..807cf6ac44e 100644 --- a/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx +++ b/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx @@ -21,6 +21,7 @@ const prepareDashboardMock = (panel: any) => { const json = { title: 'name', panels: [panel], + tags: ['tag1', 'tag2'], }; return { @@ -67,6 +68,7 @@ describe('SaveDashboardAsForm', () => { expect(savedDashboardModel.id).toBe(null); expect(savedDashboardModel.title).toBe('name'); expect(savedDashboardModel.editable).toBe(true); + expect(savedDashboardModel.tags).toEqual(['tag1', 'tag2']); }); it("appends 'Copy' to the name when the dashboard isnt new", async () => { @@ -80,6 +82,8 @@ describe('SaveDashboardAsForm', () => { expect(spy).toBeCalledTimes(1); const savedDashboardModel = spy.mock.calls[0][0]; expect(savedDashboardModel.title).toBe('name Copy'); + // when copying a dashboard, the tags should be empty + expect(savedDashboardModel.tags).toEqual([]); }); }); diff --git a/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.tsx b/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.tsx index ed78b95e3ff..50a1b9c3a0f 100644 --- a/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.tsx +++ b/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.tsx @@ -80,7 +80,7 @@ export const SaveDashboardAsForm = ({ const clone = getSaveAsDashboardClone(dashboard); clone.title = data.title; - if (!data.copyTags) { + if (!isNew && !data.copyTags) { clone.tags = []; }