Remove cluster view when removed from store (#758)

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala authored and GitHub committed 2020-08-27 16:14:56 +03:00
1 parent 4b3570a190
commit 4196576e99
1 file changed
+7 -1
@@ -1,4 +1,4 @@
import { observable } from "mobx";
import { observable, when } from "mobx";
import { ClusterId, clusterStore } from "../../../common/cluster-store";
import { getMatchedCluster } from "./cluster-view.route"
import logger from "../../../main/logger";
@@ -32,6 +32,12 @@ export async function initView(clusterId: ClusterId) {
})
lensViews.set(clusterId, { clusterId, view: iframe });
parentElem.appendChild(iframe);
// auto-clean when cluster removed
await when(() => !clusterStore.getById(clusterId));
logger.info(`[LENS-VIEW]: remove dashboard, clusterId=${clusterId}`)
parentElem.removeChild(iframe)
lensViews.delete(clusterId)
}
export function refreshViews() {