From 2b4e85397c2fd7b46add27204e859b079412a42e Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Fri, 30 Oct 2020 10:22:30 +0300 Subject: [PATCH] Adding get userExtensions filter Signed-off-by: Alex Andreev --- src/extensions/extension-loader.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/extensions/extension-loader.ts b/src/extensions/extension-loader.ts index c0b2d5ada6..2662b05b18 100644 --- a/src/extensions/extension-loader.ts +++ b/src/extensions/extension-loader.ts @@ -3,10 +3,11 @@ import type { LensMainExtension } from "./lens-main-extension" import type { LensRendererExtension } from "./lens-renderer-extension" import path from "path" import { broadcastIpc } from "../common/ipc" -import { observable, reaction, toJS, } from "mobx" +import { computed, observable, reaction, toJS, } from "mobx" import logger from "../main/logger" import { app, ipcRenderer, remote } from "electron" import { appPreferenceRegistry, clusterFeatureRegistry, clusterPageRegistry, globalPageRegistry, kubeObjectMenuRegistry, menuRegistry, statusBarRegistry } from "./registries"; +import { getBundledExtensions } from "../common/utils" export interface InstalledExtension extends ExtensionModel { manifestPath: string; @@ -34,6 +35,16 @@ export class ExtensionLoader { } } + @computed get userExtensions() { + const builtIn = getBundledExtensions().map(ext => `lens-${ext}`) + const extensions: LensExtension[] = [] + this.instances.forEach(instance => { + if (builtIn.includes(instance.name)) return + extensions.push(instance) + }) + return extensions + } + loadOnMain() { logger.info('[EXTENSIONS-LOADER]: load on main') this.autoloadExtensions((extension: LensMainExtension) => {