mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-16 05:56:47 +01:00
63 lines
2.0 KiB
TypeScript
63 lines
2.0 KiB
TypeScript
import { useDeleteActiveWorkspace } from '../hooks/useDeleteActiveWorkspace';
|
|
import { useUpdateWorkspace } from '../hooks/useUpdateWorkspace';
|
|
import { useWorkspaces } from '../hooks/useWorkspaces';
|
|
import { Button } from './core/Button';
|
|
import { PlainInput } from './core/PlainInput';
|
|
import { VStack } from './core/Stacks';
|
|
import { MarkdownEditor } from './MarkdownEditor';
|
|
import { SelectFile } from './SelectFile';
|
|
|
|
interface Props {
|
|
workspaceId: string | null;
|
|
hide: () => void;
|
|
}
|
|
|
|
export function WorkspaceSettingsDialog({ workspaceId, hide }: Props) {
|
|
const workspaces = useWorkspaces();
|
|
const workspace = workspaces.find((w) => w.id === workspaceId);
|
|
const { mutate: updateWorkspace } = useUpdateWorkspace(workspaceId ?? null);
|
|
const { mutateAsync: deleteActiveWorkspace } = useDeleteActiveWorkspace();
|
|
|
|
if (workspace == null) return null;
|
|
|
|
return (
|
|
<VStack space={3} alignItems="start" className="pb-3 max-h-[50vh]">
|
|
<PlainInput
|
|
label="Workspace Name"
|
|
defaultValue={workspace.name}
|
|
onChange={(name) => updateWorkspace({ name })}
|
|
/>
|
|
|
|
<MarkdownEditor
|
|
name="workspace-description"
|
|
placeholder="Workspace description"
|
|
className="min-h-[10rem] max-h-[25rem] border border-border px-2"
|
|
defaultValue={workspace.description}
|
|
stateKey={`description.${workspace.id}`}
|
|
onChange={(description) => updateWorkspace({ description })}
|
|
heightMode="auto"
|
|
/>
|
|
|
|
<VStack space={3} className="mt-3" alignItems="start">
|
|
<SelectFile
|
|
directory
|
|
noun="Sync Directory"
|
|
filePath={workspace.settingSyncDir}
|
|
onChange={({ filePath: settingSyncDir }) => updateWorkspace({ settingSyncDir })}
|
|
/>
|
|
<Button
|
|
onClick={async () => {
|
|
await deleteActiveWorkspace();
|
|
hide();
|
|
}}
|
|
color="danger"
|
|
variant="border"
|
|
size="sm"
|
|
>
|
|
Delete Workspace
|
|
</Button>
|
|
</VStack>
|
|
</VStack>
|
|
);
|
|
}
|