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