Extension {displayName} successfully uninstalled!
); this.extensionStateStore.extensionState.delete(id); }); this.addedInstalling.forEach(({ id, displayName }) => { const extension = this.extensions.find(extension => extension.id === id); if (!extension) { throw new Error("Extension not found"); } Notifications.ok(Extension {displayName} successfully installed!
); this.extensionStateStore.extensionState.delete(id); this.installPath = ""; // Enable installed extensions by default. extension.isEnabled = true; }); }) ); } @computed get extensions() { const searchText = this.search.toLowerCase(); return Array.from(extensionLoader.userExtensions.values()) .filter(({ manifest: { name, description }}) => ( name.toLowerCase().includes(searchText) || description?.toLowerCase().includes(searchText) )); } get extensionsPath() { return extensionDiscovery.localFolderPath; } getExtensionPackageTemp(fileName = "") { return path.join(os.tmpdir(), "lens-extensions", fileName); } getExtensionDestFolder(name: string) { return path.join(this.extensionsPath, sanitizeExtensionName(name)); } installFromSelectFileDialog = async () => { const { dialog, BrowserWindow, app } = remote; const { canceled, filePaths } = await dialog.showOpenDialog(BrowserWindow.getFocusedWindow(), { defaultPath: app.getPath("downloads"), properties: ["openFile", "multiSelections"], message: _i18n._(t`Select extensions to install (formats: ${Extensions.supportedFormats.join(", ")}), `), buttonLabel: _i18n._(t`Use configuration`), filters: [ { name: "tarball", extensions: Extensions.supportedFormats } ] }); if (!canceled && filePaths.length) { this.requestInstall( filePaths.map(filePath => ({ fileName: path.basename(filePath), filePath, })) ); } }; installFromUrlOrPath = async () => { const { installPath } = this; if (!installPath) return; this.startingInstall = true; const fileName = path.basename(installPath); try { // install via url // fixme: improve error messages for non-tar-file URLs if (InputValidators.isUrl.validate(installPath)) { const { promise: filePromise } = downloadFile({ url: installPath, timeout: 60000 /*1m*/ }); const data = await filePromise; await this.requestInstall({ fileName, data }); } // otherwise installing from system path else if (InputValidators.isPath.validate(installPath)) { await this.requestInstall({ fileName, filePath: installPath }); } } catch (error) { this.startingInstall = false; Notifications.error(Installation has failed: {String(error)}
); } }; installOnDrop = (files: File[]) => { logger.info("Install from D&D"); return this.requestInstall( files.map(file => ({ fileName: path.basename(file.path), filePath: file.path, })) ); }; async preloadExtensions(requests: InstallRequest[], { showError = true } = {}) { const preloadedRequests = requests.filter(request => request.data); await Promise.all( requests .filter(request => !request.data && request.filePath) .map(async request => { try { const data = await fse.readFile(request.filePath); request.data = data; preloadedRequests.push(request); return request; } catch(error) { if (showError) { Notifications.error(`Error while reading "${request.filePath}": ${String(error)}`); } } }) ); return preloadedRequests as InstallRequestPreloaded[]; } async validatePackage(filePath: string): PromiseInstalling {req.fileName} has failed, skipping.
Reason: {String(error)}
Install extension {name}@{version}?
Description: {description}
{extensionFolder} will be removed before installation.
Installing extension {displayName} has failed: {error}
); // Remove install state on install failure if (this.extensionStateStore.extensionState.get(extensionId)?.state === "installing") { this.extensionStateStore.extensionState.delete(extensionId); } } finally { // clean up fse.remove(unpackingTempFolder).catch(Function); fse.unlink(tempFile).catch(Function); } } confirmUninstallExtension = (extension: InstalledExtension) => { const displayName = extensionDisplayName(extension.manifest.name, extension.manifest.version); ConfirmDialog.open({ message:Are you sure you want to uninstall extension {displayName}?
, labelOk:Uninstalling extension {displayName} has failed: {error?.message ?? ""}
); // Remove uninstall state on uninstall failure if (this.extensionStateStore.extensionState.get(extension.id)?.state === "uninstalling") { this.extensionStateStore.extensionState.delete(extension.id); } } } renderExtensions() { const { extensions, search } = this; if (!extensions.length) { return (No search results found
:There are no installed extensions. See list of available extensions.
}