some work, still need to fix the race condition on emitting

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2021-04-12 11:51:18 -04:00
1 parent 99a464c61d
commit a38cb10720
17 files changed
+4341 -108

No files matched your search

@@ -45,25 +45,26 @@ export class KubernetesCluster implements CatalogEntity {
}
async onContextMenuOpen(context: CatalogEntityContextMenuContext) {
context.menuItems = [
context.menuItems.push(
{
icon: "settings",
icon: "Settings",
title: "Settings",
onClick: async () => context.navigate(`/cluster/${this.metadata.uid}/settings`)
},
{
icon: "delete",
icon: "Delete",
title: "Delete",
onClick: async () => clusterStore.removeById(this.metadata.uid),
confirm: {
message: `Remove Kubernetes Cluster "${this.metadata.name} from Lens?`
}
},
];
);
if (this.status.active) {
context.menuItems.unshift({
icon: "link_off",
icon: "LinkOff",
title: "Disconnect",
onClick: async () => {
clusterStore.deactivate(this.metadata.uid);
@@ -72,9 +73,9 @@ export class KubernetesCluster implements CatalogEntity {
});
}
const category = catalogCategoryRegistry.getCategoryForEntity<KubernetesClusterCategory>(this);
if (category) category.emit("contextMenuOpen", this, context);
catalogCategoryRegistry
.getCategoryForEntity<KubernetesClusterCategory>(this)
?.emit("contextMenuOpen", );
}
}
+4 -2
View File
@@ -1,3 +1,5 @@
import Icons from "@material-ui/icons";
export interface CatalogCategoryVersion {
name: string;
entityClass: { new(data: CatalogEntityData): CatalogEntity };
@@ -43,7 +45,7 @@ export interface CatalogEntityActionContext {
}
export type CatalogEntityContextMenu = {
icon: string;
icon: keyof typeof Icons;
title: string;
onClick: () => Promise<void>;
confirm?: {
@@ -53,7 +55,7 @@ export type CatalogEntityContextMenu = {
export interface CatalogEntityContextMenuContext {
navigate: (url: string) => void;
menuItems: CatalogEntityContextMenu[];
menuItems: Promise<CatalogEntityContextMenu[] | CatalogEntityContextMenu>[];
}
export type CatalogEntityData = {