fix(app): don't allow workspaces in non-vcs projects

This commit is contained in:
adamelmore
2026-01-25 13:13:38 -06:00
parent 14b00f64a7
commit d115f33b59

View File

@@ -548,6 +548,7 @@ export default function Layout(props: ParentProps) {
const workspaceSetting = createMemo(() => {
const project = currentProject()
if (!project) return false
if (project.vcs !== "git") return false
return layout.sidebar.workspaces(project.worktree)()
})
@@ -587,7 +588,7 @@ export default function Layout(props: ParentProps) {
if (!expanded) continue
const project = projects.find((item) => item.worktree === directory || item.sandboxes?.includes(directory))
if (!project) continue
if (layout.sidebar.workspaces(project.worktree)()) continue
if (project.vcs === "git" && layout.sidebar.workspaces(project.worktree)()) continue
setStore("workspaceExpanded", directory, false)
}
})
@@ -2041,7 +2042,9 @@ export default function Layout(props: ParentProps) {
})
const workspaces = createMemo(() => workspaceIds(props.project).slice(0, 2))
const workspaceEnabled = createMemo(() => layout.sidebar.workspaces(props.project.worktree)())
const workspaceEnabled = createMemo(
() => props.project.vcs === "git" && layout.sidebar.workspaces(props.project.worktree)(),
)
const [open, setOpen] = createSignal(false)
const label = (directory: string) => {
@@ -2301,7 +2304,7 @@ export default function Layout(props: ParentProps) {
title: language.t("workspace.new"),
category: language.t("command.category.workspace"),
keybind: "mod+shift+w",
disabled: !layout.sidebar.workspaces(project()?.worktree ?? "")(),
disabled: !workspaceSetting(),
onSelect: createWorkspace,
},
])
@@ -2429,7 +2432,18 @@ export default function Layout(props: ParentProps) {
<DropdownMenu.Item onSelect={() => dialog.show(() => <DialogEditProject project={p} />)}>
<DropdownMenu.ItemLabel>{language.t("common.edit")}</DropdownMenu.ItemLabel>
</DropdownMenu.Item>
<DropdownMenu.Item onSelect={() => layout.sidebar.toggleWorkspaces(p.worktree)}>
<DropdownMenu.Item
disabled={p.vcs !== "git" && !layout.sidebar.workspaces(p.worktree)()}
onSelect={() => {
const enabled = layout.sidebar.workspaces(p.worktree)()
if (enabled) {
layout.sidebar.toggleWorkspaces(p.worktree)
return
}
if (p.vcs !== "git") return
layout.sidebar.toggleWorkspaces(p.worktree)
}}
>
<DropdownMenu.ItemLabel>
{layout.sidebar.workspaces(p.worktree)()
? language.t("sidebar.workspaces.disable")
@@ -2447,7 +2461,7 @@ export default function Layout(props: ParentProps) {
</div>
<Show
when={layout.sidebar.workspaces(p.worktree)()}
when={workspaceSetting()}
fallback={
<>
<div class="py-4 px-3">