mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
add more commands
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
c1a3f6f280
commit
60f6af4a0a
@ -13,6 +13,9 @@ export * from "../../renderer/components/select";
|
||||
export * from "../../renderer/components/slider";
|
||||
export * from "../../renderer/components/input/input";
|
||||
|
||||
// command-overlay
|
||||
export { CommandOverlay } from "../../renderer/components/command-palette";
|
||||
|
||||
// other components
|
||||
export * from "../../renderer/components/icon";
|
||||
export * from "../../renderer/components/tooltip";
|
||||
|
||||
18
src/renderer/components/+apps/apps.command.ts
Normal file
18
src/renderer/components/+apps/apps.command.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { navigate } from "../../navigation";
|
||||
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
import { helmChartsURL } from "../+apps-helm-charts";
|
||||
import { releaseURL } from "../+apps-releases";
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewHelmCharts",
|
||||
title: "Cluster: View Helm Charts",
|
||||
scope: "cluster",
|
||||
action: () => navigate(helmChartsURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewHelmReleases",
|
||||
title: "Cluster: View Helm Releases",
|
||||
scope: "cluster",
|
||||
action: () => navigate(releaseURL())
|
||||
});
|
||||
@ -1,2 +1,3 @@
|
||||
export * from "./apps";
|
||||
export * from "./apps.route";
|
||||
export * from "./apps.route";
|
||||
export * from "./apps.command";
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
import { navigate } from "../../navigation";
|
||||
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
import { clusterSettingsURL } from "./cluster-settings.route";
|
||||
import { clusterStore } from "../../../common/cluster-store";
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewCurrentClusterSettings",
|
||||
title: "Cluster: View Settings",
|
||||
scope: "global",
|
||||
action: () => navigate(clusterSettingsURL({
|
||||
params: {
|
||||
clusterId: clusterStore.active.id
|
||||
}
|
||||
})),
|
||||
isActive: (context) => !!context.cluster
|
||||
});
|
||||
@ -1,2 +1,3 @@
|
||||
export * from "./cluster-settings.route";
|
||||
export * from "./cluster-settings";
|
||||
export * from "./cluster-settings.command";
|
||||
|
||||
50
src/renderer/components/+config/config.command.ts
Normal file
50
src/renderer/components/+config/config.command.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import { navigate } from "../../navigation";
|
||||
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
import { configMapsURL } from "../+config-maps";
|
||||
import { secretsURL } from "../+config-secrets";
|
||||
import { resourceQuotaURL } from "../+config-resource-quotas";
|
||||
import { limitRangeURL } from "../+config-limit-ranges";
|
||||
import { hpaURL } from "../+config-autoscalers";
|
||||
import { pdbURL } from "../+config-pod-disruption-budgets";
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewConfigMaps",
|
||||
title: "Cluster: View ConfigMaps",
|
||||
scope: "cluster",
|
||||
action: () => navigate(configMapsURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewSecrets",
|
||||
title: "Cluster: View Secrets",
|
||||
scope: "cluster",
|
||||
action: () => navigate(secretsURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewResourceQuotas",
|
||||
title: "Cluster: View ResourceQuotas",
|
||||
scope: "cluster",
|
||||
action: () => navigate(resourceQuotaURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewLimitRanges",
|
||||
title: "Cluster: View LimitRanges",
|
||||
scope: "cluster",
|
||||
action: () => navigate(limitRangeURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewHorizontalPodAutoscalers",
|
||||
title: "Cluster: View HorizontalPodAutoscalers (HPA)",
|
||||
scope: "cluster",
|
||||
action: () => navigate(hpaURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewPodDisruptionBudget",
|
||||
title: "Cluster: View PodDisruptionBudgets",
|
||||
scope: "cluster",
|
||||
action: () => navigate(pdbURL())
|
||||
});
|
||||
@ -1,2 +1,3 @@
|
||||
export * from "./config.route";
|
||||
export * from "./config";
|
||||
export * from "./config.command";
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
export * from "./network.route";
|
||||
export * from "./network";
|
||||
export * from "./network.command";
|
||||
|
||||
34
src/renderer/components/+network/network.command.ts
Normal file
34
src/renderer/components/+network/network.command.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { navigate } from "../../navigation";
|
||||
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
import { servicesURL } from "../+network-services";
|
||||
import { endpointURL } from "../+network-endpoints";
|
||||
import { ingressURL } from "../+network-ingresses";
|
||||
import { networkPoliciesURL } from "../+network-policies";
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewServices",
|
||||
title: "Cluster: View Services",
|
||||
scope: "cluster",
|
||||
action: () => navigate(servicesURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewEndpoints",
|
||||
title: "Cluster: View Endpoints",
|
||||
scope: "cluster",
|
||||
action: () => navigate(endpointURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewIngresses",
|
||||
title: "Cluster: View Ingresses",
|
||||
scope: "cluster",
|
||||
action: () => navigate(ingressURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewNetworkPolicies",
|
||||
title: "Cluster: View NetworkPolicies",
|
||||
scope: "cluster",
|
||||
action: () => navigate(networkPoliciesURL())
|
||||
});
|
||||
@ -1,3 +1,4 @@
|
||||
export * from "./nodes";
|
||||
export * from "./nodes.route";
|
||||
export * from "./node-details";
|
||||
export * from "./node.command";
|
||||
|
||||
10
src/renderer/components/+nodes/node.command.ts
Normal file
10
src/renderer/components/+nodes/node.command.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { navigate } from "../../navigation";
|
||||
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
import { nodesURL } from "./nodes.route";
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewNodes",
|
||||
title: "Cluster: View Nodes",
|
||||
scope: "cluster",
|
||||
action: () => navigate(nodesURL())
|
||||
});
|
||||
@ -1,3 +1,4 @@
|
||||
export * from "./workloads.route";
|
||||
export * from "./workloads";
|
||||
export * from "./workloads.stores";
|
||||
export * from "./workloads.command";
|
||||
|
||||
45
src/renderer/components/+workloads/workloads.command.ts
Normal file
45
src/renderer/components/+workloads/workloads.command.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { navigate } from "../../navigation";
|
||||
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
import { cronJobsURL, daemonSetsURL, deploymentsURL, jobsURL, podsURL, statefulSetsURL } from "./workloads.route";
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewPods",
|
||||
title: "Cluster: View Pods",
|
||||
scope: "cluster",
|
||||
action: () => navigate(podsURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewDeployments",
|
||||
title: "Cluster: View Deployments",
|
||||
scope: "cluster",
|
||||
action: () => navigate(deploymentsURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewDaemonSets",
|
||||
title: "Cluster: View DaemonSets",
|
||||
scope: "cluster",
|
||||
action: () => navigate(daemonSetsURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewStatefulSets",
|
||||
title: "Cluster: View StatefulSets",
|
||||
scope: "cluster",
|
||||
action: () => navigate(statefulSetsURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewJobs",
|
||||
title: "Cluster: View Jobs",
|
||||
scope: "cluster",
|
||||
action: () => navigate(jobsURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewCronJobs",
|
||||
title: "Cluster: View CronJobs",
|
||||
scope: "cluster",
|
||||
action: () => navigate(cronJobsURL())
|
||||
});
|
||||
@ -1,9 +1,7 @@
|
||||
import type { RouteProps } from "react-router";
|
||||
import { buildURL, IURLParams } from "../../../common/utils/buildUrl";
|
||||
import { isAllowedResource, KubeResource } from "../../../common/rbac";
|
||||
import { KubeResource } from "../../../common/rbac";
|
||||
import { Workloads } from "./workloads";
|
||||
import { navigate } from "../../navigation";
|
||||
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
|
||||
export const workloadsRoute: RouteProps = {
|
||||
get path() {
|
||||
@ -83,30 +81,4 @@ export const workloadURL: Partial<Record<KubeResource, ReturnType<typeof buildUR
|
||||
"cronjobs": cronJobsURL,
|
||||
};
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewPods",
|
||||
title: "Cluster: View Pods",
|
||||
scope: "cluster",
|
||||
action: () => navigate(podsURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewDeployments",
|
||||
title: "Cluster: View Deployments",
|
||||
scope: "cluster",
|
||||
action: () => navigate(deploymentsURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewDaemonSets",
|
||||
title: "Cluster: View DaemonSets",
|
||||
scope: "cluster",
|
||||
action: () => navigate(daemonSetsURL())
|
||||
});
|
||||
|
||||
commandRegistry.add({
|
||||
id: "cluster.viewStatefulSets",
|
||||
title: "Cluster: View StatefulSets",
|
||||
scope: "cluster",
|
||||
action: () => navigate(statefulSetsURL())
|
||||
});
|
||||
|
||||
@ -5,7 +5,7 @@ import { v4 as uuid } from "uuid";
|
||||
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
import { Input, InputValidator } from "../input";
|
||||
import { navigate } from "../../navigation";
|
||||
import { closeCommandDialog, openCommandDialog } from "../command-palette/command-container";
|
||||
import { CommandOverlay } from "../command-palette/command-container";
|
||||
|
||||
const uniqueWorkspaceName: InputValidator = {
|
||||
condition: ({ required }) => required,
|
||||
@ -15,7 +15,7 @@ const uniqueWorkspaceName: InputValidator = {
|
||||
|
||||
@observer
|
||||
export class AddWorkspace extends React.Component {
|
||||
handleKeyDown(name: string) {
|
||||
onSubmit(name: string) {
|
||||
if (name.trim() === "") {
|
||||
return;
|
||||
}
|
||||
@ -26,7 +26,7 @@ export class AddWorkspace extends React.Component {
|
||||
|
||||
workspaceStore.setActive(workspace.id);
|
||||
navigate("/");
|
||||
closeCommandDialog();
|
||||
CommandOverlay.close();
|
||||
}
|
||||
|
||||
render() {
|
||||
@ -37,7 +37,7 @@ export class AddWorkspace extends React.Component {
|
||||
autoFocus={true}
|
||||
theme="round-black"
|
||||
validators={[uniqueWorkspaceName]}
|
||||
onSubmit={(v) => this.handleKeyDown(v)}
|
||||
onSubmit={(v) => this.onSubmit(v)}
|
||||
dirty={true}
|
||||
showValidationLine={true} />
|
||||
<small className="hint">
|
||||
@ -52,5 +52,5 @@ commandRegistry.add({
|
||||
id: "workspace.addWorkspace",
|
||||
title: "Workspace: Add workspace ...",
|
||||
scope: "global",
|
||||
action: () => openCommandDialog(<AddWorkspace />)
|
||||
action: () => CommandOverlay.open(<AddWorkspace />)
|
||||
});
|
||||
|
||||
@ -5,7 +5,7 @@ import { WorkspaceStore, workspaceStore } from "../../../common/workspace-store"
|
||||
import { ConfirmDialog } from "../confirm-dialog";
|
||||
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
import { Select } from "../select";
|
||||
import { closeCommandDialog, openCommandDialog } from "../command-palette/command-container";
|
||||
import { CommandOverlay } from "../command-palette/command-container";
|
||||
|
||||
@observer
|
||||
export class RemoveWorkspace extends React.Component {
|
||||
@ -22,7 +22,7 @@ export class RemoveWorkspace extends React.Component {
|
||||
return;
|
||||
}
|
||||
|
||||
closeCommandDialog();
|
||||
CommandOverlay.close();
|
||||
ConfirmDialog.open({
|
||||
okButtonProps: {
|
||||
label: `Remove Workspace`,
|
||||
@ -67,5 +67,5 @@ commandRegistry.add({
|
||||
id: "workspace.removeWorkspace",
|
||||
title: "Workspace: Remove workspace ...",
|
||||
scope: "global",
|
||||
action: () => openCommandDialog(<RemoveWorkspace />)
|
||||
action: () => CommandOverlay.open(<RemoveWorkspace />)
|
||||
});
|
||||
|
||||
@ -5,7 +5,7 @@ import { workspaceStore } from "../../../common/workspace-store";
|
||||
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
import { Select } from "../select";
|
||||
import { navigate } from "../../navigation";
|
||||
import { closeCommandDialog, openCommandDialog } from "../command-palette/command-container";
|
||||
import { CommandOverlay } from "../command-palette/command-container";
|
||||
import { AddWorkspace } from "./add-workspace";
|
||||
import { RemoveWorkspace } from "./remove-workspace";
|
||||
|
||||
@ -30,20 +30,20 @@ export class ChooseWorkspace extends React.Component {
|
||||
|
||||
onChange(id: string) {
|
||||
if (id === ChooseWorkspace.addActionId) {
|
||||
openCommandDialog(<AddWorkspace />);
|
||||
CommandOverlay.open(<AddWorkspace />);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (id === ChooseWorkspace.removeActionId) {
|
||||
openCommandDialog(<RemoveWorkspace />);
|
||||
CommandOverlay.open(<RemoveWorkspace />);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
workspaceStore.setActive(id);
|
||||
navigate("/");
|
||||
closeCommandDialog();
|
||||
CommandOverlay.close();
|
||||
}
|
||||
|
||||
render() {
|
||||
@ -66,5 +66,5 @@ commandRegistry.add({
|
||||
id: "workspace.chooseWorkspace",
|
||||
title: "Workspace: Switch to workspace ...",
|
||||
scope: "global",
|
||||
action: () => openCommandDialog(<ChooseWorkspace />)
|
||||
action: () => CommandOverlay.open(<ChooseWorkspace />)
|
||||
});
|
||||
|
||||
@ -5,7 +5,7 @@ import { observer } from "mobx-react";
|
||||
import { Icon } from "../icon";
|
||||
import { workspaceStore } from "../../../common/workspace-store";
|
||||
import { statusBarRegistry } from "../../../extensions/registries";
|
||||
import { openCommandDialog } from "../command-palette/command-container";
|
||||
import { CommandOverlay } from "../command-palette/command-container";
|
||||
import { ChooseWorkspace } from "../+workspaces";
|
||||
|
||||
@observer
|
||||
@ -17,7 +17,7 @@ export class BottomBar extends React.Component {
|
||||
|
||||
return (
|
||||
<div className="BottomBar flex gaps">
|
||||
<div id="current-workspace" className="flex gaps align-center" onClick={() => openCommandDialog(<ChooseWorkspace />)}>
|
||||
<div id="current-workspace" className="flex gaps align-center" onClick={() => CommandOverlay.open(<ChooseWorkspace />)}>
|
||||
<Icon smallest material="layers"/>
|
||||
<span className="workspace-name">{currentWorkspace.name}</span>
|
||||
</div>
|
||||
|
||||
@ -23,7 +23,7 @@ import { clusterViewURL } from "./cluster-view.route";
|
||||
import { getExtensionPageUrl, globalPageMenuRegistry, globalPageRegistry } from "../../../extensions/registries";
|
||||
import { clusterDisconnectHandler } from "../../../common/cluster-ipc";
|
||||
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
import { closeCommandDialog, openCommandDialog } from "../command-palette/command-container";
|
||||
import { CommandOverlay } from "../command-palette/command-container";
|
||||
import { computed } from "mobx";
|
||||
import { Select } from "../select";
|
||||
|
||||
@ -196,7 +196,7 @@ export class ChooseCluster extends React.Component {
|
||||
|
||||
onChange(clusterId: string) {
|
||||
navigate(clusterViewURL({ params: { clusterId } }));
|
||||
closeCommandDialog();
|
||||
CommandOverlay.close();
|
||||
}
|
||||
|
||||
render() {
|
||||
@ -218,5 +218,5 @@ commandRegistry.add({
|
||||
id: "workspace.chooseCluster",
|
||||
title: "Workspace: Switch to cluster ...",
|
||||
scope: "global",
|
||||
action: () => openCommandDialog(<ChooseCluster />)
|
||||
action: () => CommandOverlay.open(<ChooseCluster />)
|
||||
});
|
||||
|
||||
@ -18,12 +18,14 @@ export type CommandDialogEvent = {
|
||||
|
||||
const commandDialogBus = new EventEmitter<[CommandDialogEvent]>();
|
||||
|
||||
export function openCommandDialog(component: React.ReactElement) {
|
||||
commandDialogBus.emit({ component });
|
||||
}
|
||||
export class CommandOverlay {
|
||||
static open(component: React.ReactElement) {
|
||||
commandDialogBus.emit({ component });
|
||||
}
|
||||
|
||||
export function closeCommandDialog() {
|
||||
commandDialogBus.emit({ component: null });
|
||||
static close() {
|
||||
commandDialogBus.emit({ component: null });
|
||||
}
|
||||
}
|
||||
|
||||
@observer
|
||||
@ -74,7 +76,7 @@ export class CommandContainer extends React.Component<{cluster?: Cluster}> {
|
||||
});
|
||||
} else {
|
||||
subscribeToBroadcast("command-palette:open", () => {
|
||||
openCommandDialog(<CommandDialog />);
|
||||
CommandOverlay.open(<CommandDialog />);
|
||||
});
|
||||
}
|
||||
window.addEventListener("keyup", (e) => this.escHandler(e), true);
|
||||
|
||||
@ -6,7 +6,7 @@ import React from "react";
|
||||
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
||||
import { clusterStore } from "../../../common/cluster-store";
|
||||
import { workspaceStore } from "../../../common/workspace-store";
|
||||
import { closeCommandDialog } from "./command-container";
|
||||
import { CommandOverlay } from "./command-container";
|
||||
import { broadcastMessage } from "../../../common/ipc";
|
||||
|
||||
@observer
|
||||
@ -50,7 +50,7 @@ export class CommandDialog extends React.Component {
|
||||
const action = toJS(command.action);
|
||||
|
||||
try {
|
||||
closeCommandDialog();
|
||||
CommandOverlay.close();
|
||||
|
||||
if (command.scope === "global") {
|
||||
action({
|
||||
|
||||
2
src/renderer/components/command-palette/index.ts
Normal file
2
src/renderer/components/command-palette/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from "./command-container";
|
||||
export * from "./command-dialog";
|
||||
Loading…
Reference in New Issue
Block a user