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 (#7107)
* Enable extension to specify storeName for persisting data Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com> * Add unit tests and update injectables Signed-off-by: Antti Lustila <antti.lustila@luotocompany.fi> * Remove unnecessary mock Signed-off-by: Antti Lustila <antti.lustila@luotocompany.fi> --------- Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com> Signed-off-by: Antti Lustila <antti.lustila@luotocompany.fi> Co-authored-by: Antti Lustila <antti.lustila@luotocompany.fi>
This commit is contained in:
1 parent
15ba5da51e
commit
3f0de0550e
7 files changed
+182
-29
No files matched your search
@@ -27,6 +27,10 @@ export interface LensExtensionManifest extends PackageJson {
|
||||
npm?: 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");
|
||||
@@ -62,7 +66,10 @@ export class LensExtension<
|
||||
|
||||
constructor({ id, manifest, manifestPath, isBundled }: InstalledExtension) {
|
||||
makeObservable(this);
|
||||
|
||||
// id is the name of the manifest
|
||||
this.id = id;
|
||||
|
||||
this.manifest = manifest;
|
||||
this.manifestPath = manifestPath;
|
||||
this.isBundled = !!isBundled;
|
||||
@@ -80,6 +87,11 @@ export class LensExtension<
|
||||
return this.manifest.description;
|
||||
}
|
||||
|
||||
// Name of extension for persisting data
|
||||
get storeName() {
|
||||
return this.manifest.storeName || this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
@@ -93,7 +105,8 @@ export class LensExtension<
|
||||
* folder name.
|
||||
*/
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user