Disable Uninstall and Enable/Disable buttons while uninstalling. Add Notification for uninstall. (#1539)

Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
Panu Horsmalahti authored and GitHub committed 2020-11-27 10:23:12 +02:00
1 parent d9faba9444
commit 263d56b3c1
12 files changed
+126 -29

No files matched your search

@@ -18,6 +18,7 @@ jest.mock(
name: "TestExtension",
version: "1.0.0",
},
id: manifestPath,
absolutePath: "/test/1",
manifestPath,
isBundled: false,
@@ -31,6 +32,7 @@ jest.mock(
name: "TestExtension2",
version: "2.0.0",
},
id: manifestPath2,
absolutePath: "/test/2",
manifestPath: manifestPath2,
isBundled: false,
@@ -54,6 +56,7 @@ jest.mock(
name: "TestExtension",
version: "1.0.0",
},
id: manifestPath,
absolutePath: "/test/1",
manifestPath,
isBundled: false,
@@ -67,6 +70,7 @@ jest.mock(
name: "TestExtension3",
version: "3.0.0",
},
id: manifestPath3,
absolutePath: "/test/3",
manifestPath: manifestPath3,
isBundled: false,
@@ -99,6 +103,7 @@ describe("ExtensionLoader", () => {
Map {
"manifest/path" => Object {
"absolutePath": "/test/1",
"id": "manifest/path",
"isBundled": false,
"isEnabled": true,
"manifest": Object {
@@ -109,6 +114,7 @@ describe("ExtensionLoader", () => {
},
"manifest/path3" => Object {
"absolutePath": "/test/3",
"id": "manifest/path3",
"isBundled": false,
"isEnabled": true,
"manifest": Object {
@@ -9,6 +9,7 @@ describe("lens extension", () => {
name: "foo-bar",
version: "0.1.1"
},
id: "/this/is/fake/package.json",
absolutePath: "/absolute/fake/",
manifestPath: "/this/is/fake/package.json",
isBundled: false,
+4 -1
View File
@@ -10,6 +10,8 @@ import { extensionsStore } from "./extensions-store";
import type { LensExtensionId, LensExtensionManifest } from "./lens-extension";
export interface InstalledExtension {
id: LensExtensionId;
readonly manifest: LensExtensionManifest;
// Absolute path to the non-symlinked source folder,
@@ -254,6 +256,7 @@ export class ExtensionDiscovery {
const isEnabled = isBundled || extensionsStore.isEnabled(installedManifestPath);
return {
id: installedManifestPath,
absolutePath: path.dirname(manifestPath),
manifestPath: installedManifestPath,
manifest: manifestJson,
@@ -273,7 +276,7 @@ export class ExtensionDiscovery {
await this.installPackages();
const extensions = bundledExtensions.concat(localExtensions);
return new Map(extensions.map(ext => [ext.manifestPath, ext]));
return new Map(extensions.map(extension => [extension.id, extension]));
}
/**
+4 -5
View File
@@ -61,7 +61,7 @@ export class ExtensionLoader {
}
addExtension(extension: InstalledExtension) {
this.extensions.set(extension.manifestPath as LensExtensionId, extension);
this.extensions.set(extension.id, extension);
}
removeInstance(lensExtensionId: LensExtensionId) {
@@ -139,8 +139,7 @@ export class ExtensionLoader {
];
this.events.on("remove", (removedExtension: LensRendererExtension) => {
// manifestPath is considered the id
if (removedExtension.manifestPath === extension.manifestPath) {
if (removedExtension.id === extension.id) {
removeItems.forEach(remove => {
remove();
});
@@ -163,7 +162,7 @@ export class ExtensionLoader {
];
this.events.on("remove", (removedExtension: LensRendererExtension) => {
if (removedExtension.manifestPath === extension.manifestPath) {
if (removedExtension.id === extension.id) {
removeItems.forEach(remove => {
remove();
});
@@ -191,7 +190,7 @@ export class ExtensionLoader {
];
this.events.on("remove", (removedExtension: LensRendererExtension) => {
if (removedExtension.manifestPath === extension.manifestPath) {
if (removedExtension.id === extension.id) {
removeItems.forEach(remove => {
remove();
});
+3 -6
View File
@@ -16,23 +16,20 @@ export interface LensExtensionManifest {
}
export class LensExtension {
readonly id: LensExtensionId;
readonly manifest: LensExtensionManifest;
readonly manifestPath: string;
readonly isBundled: boolean;
@observable private isEnabled = false;
constructor({ manifest, manifestPath, isBundled }: InstalledExtension) {
constructor({ id, manifest, manifestPath, isBundled }: InstalledExtension) {
this.id = id;
this.manifest = manifest;
this.manifestPath = manifestPath;
this.isBundled = !!isBundled;
}
get id(): LensExtensionId {
// This is the symlinked path under node_modules
return this.manifestPath;
}
get name() {
return this.manifest.name;
}
@@ -11,6 +11,7 @@ describe("getPageUrl", () => {
name: "foo-bar",
version: "0.1.1"
},
id: "/this/is/fake/package.json",
absolutePath: "/absolute/fake/",
manifestPath: "/this/is/fake/package.json",
isBundled: false,
@@ -42,6 +43,7 @@ describe("globalPageRegistry", () => {
name: "@acme/foo-bar",
version: "0.1.1"
},
id: "/this/is/fake/package.json",
absolutePath: "/absolute/fake/",
manifestPath: "/this/is/fake/package.json",
isBundled: false,