1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fetching hosted cluster inside Command Palette

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-03-03 10:50:50 +03:00
parent 97a88eb2b8
commit e88e500722

View File

@ -8,9 +8,8 @@ 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 { clusterStore } from "../../../common/cluster-store";
import { clusterStore, getHostedCluster } from "../../../common/cluster-store";
import { workspaceStore } from "../../../common/workspace-store";
import { Cluster } from "../../../main/cluster";
export type CommandDialogEvent = {
component: React.ReactElement
@ -29,8 +28,9 @@ export class CommandOverlay {
}
@observer
export class CommandContainer extends React.Component<{cluster?: Cluster}> {
export class CommandContainer extends React.Component {
@observable.ref commandComponent: React.ReactElement;
@observable cluster = getHostedCluster();
private escHandler(event: KeyboardEvent) {
if (event.key === "Escape") {
@ -56,8 +56,8 @@ export class CommandContainer extends React.Component<{cluster?: Cluster}> {
}
componentDidMount() {
if (this.props.cluster) {
subscribeToBroadcast(`command-palette:run-action:${this.props.cluster.id}`, (event, commandId: string) => {
if (this.cluster) {
subscribeToBroadcast(`command-palette:run-action:${this.cluster.id}`, (event, commandId: string) => {
const command = this.findCommandById(commandId);
if (command) {