Change isEnabledForCluster to use KubernetesCluster instead of Cluster (#4584)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-12-17 08:28:47 -05:00
1 parent 3418c0acfe
commit bde0a9ef91
6 files changed
+74 -20

No files matched your search

@@ -25,10 +25,10 @@ import { isEqual } from "lodash";
import { action, computed, makeObservable, observable, observe, reaction, when } from "mobx";
import path from "path";
import { AppPaths } from "../../common/app-paths";
import { ClusterStore } from "../../common/cluster-store";
import { broadcastMessage, ipcMainOn, ipcRendererOn, requestMain, ipcMainHandle } from "../../common/ipc";
import { Disposer, getHostedClusterId, toJS } from "../../common/utils";
import { Disposer, toJS } from "../../common/utils";
import logger from "../../main/logger";
import type { KubernetesCluster } from "../common-api/catalog";
import type { InstalledExtension } from "../extension-discovery";
import { ExtensionsStore } from "../extensions-store";
import type { LensExtension, LensExtensionConstructor, LensExtensionId } from "../lens-extension";
@@ -280,12 +280,11 @@ export class ExtensionLoader {
});
}
loadOnClusterRenderer() {
loadOnClusterRenderer(entity: KubernetesCluster) {
logger.debug(`${logModule}: load on cluster renderer (dashboard)`);
const cluster = ClusterStore.getInstance().getById(getHostedClusterId());
this.autoInitExtensions(async (extension: LensRendererExtension) => {
if ((await extension.isEnabledForCluster(cluster)) === false) {
if ((await extension.isEnabledForCluster(entity)) === false) {
return [];
}
+6 -3
View File
@@ -20,13 +20,13 @@
*/
import type * as registries from "./registries";
import type { Cluster } from "../main/cluster";
import { Disposers, LensExtension } from "./lens-extension";
import { getExtensionPageUrl } from "./registries/page-registry";
import type { CatalogEntity } from "../common/catalog";
import type { Disposer } from "../common/utils";
import { catalogEntityRegistry, EntityFilter } from "../renderer/api/catalog-entity-registry";
import { catalogCategoryRegistry, CategoryFilter } from "../renderer/api/catalog-category-registry";
import type { KubernetesCluster } from "../common/catalog-entities";
export class LensRendererExtension extends LensExtension {
globalPages: registries.PageRegistration[] = [];
@@ -57,9 +57,12 @@ export class LensRendererExtension extends LensExtension {
}
/**
* Defines if extension is enabled for a given cluster. Defaults to `true`.
* Defines if extension is enabled for a given cluster. This method is only
* called when the extension is created within a cluster frame.
*
* The default implementation is to return `true`
*/
async isEnabledForCluster(cluster: Cluster): Promise<Boolean> {
async isEnabledForCluster(cluster: KubernetesCluster): Promise<Boolean> {
return (void cluster) || true;
}