From 0872933ce8f248f865dcf663d3842e58b815bc82 Mon Sep 17 00:00:00 2001 From: atrovato <1839717+atrovato@users.noreply.github.com> Date: Sat, 12 Mar 2022 20:00:31 +0100 Subject: [PATCH] Refresh dashbord name #1323 --- front/src/routes/dashboard/index.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/front/src/routes/dashboard/index.js b/front/src/routes/dashboard/index.js index c28c6b15f6..db5948aa1e 100644 --- a/front/src/routes/dashboard/index.js +++ b/front/src/routes/dashboard/index.js @@ -211,14 +211,26 @@ class Dashboard extends Component { unknownError: false }); try { + const { currentDashboard: selectedDashboard, dashboards } = this.state; + const { selector } = selectedDashboard; + const currentDashboard = await this.props.httpClient.patch( - `/api/v1/dashboard/${this.state.currentDashboard.selector}`, + `/api/v1/dashboard/${selector}`, this.state.currentDashboard ); + + const currentDashboardIndex = dashboards.findIndex(d => d.selector === selector); + const updatedDashboards = update(dashboards, { + [currentDashboardIndex]: { + $set: currentDashboard + } + }); + this.setState({ currentDashboard, dashboardEditMode: false, - loading: false + loading: false, + dashboards: updatedDashboards }); } catch (e) { if (e.response && e.response.status === 422) {