mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* wip: command palette Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * register shortcut to global menu Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * introduce openCommandDialog & closeCommandDialog Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix ipc broadcast to frames from renderer Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * tweak Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * add more commands Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * cleanup Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * ipc fix Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * add integration tests Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * ipc fix Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * implement workspace edit Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * workspace edit fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * make tests green Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fixes from code review Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * cleanup ipc Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * cleanup CommandRegistry Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * ipc fix Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fix ClusterManager cluster auto-init Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * ensure cluster view is active before sending a command Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * switch to last active cluster when workspace change Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * tweak integration tests Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * run integration tests serially Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * cleanup Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * fixes based on code review Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * cleanup Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * cleanup more Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * cleanup Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * add workspace fixes Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> * cleanup Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
69 lines
2.0 KiB
TypeScript
69 lines
2.0 KiB
TypeScript
import React from "react";
|
|
import { observer } from "mobx-react";
|
|
import { computed} from "mobx";
|
|
import { WorkspaceStore, workspaceStore } from "../../../common/workspace-store";
|
|
import { ConfirmDialog } from "../confirm-dialog";
|
|
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
|
import { Select } from "../select";
|
|
import { CommandOverlay } from "../command-palette/command-container";
|
|
|
|
@observer
|
|
export class RemoveWorkspace extends React.Component {
|
|
@computed get options() {
|
|
return workspaceStore.enabledWorkspacesList.filter((workspace) => workspace.id !== WorkspaceStore.defaultId).map((workspace) => {
|
|
return { value: workspace.id, label: workspace.name };
|
|
});
|
|
}
|
|
|
|
onChange(id: string) {
|
|
const workspace = workspaceStore.enabledWorkspacesList.find((workspace) => workspace.id === id);
|
|
|
|
if (!workspace ) {
|
|
return;
|
|
}
|
|
|
|
CommandOverlay.close();
|
|
ConfirmDialog.open({
|
|
okButtonProps: {
|
|
label: `Remove Workspace`,
|
|
primary: false,
|
|
accent: true,
|
|
},
|
|
ok: () => {
|
|
workspaceStore.removeWorkspace(workspace);
|
|
},
|
|
message: (
|
|
<div className="confirm flex column gaps">
|
|
<p>
|
|
Are you sure you want remove workspace <b>{workspace.name}</b>?
|
|
</p>
|
|
<p className="info">
|
|
All clusters within workspace will be cleared as well
|
|
</p>
|
|
</div>
|
|
),
|
|
});
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<Select
|
|
onChange={(v) => this.onChange(v.value)}
|
|
components={{ DropdownIndicator: null, IndicatorSeparator: null }}
|
|
menuIsOpen={true}
|
|
options={this.options}
|
|
autoFocus={true}
|
|
escapeClearsValue={false}
|
|
data-test-id="command-palette-workspace-remove-select"
|
|
placeholder="Remove workspace" />
|
|
);
|
|
}
|
|
}
|
|
|
|
commandRegistry.add({
|
|
id: "workspace.removeWorkspace",
|
|
title: "Workspace: Remove workspace ...",
|
|
scope: "global",
|
|
action: () => CommandOverlay.open(<RemoveWorkspace />)
|
|
});
|