mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Explicitly initialize registries
- Helps moves towards turning on banning CyclicImports Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
c18df6bcae
commit
6d10f011e5
101 files changed
+1178
-1087
No files matched your search
@@ -28,9 +28,9 @@ import { Dialog } from "../dialog";
|
||||
import { EventEmitter } from "../../../common/event-emitter";
|
||||
import { subscribeToBroadcast } from "../../../common/ipc";
|
||||
import { CommandDialog } from "./command-dialog";
|
||||
import { CommandRegistration, commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
import type { ClusterId } from "../../../common/cluster-store";
|
||||
import { catalogEntityRegistry } from "../../api/catalog-entity-registry";
|
||||
import { CommandRegistration, CommandRegistry } from "../../../extensions/registries/command-registry";
|
||||
|
||||
export type CommandDialogEvent = {
|
||||
component: React.ReactElement
|
||||
@@ -74,7 +74,7 @@ export class CommandContainer extends React.Component<CommandContainerProps> {
|
||||
}
|
||||
|
||||
private findCommandById(commandId: string) {
|
||||
return commandRegistry.getItems().find((command) => command.id === commandId);
|
||||
return CommandRegistry.getInstance().getItems().find((command) => command.id === commandId);
|
||||
}
|
||||
|
||||
private runCommand(command: CommandRegistration) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import { Select } from "../select";
|
||||
import { computed, makeObservable, observable } from "mobx";
|
||||
import { observer } from "mobx-react";
|
||||
import React from "react";
|
||||
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
import { CommandRegistry } from "../../../extensions/registries/command-registry";
|
||||
import { CommandOverlay } from "./command-container";
|
||||
import { broadcastMessage } from "../../../common/ipc";
|
||||
import { navigate } from "../../navigation";
|
||||
@@ -46,33 +46,35 @@ export class CommandDialog extends React.Component {
|
||||
}
|
||||
|
||||
@computed get options() {
|
||||
const registry = CommandRegistry.getInstance();
|
||||
|
||||
const context = {
|
||||
entity: this.activeEntity
|
||||
};
|
||||
|
||||
return commandRegistry.getItems().filter((command) => {
|
||||
return registry.getItems().filter((command) => {
|
||||
if (command.scope === "entity" && !this.activeEntity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!command.isActive) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
return command.isActive(context);
|
||||
return command.isActive?.(context) ?? true;
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
|
||||
return false;
|
||||
}
|
||||
}).map((command) => {
|
||||
return { value: command.id, label: command.title };
|
||||
}).sort((a, b) => a.label > b.label ? 1 : -1);
|
||||
|
||||
return false;
|
||||
})
|
||||
.map((command) => ({
|
||||
value: command.id,
|
||||
label: command.title,
|
||||
}))
|
||||
.sort((a, b) => a.label > b.label ? 1 : -1);
|
||||
}
|
||||
|
||||
private onChange(value: string) {
|
||||
const command = commandRegistry.getItems().find((cmd) => cmd.id === value);
|
||||
const registry = CommandRegistry.getInstance();
|
||||
const command = registry.getItems().find((cmd) => cmd.id === value);
|
||||
|
||||
if (!command) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user