mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
- Move to using Material-UI's <Icon /> and <SvgIcon /> - Move to using Material-UI's <Tooltip /> - Move to using Material-UI's <IconButton /> - Switch *.svg webpack importer so we can import then as React components - Export the above to the extension API - Move to using the Material-UI's component names for menuItem.icon's. This means that they are now in PascalCase instead of snake_case - Remove the Material-UI font Signed-off-by: Sebastian Malton <sebastian@malton.name>
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import { LensRendererExtension, Store, Interface, Component } from "@k8slens/extensions";
|
|
import { MetricsFeature } from "./src/metrics-feature";
|
|
|
|
export default class ClusterMetricsFeatureExtension extends LensRendererExtension {
|
|
onActivate() {
|
|
const category = Store.catalogCategories.getForGroupKind<Store.KubernetesClusterCategory>("entity.k8slens.dev", "KubernetesCluster");
|
|
|
|
if (!category) {
|
|
return;
|
|
}
|
|
|
|
category.on("contextMenuOpen", this.clusterContextMenuOpen.bind(this));
|
|
}
|
|
|
|
async clusterContextMenuOpen(cluster: Store.KubernetesCluster, ctx: Interface.CatalogEntityContextMenuContext) {
|
|
if (!cluster.status.active) {
|
|
return;
|
|
}
|
|
|
|
const metricsFeature = new MetricsFeature();
|
|
|
|
await metricsFeature.updateStatus(cluster);
|
|
|
|
if (metricsFeature.status.installed) {
|
|
if (metricsFeature.status.canUpgrade) {
|
|
ctx.menuItems.unshift({
|
|
icon: "Refresh",
|
|
title: "Upgrade Lens Metrics stack",
|
|
onClick: async () => {
|
|
metricsFeature.upgrade(cluster);
|
|
}
|
|
});
|
|
}
|
|
ctx.menuItems.unshift({
|
|
icon: "ToggleOff",
|
|
title: "Uninstall Lens Metrics stack",
|
|
onClick: async () => {
|
|
await metricsFeature.uninstall(cluster);
|
|
|
|
Component.Notifications.info(`Lens Metrics has been removed from ${cluster.metadata.name}`, { timeout: 10_000 });
|
|
}
|
|
});
|
|
} else {
|
|
ctx.menuItems.unshift({
|
|
icon: "ToggleOn",
|
|
title: "Install Lens Metrics stack",
|
|
onClick: async () => {
|
|
metricsFeature.install(cluster);
|
|
|
|
Component.Notifications.info(`Lens Metrics is now installed to ${cluster.metadata.name}`, { timeout: 10_000 });
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|