mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Report enabled extensions (#1451)
* Report enabled extensions Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com> * Add missing semicolons Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com> * Refactoring Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com> * Add missing semicolon Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
1 parent
19150fca84
commit
0a5e7a048d
4 files changed
+44
-3
No files matched your search
@@ -1,4 +1,8 @@
|
||||
import { getAppVersion } from "../../common/utils";
|
||||
import { extensionsStore } from "../extensions-store";
|
||||
|
||||
export const version = getAppVersion();
|
||||
export { isSnap, isWindows, isMac, isLinux, appName, slackUrl, issuesTrackerUrl } from "../../common/vars";
|
||||
export { isSnap, isWindows, isMac, isLinux, appName, slackUrl, issuesTrackerUrl } from "../../common/vars";
|
||||
export function getEnabledExtensions(): string[] {
|
||||
return extensionsStore.enabledExtensions;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { LensExtensionId } from "./lens-extension";
|
||||
import type { ExtensionLoader } from "./extension-loader";
|
||||
import { BaseStore } from "../common/base-store";
|
||||
import { action, observable, reaction, toJS } from "mobx";
|
||||
import { action, computed, observable, reaction, toJS } from "mobx";
|
||||
|
||||
export interface LensExtensionsStoreModel {
|
||||
extensions: Record<LensExtensionId, LensExtensionState>;
|
||||
@@ -9,6 +9,7 @@ export interface LensExtensionsStoreModel {
|
||||
|
||||
export interface LensExtensionState {
|
||||
enabled?: boolean;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export class ExtensionsStore extends BaseStore<LensExtensionsStoreModel> {
|
||||
@@ -18,6 +19,17 @@ export class ExtensionsStore extends BaseStore<LensExtensionsStoreModel> {
|
||||
});
|
||||
}
|
||||
|
||||
@computed
|
||||
get enabledExtensions() {
|
||||
const extensions: string[] = [];
|
||||
this.state.forEach((state, id) => {
|
||||
if (state.enabled) {
|
||||
extensions.push(state.name);
|
||||
}
|
||||
});
|
||||
return extensions;
|
||||
}
|
||||
|
||||
protected state = observable.map<LensExtensionId, LensExtensionState>();
|
||||
|
||||
protected getState(extensionLoader: ExtensionLoader) {
|
||||
@@ -25,6 +37,7 @@ export class ExtensionsStore extends BaseStore<LensExtensionsStoreModel> {
|
||||
return Array.from(extensionLoader.userExtensions).reduce((state, [extId, ext]) => {
|
||||
state[extId] = {
|
||||
enabled: ext.isEnabled,
|
||||
name: ext.manifest.name,
|
||||
};
|
||||
return state;
|
||||
}, state);
|
||||
|
||||
Reference in new issue
Block a user