fix(ui): sync dashboards edits properly

This commit is contained in:
Shekar Siri 2024-11-15 11:01:56 +01:00
parent 99a83fab5e
commit 3188b0ad6f
2 changed files with 8 additions and 2 deletions

View file

@ -68,6 +68,8 @@ function DashboardView(props: Props) {
onAddWidgets();
trimQuery();
}
return () => dashboardStore.resetSelectedDashboard()
}, []);
useEffect(() => {

View file

@ -216,9 +216,9 @@ export default class DashboardStore {
syncDashboardInfo(id: string, info: { name: string, description: string, isPublic: boolean, createdAt: number }) {
if (this.selectedDashboard !== null) {
this.selectedDashboard.updateInfo(info)
const index = this.dashboards.findIndex((d) => d.dashboardId === id);
this.dashboards[index].updateInfo(info);
}
const index = this.dashboards.findIndex((d) => d.dashboardId === id);
this.dashboards[index].updateInfo(info);
}
saveMetric(metric: Widget, dashboardId: string): Promise<any> {
@ -320,6 +320,10 @@ export default class DashboardStore {
}
};
resetSelectedDashboard = () => {
this.selectedDashboard = null
}
setSiteId = (siteId: any) => {
this.siteId = siteId;
};