Dashboards: Save tags on dashboard creation (#71394)

Dashboards: save tags on dashboard creation
This commit is contained in:
Ezequiel Victorero
2023-07-13 09:10:46 -03:00
committed by GitHub
parent 0083b2e346
commit 290deca2eb
2 changed files with 5 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ const prepareDashboardMock = (panel: any) => {
const json = { const json = {
title: 'name', title: 'name',
panels: [panel], panels: [panel],
tags: ['tag1', 'tag2'],
}; };
return { return {
@@ -67,6 +68,7 @@ describe('SaveDashboardAsForm', () => {
expect(savedDashboardModel.id).toBe(null); expect(savedDashboardModel.id).toBe(null);
expect(savedDashboardModel.title).toBe('name'); expect(savedDashboardModel.title).toBe('name');
expect(savedDashboardModel.editable).toBe(true); expect(savedDashboardModel.editable).toBe(true);
expect(savedDashboardModel.tags).toEqual(['tag1', 'tag2']);
}); });
it("appends 'Copy' to the name when the dashboard isnt new", async () => { it("appends 'Copy' to the name when the dashboard isnt new", async () => {
@@ -80,6 +82,8 @@ describe('SaveDashboardAsForm', () => {
expect(spy).toBeCalledTimes(1); expect(spy).toBeCalledTimes(1);
const savedDashboardModel = spy.mock.calls[0][0]; const savedDashboardModel = spy.mock.calls[0][0];
expect(savedDashboardModel.title).toBe('name Copy'); expect(savedDashboardModel.title).toBe('name Copy');
// when copying a dashboard, the tags should be empty
expect(savedDashboardModel.tags).toEqual([]);
}); });
}); });

View File

@@ -80,7 +80,7 @@ export const SaveDashboardAsForm = ({
const clone = getSaveAsDashboardClone(dashboard); const clone = getSaveAsDashboardClone(dashboard);
clone.title = data.title; clone.title = data.title;
if (!data.copyTags) { if (!isNew && !data.copyTags) {
clone.tags = []; clone.tags = [];
} }