diff --git a/Makefile b/Makefile index 1f8d4f5392..40eff8445f 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ binaries/client: yarn download-bins node_modules: - yarn install --frozen-lockfile --verbose + yarn install --frozen-lockfile yarn check --verify-tree --integrity static/build/LensDev.html: diff --git a/extensions/example-extension/package-lock.json b/extensions/example-extension/package-lock.json index 6ab5142f50..cf3390a42b 100644 --- a/extensions/example-extension/package-lock.json +++ b/extensions/example-extension/package-lock.json @@ -1,5 +1,5 @@ { - "name": "extension-example", + "name": "example-extension", "version": "1.0.0", "lockfileVersion": 1, "requires": true, diff --git a/src/common/cluster-store.ts b/src/common/cluster-store.ts index e408269163..d1ae7294d4 100644 --- a/src/common/cluster-store.ts +++ b/src/common/cluster-store.ts @@ -78,19 +78,17 @@ export interface ClusterPrometheusPreferences { export interface ClusterRenderInfo extends ClusterModel { DeadError?: LoadKubeError; // this != undefined => dead - isAdmin: boolean; name: string; - eventCount: number; online: boolean; } -export class ClusterStore extends BaseStore { +export class LensClusterStoreImpl extends BaseStore { static getCustomKubeConfigPath(clusterId: ClusterId): string { return path.resolve((app || remote.app).getPath("userData"), "kubeconfigs", clusterId); } static embedCustomKubeConfig(clusterId: ClusterId, kubeConfig: KubeConfig | string): string { - const filePath = ClusterStore.getCustomKubeConfigPath(clusterId); + const filePath = LensClusterStoreImpl.getCustomKubeConfigPath(clusterId); const fileContents = typeof kubeConfig == "string" ? kubeConfig : dumpConfigYaml(kubeConfig); saveToAppFiles(filePath, fileContents, { mode: 0o600 }); return filePath; @@ -101,7 +99,7 @@ export class ClusterStore extends BaseStore { @observable clusters = observable.map(); @observable deadClusters = observable.map(); - private constructor() { + protected constructor() { super({ configName: "lens-cluster-store", accessPropertiesByDotNotation: false, // To make dots safe in cluster context names @@ -202,15 +200,13 @@ export class ClusterStore extends BaseStore { return this.deadClusters.get(id); } - getRendererInfoByWorkspace(workspaceId: string): ClusterRenderInfo[] { + protected getRendererInfoByWorkspace(workspaceId: string): ClusterRenderInfo[] { const aliveClusters: ClusterRenderInfo[] = this.clustersList.filter(c => c.workspace === workspaceId); const deadClusters: ClusterRenderInfo[] = this.deadClustersList .filter(([c]) => c.workspace === workspaceId) .map(([cluster, error]) => ({ DeadError: error, name: cluster.contextName, - isAdmin: false, - eventCount: 0, online: false, ...cluster, })); @@ -266,7 +262,7 @@ export class ClusterStore extends BaseStore { this.setActive(null); } // remove only custom kubeconfigs (pasted as text) - if (cluster.kubeConfigPath == ClusterStore.getCustomKubeConfigPath(clusterId)) { + if (cluster.kubeConfigPath == LensClusterStoreImpl.getCustomKubeConfigPath(clusterId)) { unlink(cluster.kubeConfigPath).catch(() => null); } } @@ -352,7 +348,20 @@ export class ClusterStore extends BaseStore { } } +export class LensClusterStore extends LensClusterStoreImpl { + public getRendererInfoByWorkspace(workspaceId: string): ClusterRenderInfo[] { + return super.getRendererInfoByWorkspace(workspaceId); + } +} + +export class ClusterStore extends LensClusterStoreImpl { + private constructor() { + super(); + } +} + export const clusterStore = ClusterStore.getInstance(); +export const lensClusterStore = clusterStore as LensClusterStore; export function getClusterIdFromHost(hostname: string): ClusterId { const subDomains = hostname.split(":")[0].split("."); diff --git a/src/main/tray.ts b/src/main/tray.ts index 3102e5c461..e5ea069a1a 100644 --- a/src/main/tray.ts +++ b/src/main/tray.ts @@ -5,7 +5,7 @@ import { autorun } from "mobx"; import { showAbout } from "./menu"; import { AppUpdater } from "./app-updater"; import { WindowManager } from "./window-manager"; -import { ClusterRenderInfo, clusterStore } from "../common/cluster-store"; +import { ClusterRenderInfo, clusterStore, lensClusterStore } from "../common/cluster-store"; import { Workspace, workspaceStore } from "../common/workspace-store"; import { preferencesURL } from "../renderer/components/+preferences/preferences.route"; import { clusterViewURL } from "../renderer/components/cluster-manager/cluster-view.route"; @@ -82,7 +82,7 @@ export function createTrayMenu(windowManager: WindowManager): Menu { { label: "Clusters", submenu: workspaceStore.enabledWorkspacesList - .map((workspace): [Workspace, ClusterRenderInfo[]] => [workspace, clusterStore.getRendererInfoByWorkspace(workspace.id)]) + .map((workspace): [Workspace, ClusterRenderInfo[]] => [workspace, lensClusterStore.getRendererInfoByWorkspace(workspace.id)]) .filter(([, clusters]) => clusters.length > 0) .map(([workspace, clusters]): MenuItemConstructorOptions => ({ label: workspace.name, diff --git a/src/renderer/components/cluster-manager/clusters-menu.tsx b/src/renderer/components/cluster-manager/clusters-menu.tsx index 1f37de3d2d..729739e9be 100644 --- a/src/renderer/components/cluster-manager/clusters-menu.tsx +++ b/src/renderer/components/cluster-manager/clusters-menu.tsx @@ -8,7 +8,7 @@ import { observer } from "mobx-react"; import { _i18n } from "../../i18n"; import { t, Trans } from "@lingui/macro"; import { userStore } from "../../../common/user-store"; -import { ClusterId, ClusterRenderInfo, clusterStore } from "../../../common/cluster-store"; +import { ClusterId, ClusterRenderInfo, clusterStore, lensClusterStore } from "../../../common/cluster-store"; import { workspaceStore } from "../../../common/workspace-store"; import { ClusterIcon } from "../cluster-icon"; import { Icon } from "../icon"; @@ -105,7 +105,7 @@ export class ClusterMenu extends React.Component { const { className } = this.props; const { newContexts } = userStore; const workspace = workspaceStore.getById(workspaceStore.currentWorkspaceId); - const clusters = clusterStore.getRendererInfoByWorkspace(workspace.id); + const clusters = lensClusterStore.getRendererInfoByWorkspace(workspace.id); const activeClusterId = clusterStore.activeCluster; return (