mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Rework ClusterCatalogRegistry to be a source of truth
Signed-off-by: Sebastian Malton <sebastian@malton.name> move to not storing the Categories anywhere else besides the registry Signed-off-by: Sebastian Malton <sebastian@malton.name> use KubernetesCluster Signed-off-by: Sebastian Malton <sebastian@malton.name> more work towards ClusterManager being the sole owner of ClusterInstances Signed-off-by: Sebastian Malton <sebastian@malton.name> making ClusterManger the source of KubernetesClusters status Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
33422ce975
commit
111356521a
48 files changed
+1027
-685
No files matched your search
@@ -18,11 +18,12 @@
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
import { Catalog, Interface, LensRendererExtension } from "@k8slens/extensions";
|
||||
|
||||
import React from "react";
|
||||
import { LensRendererExtension, Catalog } from "@k8slens/extensions";
|
||||
import { MetricsSettings } from "./src/metrics-settings";
|
||||
|
||||
|
||||
export default class ClusterMetricsFeatureExtension extends LensRendererExtension {
|
||||
entitySettings = [
|
||||
{
|
||||
@@ -39,4 +40,67 @@ export default class ClusterMetricsFeatureExtension extends LensRendererExtensio
|
||||
}
|
||||
}
|
||||
];
|
||||
onActivate() {
|
||||
this.disposers.push(
|
||||
Catalog.CatalogCategoryRegistry.registerHandler(
|
||||
"entity.k8slens.dev/v1alpha1",
|
||||
"KubernetesCluster",
|
||||
"onContextMenuOpen",
|
||||
this.clusterContextMenuOpen,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
clusterContextMenuOpen = (cluster: Catalog.KubernetesCluster): Interface.ContextMenu[] => {
|
||||
if (!cluster.status.active) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const metricsFeature = new MetricsFeature();
|
||||
|
||||
return [
|
||||
{
|
||||
icon: "refresh",
|
||||
title: "Upgrade Lens Metrics stack",
|
||||
onClick: async () => {
|
||||
metricsFeature.upgrade(cluster);
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
// 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: "toggle_off",
|
||||
// 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: "toggle_on",
|
||||
// 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 });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user