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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -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([]);
});
});

View File

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