diff --git a/api/package.json b/api/package.json index 8f9f7a294..510f02f1e 100644 --- a/api/package.json +++ b/api/package.json @@ -1,6 +1,6 @@ { "name": "@devtable/api", - "version": "13.42.3", + "version": "13.42.4", "description": "", "main": "index.js", "scripts": { diff --git a/dashboard/package.json b/dashboard/package.json index cbd8221cf..73b091f85 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -1,6 +1,6 @@ { "name": "@devtable/dashboard", - "version": "13.42.3", + "version": "13.42.4", "license": "Apache-2.0", "publishConfig": { "access": "public", diff --git a/dashboard/src/dashboard-editor/model/layouts/layouts.ts b/dashboard/src/dashboard-editor/model/layouts/layouts.ts index c74bfa073..69f14ba31 100644 --- a/dashboard/src/dashboard-editor/model/layouts/layouts.ts +++ b/dashboard/src/dashboard-editor/model/layouts/layouts.ts @@ -52,6 +52,11 @@ export const LayoutsModel = types layoutSet.removeByPanelID(panelID); }); }, + removeByPanelIDs(panelIDs: string[]) { + self.list.forEach((layoutSet) => { + layoutSet.removeByPanelIDs(panelIDs); + }); + }, setCurrentLayoutWrapperWidth(v: number) { self.currentLayoutWrapperWidth = v; }, diff --git a/dashboard/src/dashboard-editor/model/views/index.ts b/dashboard/src/dashboard-editor/model/views/index.ts index 5b92c6c5b..0278626e9 100644 --- a/dashboard/src/dashboard-editor/model/views/index.ts +++ b/dashboard/src/dashboard-editor/model/views/index.ts @@ -5,6 +5,7 @@ import { PanelsModelInstance } from '../panels'; import { ViewDivisionConfigSnapshotIn, ViewMetaInstance, ViewModalConfigSnapshotIn } from '~/model'; import { ViewModel, ViewModelInstance } from './view'; +import { LayoutsModelInstance } from '../layouts'; export const ViewsModel = types .compose( @@ -45,6 +46,10 @@ export const ViewsModel = types } as const), ); }, + get contentModel() { + // @ts-expect-error getRoot type, reading panels + return getRoot(self).content; + }, })) .actions((self) => ({ setIDOfVIE(id: string) { @@ -52,6 +57,9 @@ export const ViewsModel = types self.visibleViewIDs.length = 0; self.visibleViewIDs.push(id); }, + resetIDOfVIE() { + this.setIDOfVIE(self.current[0].id); + }, replace(current: Array) { self.current.replace(current); }, @@ -88,11 +96,13 @@ export const ViewsModel = types return; } const view = self.current[index]; - // @ts-expect-error getRoot type, reading panels - const panels: PanelsModelInstance = getRoot(self).content.panels; + const panels: PanelsModelInstance = self.contentModel.panels; + const layouts: LayoutsModelInstance = self.contentModel.layouts; panels.removeByIDs(view.panelIDs); + layouts.removeByPanelIDs(view.panelIDs); self.current.splice(index, 1); + this.resetIDOfVIE(); }, replaceByIndex(index: number, replacement: ViewRenderModelInstance) { self.current.splice(index, 1, replacement); @@ -109,7 +119,7 @@ export const ViewsModel = types return; } this.removeByID(self.idOfVIE); - this.setIDOfVIE(self.current[0].id); + this.resetIDOfVIE(); }, })); diff --git a/dashboard/src/model/meta-model/dashboard/content/layout/layout-set.ts b/dashboard/src/model/meta-model/dashboard/content/layout/layout-set.ts index 3e9df7be9..5712422cc 100644 --- a/dashboard/src/model/meta-model/dashboard/content/layout/layout-set.ts +++ b/dashboard/src/model/meta-model/dashboard/content/layout/layout-set.ts @@ -75,6 +75,14 @@ export const LayoutSetMeta = types self.list.splice(i, 1); } }, + removeByPanelIDs(panelIDs: string[]) { + while (panelIDs.length > 0) { + const id = panelIDs.pop(); + if (id) { + this.removeByPanelID(id); + } + } + }, updateLayoutItem(item: Layout) { const layoutItem = self.list.find((o) => o.id === item.i); if (!layoutItem) { diff --git a/package.json b/package.json index 307a159e6..159bbdd62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtable/root", - "version": "13.42.3", + "version": "13.42.4", "private": true, "workspaces": [ "api", diff --git a/settings-form/package.json b/settings-form/package.json index 0f715eb89..e472b4873 100644 --- a/settings-form/package.json +++ b/settings-form/package.json @@ -1,6 +1,6 @@ { "name": "@devtable/settings-form", - "version": "13.42.3", + "version": "13.42.4", "license": "Apache-2.0", "publishConfig": { "access": "public", diff --git a/website/package.json b/website/package.json index 9294a4ebf..6a5d194b9 100644 --- a/website/package.json +++ b/website/package.json @@ -2,7 +2,7 @@ "name": "@devtable/website", "private": true, "license": "Apache-2.0", - "version": "13.42.3", + "version": "13.42.4", "scripts": { "dev": "vite", "preview": "vite preview"