mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Enable extension to specify storeName for persisting data
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
parent
65175377d0
commit
4849f62141
@ -92,6 +92,6 @@ export abstract class ExtensionStore<T extends object> extends BaseStore<T> {
|
|||||||
protected cwd() {
|
protected cwd() {
|
||||||
assert(this.extension, "must call this.load() first");
|
assert(this.extension, "must call this.load() first");
|
||||||
|
|
||||||
return path.join(super.cwd(), "extension-store", this.extension.name);
|
return path.join(super.cwd(), "extension-store", this.extension.storeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,10 @@ export interface LensExtensionManifest extends PackageJson {
|
|||||||
npm?: string;
|
npm?: string;
|
||||||
node?: string;
|
node?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Specify extension name used for persisting data.
|
||||||
|
// Useful if extension is renamed but the data should not be lost.
|
||||||
|
storeName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const lensExtensionDependencies = Symbol("lens-extension-dependencies");
|
export const lensExtensionDependencies = Symbol("lens-extension-dependencies");
|
||||||
@ -62,7 +66,10 @@ export class LensExtension<
|
|||||||
|
|
||||||
constructor({ id, manifest, manifestPath, isBundled }: InstalledExtension) {
|
constructor({ id, manifest, manifestPath, isBundled }: InstalledExtension) {
|
||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
|
|
||||||
|
// id is the name of the manifest
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
this.manifest = manifest;
|
this.manifest = manifest;
|
||||||
this.manifestPath = manifestPath;
|
this.manifestPath = manifestPath;
|
||||||
this.isBundled = !!isBundled;
|
this.isBundled = !!isBundled;
|
||||||
@ -80,6 +87,11 @@ export class LensExtension<
|
|||||||
return this.manifest.description;
|
return this.manifest.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name of extension for persisting data
|
||||||
|
get storeName() {
|
||||||
|
return this.manifest.storeName || this.name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
@ -93,7 +105,8 @@ export class LensExtension<
|
|||||||
* folder name.
|
* folder name.
|
||||||
*/
|
*/
|
||||||
async getExtensionFileFolder(): Promise<string> {
|
async getExtensionFileFolder(): Promise<string> {
|
||||||
return this[lensExtensionDependencies].fileSystemProvisionerStore.requestDirectory(this.id);
|
// storeName is read from the manifest and has a fallback to the manifest name, which equals id
|
||||||
|
return this[lensExtensionDependencies].fileSystemProvisionerStore.requestDirectory(this.storeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user