mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix circular dependency. Fix waiting for instance enabled.
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
parent
28b49cc8f2
commit
7052475703
@ -301,8 +301,18 @@ export class ExtensionLoader {
|
|||||||
return this.extensions.get(extId);
|
return this.extensions.get(extId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async instanceToBeEnabled(extId: LensExtensionId): Promise<void> {
|
public async waitForEnabled(name: string): Promise<void> {
|
||||||
return when(() => this.instances.get(extId)?.isEnabled);
|
return when(() => {
|
||||||
|
for (const instanceEntry of this.instances) {
|
||||||
|
const [, extension ] = instanceEntry;
|
||||||
|
|
||||||
|
if (extension.manifest.name === name) {
|
||||||
|
return extension.isEnabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -4,8 +4,6 @@ import { match, matchPath } from "react-router";
|
|||||||
import { pathToRegexp } from "path-to-regexp";
|
import { pathToRegexp } from "path-to-regexp";
|
||||||
import { subscribeToBroadcast } from "../../common/ipc";
|
import { subscribeToBroadcast } from "../../common/ipc";
|
||||||
import logger from "../logger";
|
import logger from "../logger";
|
||||||
import { extensionLoader } from "../../extensions/extension-loader";
|
|
||||||
import { sanitizeExtensionName } from "../../extensions/lens-extension";
|
|
||||||
|
|
||||||
export enum RoutingErrorType {
|
export enum RoutingErrorType {
|
||||||
INVALID_PROTOCOL = "invalid-protocol",
|
INVALID_PROTOCOL = "invalid-protocol",
|
||||||
@ -119,13 +117,11 @@ export class LensProtocolRouter extends Singleton {
|
|||||||
|
|
||||||
if (!routes) {
|
if (!routes) {
|
||||||
if (this.missingExtensionHandler) {
|
if (this.missingExtensionHandler) {
|
||||||
const enabledPromise = extensionLoader.instanceToBeEnabled(sanitizeExtensionName(name));
|
|
||||||
|
|
||||||
if (!await this.missingExtensionHandler(name)) {
|
if (!await this.missingExtensionHandler(name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await enabledPromise;
|
|
||||||
routes = this.extentionRoutes.get(name);
|
routes = this.extentionRoutes.get(name);
|
||||||
|
|
||||||
if (!routes) {
|
if (!routes) {
|
||||||
|
|||||||
@ -21,7 +21,6 @@ import protocolEndpoints from "./api/protocol-endpoints";
|
|||||||
import { LensProtocolRouter } from "../main/protocol-handler";
|
import { LensProtocolRouter } from "../main/protocol-handler";
|
||||||
import logger from "../main/logger";
|
import logger from "../main/logger";
|
||||||
import { installFromNpm } from "./components/+extensions";
|
import { installFromNpm } from "./components/+extensions";
|
||||||
|
|
||||||
type AppComponent = React.ComponentType & {
|
type AppComponent = React.ComponentType & {
|
||||||
init?(): Promise<void>;
|
init?(): Promise<void>;
|
||||||
};
|
};
|
||||||
@ -47,7 +46,9 @@ export async function bootstrap(App: AppComponent) {
|
|||||||
if (!extensionLoader.isInstalled(name)) {
|
if (!extensionLoader.isInstalled(name)) {
|
||||||
logger.info(`[PROTOCOL ROUTER]: Extension ${name} not installed, installing..`);
|
logger.info(`[PROTOCOL ROUTER]: Extension ${name} not installed, installing..`);
|
||||||
|
|
||||||
await installFromNpm(name);
|
await Promise.all([installFromNpm(name), extensionLoader.waitForEnabled(name)]);
|
||||||
|
|
||||||
|
logger.info(`[PROTOCOL ROUTER]: Extension ${name} installed and enabled.`);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user