mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Make all of Command* injectable, with some others too
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
abe90ad92a
commit
f8ae1149fb
44 files changed
+868
-753
No files matched your search
@@ -22,32 +22,12 @@
|
||||
import React from "react";
|
||||
import fs from "fs";
|
||||
import "../../common/catalog-entities/kubernetes-cluster";
|
||||
import { WebLinkCategory } from "../../common/catalog-entities";
|
||||
import { ClusterStore } from "../../common/cluster-store";
|
||||
import { catalogCategoryRegistry } from "../api/catalog-category-registry";
|
||||
import { WeblinkAddCommand } from "../components/catalog-entities/weblink-add-command";
|
||||
import { CommandOverlay } from "../components/command-palette";
|
||||
import { loadConfigFromString } from "../../common/kube-helpers";
|
||||
import { DeleteClusterDialog } from "../components/delete-cluster-dialog";
|
||||
|
||||
function initWebLinks() {
|
||||
WebLinkCategory.onAdd = () => CommandOverlay.open(<WeblinkAddCommand />);
|
||||
}
|
||||
|
||||
function initKubernetesClusters() {
|
||||
catalogCategoryRegistry
|
||||
.getForGroupKind("entity.k8slens.dev", "KubernetesCluster")
|
||||
.on("contextMenuOpen", (entity, context) => {
|
||||
if (entity.metadata?.source == "local") {
|
||||
context.menuItems.push({
|
||||
title: "Delete",
|
||||
icon: "delete",
|
||||
onClick: () => onClusterDelete(entity.metadata.uid),
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function onClusterDelete(clusterId: string) {
|
||||
const cluster = ClusterStore.getInstance().getById(clusterId);
|
||||
|
||||
@@ -64,7 +44,29 @@ async function onClusterDelete(clusterId: string) {
|
||||
DeleteClusterDialog.open({ cluster, config });
|
||||
}
|
||||
|
||||
export function initCatalog() {
|
||||
initWebLinks();
|
||||
initKubernetesClusters();
|
||||
interface Dependencies {
|
||||
openCommandDialog: (component: React.ReactElement) => void;
|
||||
}
|
||||
|
||||
export function initCatalog({ openCommandDialog }: Dependencies) {
|
||||
catalogCategoryRegistry
|
||||
.getForGroupKind("entity.k8slens.dev", "WebLink")
|
||||
.on("catalogAddMenu", ctx => {
|
||||
ctx.menuItems.push({
|
||||
title: "Add web link",
|
||||
icon: "public",
|
||||
onClick: () => openCommandDialog(<WeblinkAddCommand />),
|
||||
});
|
||||
});
|
||||
catalogCategoryRegistry
|
||||
.getForGroupKind("entity.k8slens.dev", "KubernetesCluster")
|
||||
.on("contextMenuOpen", (entity, context) => {
|
||||
if (entity.metadata?.source == "local") {
|
||||
context.menuItems.push({
|
||||
title: "Delete",
|
||||
icon: "delete",
|
||||
onClick: () => onClusterDelete(entity.metadata.uid),
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user