mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Review fixes
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
8c8ada45c0
commit
59124e351b
@ -91,23 +91,15 @@ export class App extends React.Component {
|
|||||||
reaction(() => this.warningsTotal, (count: number) => {
|
reaction(() => this.warningsTotal, (count: number) => {
|
||||||
broadcastMessage(`cluster-warning-event-count:${getHostedCluster().id}`, count);
|
broadcastMessage(`cluster-warning-event-count:${getHostedCluster().id}`, count);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
reaction(getHostedCluster, () => {
|
|
||||||
this.setStartUrl();
|
|
||||||
})
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@observable startUrl: string = clusterURL();
|
@observable startUrl = isAllowedResource(["events", "nodes", "pods"]) ? clusterURL() : workloadsURL();
|
||||||
|
|
||||||
@computed get warningsTotal(): number {
|
@computed get warningsTotal(): number {
|
||||||
return nodesStore.getWarningsCount() + eventStore.getWarningsCount();
|
return nodesStore.getWarningsCount() + eventStore.getWarningsCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
setStartUrl() {
|
|
||||||
this.startUrl = isAllowedResource(["events", "nodes", "pods"]) ? clusterURL() : workloadsURL();
|
|
||||||
}
|
|
||||||
|
|
||||||
getTabLayoutRoutes(menuItem: ClusterPageMenuRegistration) {
|
getTabLayoutRoutes(menuItem: ClusterPageMenuRegistration) {
|
||||||
const routes: TabLayoutRoute[] = [];
|
const routes: TabLayoutRoute[] = [];
|
||||||
|
|
||||||
@ -190,7 +182,7 @@ export class App extends React.Component {
|
|||||||
<StatefulSetScaleDialog/>
|
<StatefulSetScaleDialog/>
|
||||||
<ReplicaSetScaleDialog/>
|
<ReplicaSetScaleDialog/>
|
||||||
<CronJobTriggerDialog/>
|
<CronJobTriggerDialog/>
|
||||||
<CommandContainer/>
|
<CommandContainer clusterId={getHostedCluster()?.id}/>
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
</Router>
|
</Router>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { EventEmitter } from "../../../common/event-emitter";
|
|||||||
import { subscribeToBroadcast } from "../../../common/ipc";
|
import { subscribeToBroadcast } from "../../../common/ipc";
|
||||||
import { CommandDialog } from "./command-dialog";
|
import { CommandDialog } from "./command-dialog";
|
||||||
import { CommandRegistration, commandRegistry } from "../../../extensions/registries/command-registry";
|
import { CommandRegistration, commandRegistry } from "../../../extensions/registries/command-registry";
|
||||||
import { clusterStore, getHostedCluster } from "../../../common/cluster-store";
|
import { clusterStore } from "../../../common/cluster-store";
|
||||||
import { workspaceStore } from "../../../common/workspace-store";
|
import { workspaceStore } from "../../../common/workspace-store";
|
||||||
|
|
||||||
export type CommandDialogEvent = {
|
export type CommandDialogEvent = {
|
||||||
@ -28,9 +28,8 @@ export class CommandOverlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class CommandContainer extends React.Component {
|
export class CommandContainer extends React.Component<{ clusterId?: string }> {
|
||||||
@observable.ref commandComponent: React.ReactElement;
|
@observable.ref commandComponent: React.ReactElement;
|
||||||
@observable cluster = getHostedCluster();
|
|
||||||
|
|
||||||
private escHandler(event: KeyboardEvent) {
|
private escHandler(event: KeyboardEvent) {
|
||||||
if (event.key === "Escape") {
|
if (event.key === "Escape") {
|
||||||
@ -56,8 +55,8 @@ export class CommandContainer extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
if (this.cluster) {
|
if (this.props.clusterId) {
|
||||||
subscribeToBroadcast(`command-palette:run-action:${this.cluster.id}`, (event, commandId: string) => {
|
subscribeToBroadcast(`command-palette:run-action:${this.props.clusterId}`, (event, commandId: string) => {
|
||||||
const command = this.findCommandById(commandId);
|
const command = this.findCommandById(commandId);
|
||||||
|
|
||||||
if (command) {
|
if (command) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user