From 1327bdf575d5db0ab7f8a08a8de74cc862b0aa6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 18 Apr 2024 08:46:24 +0200 Subject: [PATCH] DashboardScene: Fixes issue saving new dashboard from panel edit (#86477) --- .../scene/DashboardScene.test.tsx | 21 +++++++++++++++++++ .../dashboard-scene/scene/DashboardScene.tsx | 1 + 2 files changed, 22 insertions(+) diff --git a/public/app/features/dashboard-scene/scene/DashboardScene.test.tsx b/public/app/features/dashboard-scene/scene/DashboardScene.test.tsx index 14908c5586a..0bbe46104db 100644 --- a/public/app/features/dashboard-scene/scene/DashboardScene.test.tsx +++ b/public/app/features/dashboard-scene/scene/DashboardScene.test.tsx @@ -102,6 +102,27 @@ describe('DashboardScene', () => { }); }); + describe('Given new dashboard in edit mode', () => { + it('when saving it should clear isNew state', () => { + const scene = buildTestScene({ + meta: { isNew: true }, + }); + + scene.activate(); + scene.onEnterEditMode(); + scene.saveCompleted({} as Dashboard, { + id: 1, + slug: 'slug', + uid: 'dash-1', + url: 'sss', + version: 2, + status: 'aaa', + }); + + expect(scene.state.meta.isNew).toBeFalsy(); + }); + }); + describe('Given scene in edit mode', () => { let scene: DashboardScene; let deactivateScene: () => void; diff --git a/public/app/features/dashboard-scene/scene/DashboardScene.tsx b/public/app/features/dashboard-scene/scene/DashboardScene.tsx index f7823513b41..eef7d822012 100644 --- a/public/app/features/dashboard-scene/scene/DashboardScene.tsx +++ b/public/app/features/dashboard-scene/scene/DashboardScene.tsx @@ -252,6 +252,7 @@ export class DashboardScene extends SceneObjectBase { url: result.url, slug: result.slug, folderUid: folderUid, + isNew: false, }, });