mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
add waiting for extension to be enabled
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
b6a17eb1be
commit
28b49cc8f2
@ -301,6 +301,10 @@ export class ExtensionLoader {
|
||||
return this.extensions.get(extId);
|
||||
}
|
||||
|
||||
public async instanceToBeEnabled(extId: LensExtensionId): Promise<void> {
|
||||
return when(() => this.instances.get(extId)?.isEnabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get url to the tarball of the extension package. Assumes package is found from npm regisry.
|
||||
* @param packageName e.g. "@mirantis/lens-extension-cc"
|
||||
|
||||
@ -22,7 +22,7 @@ export class LensExtension {
|
||||
readonly manifestPath: string;
|
||||
readonly isBundled: boolean;
|
||||
|
||||
@observable private isEnabled = false;
|
||||
@observable isEnabled = false;
|
||||
|
||||
constructor({ id, manifest, manifestPath, isBundled }: InstalledExtension) {
|
||||
this.id = id;
|
||||
|
||||
@ -4,6 +4,8 @@ import { match, matchPath } from "react-router";
|
||||
import { pathToRegexp } from "path-to-regexp";
|
||||
import { subscribeToBroadcast } from "../../common/ipc";
|
||||
import logger from "../logger";
|
||||
import { extensionLoader } from "../../extensions/extension-loader";
|
||||
import { sanitizeExtensionName } from "../../extensions/lens-extension";
|
||||
|
||||
export enum RoutingErrorType {
|
||||
INVALID_PROTOCOL = "invalid-protocol",
|
||||
@ -117,10 +119,13 @@ export class LensProtocolRouter extends Singleton {
|
||||
|
||||
if (!routes) {
|
||||
if (this.missingExtensionHandler) {
|
||||
const enabledPromise = extensionLoader.instanceToBeEnabled(sanitizeExtensionName(name));
|
||||
|
||||
if (!await this.missingExtensionHandler(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
await enabledPromise;
|
||||
routes = this.extentionRoutes.get(name);
|
||||
|
||||
if (!routes) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user