mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
UI for enabling/disabling extensions (#1208)
* Extensions page and menu item Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Basic extension list view Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Adding get userExtensions filter Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Using WizardLayout at extension page Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Adding search to extension page Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Few style fixes Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * clean up Signed-off-by: Roman <ixrock@gmail.com> * added folder-icon to open extensions in finder, refactoring Signed-off-by: Roman <ixrock@gmail.com> * remove export warnings in dev:main, tooltip.getPosition() fix Signed-off-by: Roman <ixrock@gmail.com> * refactoring base lens-extension.ts, added `isBundled` flag Signed-off-by: Roman <ixrock@gmail.com> * added enabled/disable buttons Signed-off-by: Roman <ixrock@gmail.com> * auto enable/disable extensions -- part 1 Signed-off-by: Roman <ixrock@gmail.com> * auto enable/disable extensions -- part 2 Signed-off-by: Roman <ixrock@gmail.com> * auto enable/disable extensions -- part 3 Signed-off-by: Roman <ixrock@gmail.com> * auto enable/disable extensions -- part 4 Signed-off-by: Roman <ixrock@gmail.com> * refactoring & fixes Signed-off-by: Roman <ixrock@gmail.com> * fix: use page-layout with fullsize viewport Signed-off-by: Roman <ixrock@gmail.com> Co-authored-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
1 parent
d5214e47c1
commit
f9578ba407
17 files changed
+376
-191
No files matched your search
@@ -2,7 +2,7 @@ import path from "path"
|
||||
import Config from "conf"
|
||||
import { Options as ConfOptions } from "conf/dist/source/types"
|
||||
import { app, ipcMain, IpcMainEvent, ipcRenderer, IpcRendererEvent, remote } from "electron"
|
||||
import { action, observable, reaction, runInAction, toJS, when } from "mobx";
|
||||
import { action, IReactionOptions, observable, reaction, runInAction, toJS, when } from "mobx";
|
||||
import Singleton from "./utils/singleton";
|
||||
import { getAppVersion } from "./utils/app-version";
|
||||
import logger from "../main/logger";
|
||||
@@ -12,6 +12,7 @@ import isEqual from "lodash/isEqual";
|
||||
export interface BaseStoreParams<T = any> extends ConfOptions<T> {
|
||||
autoLoad?: boolean;
|
||||
syncEnabled?: boolean;
|
||||
syncOptions?: IReactionOptions;
|
||||
}
|
||||
|
||||
export class BaseStore<T = any> extends Singleton {
|
||||
@@ -20,7 +21,7 @@ export class BaseStore<T = any> extends Singleton {
|
||||
|
||||
whenLoaded = when(() => this.isLoaded);
|
||||
@observable isLoaded = false;
|
||||
@observable protected data: T;
|
||||
@observable data = {} as T;
|
||||
|
||||
protected constructor(protected params: BaseStoreParams) {
|
||||
super();
|
||||
@@ -36,8 +37,12 @@ export class BaseStore<T = any> extends Singleton {
|
||||
return path.basename(this.storeConfig.path);
|
||||
}
|
||||
|
||||
get path() {
|
||||
return this.storeConfig.path;
|
||||
}
|
||||
|
||||
get syncChannel() {
|
||||
return `store-sync:${this.name}`
|
||||
return `STORE-SYNC:${this.path}`
|
||||
}
|
||||
|
||||
protected async init() {
|
||||
@@ -56,19 +61,19 @@ export class BaseStore<T = any> extends Singleton {
|
||||
...confOptions,
|
||||
projectName: "lens",
|
||||
projectVersion: getAppVersion(),
|
||||
cwd: this.storePath(),
|
||||
cwd: this.cwd(),
|
||||
});
|
||||
logger.info(`[STORE]: LOADED from ${this.storeConfig.path}`);
|
||||
logger.info(`[STORE]: LOADED from ${this.path}`);
|
||||
this.fromStore(this.storeConfig.store);
|
||||
this.isLoaded = true;
|
||||
}
|
||||
|
||||
protected storePath() {
|
||||
protected cwd() {
|
||||
return (app || remote.app).getPath("userData")
|
||||
}
|
||||
|
||||
protected async saveToFile(model: T) {
|
||||
logger.info(`[STORE]: SAVING ${this.name}`);
|
||||
logger.info(`[STORE]: SAVING ${this.path}`);
|
||||
// todo: update when fixed https://github.com/sindresorhus/conf/issues/114
|
||||
Object.entries(model).forEach(([key, value]) => {
|
||||
this.storeConfig.set(key, value);
|
||||
@@ -77,7 +82,7 @@ export class BaseStore<T = any> extends Singleton {
|
||||
|
||||
enableSync() {
|
||||
this.syncDisposers.push(
|
||||
reaction(() => this.toJSON(), model => this.onModelChange(model)),
|
||||
reaction(() => this.toJSON(), model => this.onModelChange(model), this.params.syncOptions),
|
||||
);
|
||||
if (ipcMain) {
|
||||
const callback = (event: IpcMainEvent, model: T) => {
|
||||
@@ -169,6 +174,7 @@ export class BaseStore<T = any> extends Singleton {
|
||||
|
||||
@action
|
||||
protected fromStore(data: T) {
|
||||
if (!data) return;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user