mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Change isEnabledForCluster to use KubernetesCluster instead of Cluster
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
3418c0acfe
commit
185cdaa502
@ -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 [];
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
import React from "react";
|
||||
import { observable, makeObservable } from "mobx";
|
||||
import { observable, makeObservable, when } from "mobx";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { Redirect, Route, Router, Switch } from "react-router";
|
||||
import { history } from "./navigation";
|
||||
@ -74,6 +74,7 @@ import { PortForwardDialog } from "./port-forward";
|
||||
import { DeleteClusterDialog } from "./components/delete-cluster-dialog";
|
||||
import { WorkloadsOverview } from "./components/+workloads-overview/overview";
|
||||
import { KubeObjectListLayout } from "./components/kube-object-list-layout";
|
||||
import type { KubernetesCluster } from "../common/catalog-entities";
|
||||
|
||||
@observer
|
||||
export class ClusterFrame extends React.Component {
|
||||
@ -101,7 +102,11 @@ export class ClusterFrame extends React.Component {
|
||||
|
||||
catalogEntityRegistry.activeEntity = ClusterFrame.clusterId;
|
||||
|
||||
extensionLoader.loadOnClusterRenderer();
|
||||
// Only load the extensions once the catalog has been populated
|
||||
when(
|
||||
() => Boolean(catalogEntityRegistry.activeEntity),
|
||||
() => extensionLoader.loadOnClusterRenderer(catalogEntityRegistry.activeEntity as KubernetesCluster),
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
appEventBus.emit({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user