mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
- Completely removes ClusterStore.activeCluster - Every workspace now tracks it current activeCluster - If an active cluster is removed then the workspace's activeClusterId is set to undefined - Only show welcome notification on the first time a non-managed workspace is viewed in the workspace overview - Add unit tests for the WorkspaceStore - Add validation that only valid clusters can be set to the activeClusterId field - only show workspace overview back button if there is an active cluster - Move workspacesSeen to storage from workspaceStore - clear out old values from landing_page store only on load - display landing page notification from reaction, fix doc comment Signed-off-by: Sebastian Malton <sebastian@malton.name>
63 lines
1.7 KiB
TypeScript
63 lines
1.7 KiB
TypeScript
import React from "react";
|
|
import { observer } from "mobx-react";
|
|
import { Workspace, workspaceStore } from "../../../common/workspace-store";
|
|
import { v4 as uuid } from "uuid";
|
|
import { commandRegistry } from "../../../extensions/registries/command-registry";
|
|
import { Input, InputValidator } from "../input";
|
|
import { navigate } from "../../navigation";
|
|
import { CommandOverlay } from "../command-palette/command-container";
|
|
import { landingURL } from "../+landing-page";
|
|
|
|
const uniqueWorkspaceName: InputValidator = {
|
|
condition: ({ required }) => required,
|
|
message: () => `Workspace with this name already exists`,
|
|
validate: value => !workspaceStore.getByName(value),
|
|
};
|
|
|
|
@observer
|
|
export class AddWorkspace extends React.Component {
|
|
onSubmit(name: string) {
|
|
if (!name.trim()) {
|
|
return;
|
|
}
|
|
const workspace = workspaceStore.addWorkspace(new Workspace({
|
|
id: uuid(),
|
|
name
|
|
}));
|
|
|
|
if (!workspace) {
|
|
return;
|
|
}
|
|
|
|
workspaceStore.setActive(workspace.id);
|
|
navigate(landingURL());
|
|
CommandOverlay.close();
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<>
|
|
<Input
|
|
placeholder="Workspace name"
|
|
autoFocus={true}
|
|
theme="round-black"
|
|
data-test-id="command-palette-workspace-add-name"
|
|
validators={[uniqueWorkspaceName]}
|
|
onSubmit={(v) => this.onSubmit(v)}
|
|
dirty={true}
|
|
showValidationLine={true} />
|
|
<small className="hint">
|
|
Please provide a new workspace name (Press "Enter" to confirm or "Escape" to cancel)
|
|
</small>
|
|
</>
|
|
);
|
|
}
|
|
}
|
|
|
|
commandRegistry.add({
|
|
id: "workspace.addWorkspace",
|
|
title: "Workspace: Add workspace ...",
|
|
scope: "global",
|
|
action: () => CommandOverlay.open(<AddWorkspace />)
|
|
});
|