From eeae71163ca973c2eed759c1b9479c88f55b4bc1 Mon Sep 17 00:00:00 2001 From: Pranshu Chittora Date: Tue, 28 Jun 2022 16:19:46 +0530 Subject: [PATCH] fix: dashboard save layout (#1320) Co-authored-by: Palash --- .../src/container/GridGraphLayout/index.tsx | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/frontend/src/container/GridGraphLayout/index.tsx b/frontend/src/container/GridGraphLayout/index.tsx index 8f7ea56c15..d80b12f7a1 100644 --- a/frontend/src/container/GridGraphLayout/index.tsx +++ b/frontend/src/container/GridGraphLayout/index.tsx @@ -113,20 +113,21 @@ function GridGraph(props: Props): JSX.Element { errorMessage: '', loading: true, })); - + const updatedDashboard: Dashboard = { + ...selectedDashboard, + data: { + title: data.title, + description: data.description, + name: data.name, + tags: data.tags, + widgets: data.widgets, + layout, + }, + uuid: selectedDashboard.uuid, + }; // Save layout only when users has the has the permission to do so. if (saveLayoutPermission) { - const response = await updateDashboardApi({ - data: { - title: data.title, - description: data.description, - name: data.name, - tags: data.tags, - widgets: data.widgets, - layout, - }, - uuid: selectedDashboard.uuid, - }); + const response = await updateDashboardApi(updatedDashboard); if (response.statusCode === 200) { setSaveLayoutState((state) => ({ ...state, @@ -134,6 +135,10 @@ function GridGraph(props: Props): JSX.Element { errorMessage: '', loading: false, })); + dispatch({ + type: UPDATE_DASHBOARD, + payload: updatedDashboard, + }); } else { setSaveLayoutState((state) => ({ ...state, @@ -153,8 +158,9 @@ function GridGraph(props: Props): JSX.Element { data.tags, data.title, data.widgets, + dispatch, saveLayoutPermission, - selectedDashboard.uuid, + selectedDashboard, ], );