feat: refactor sidebar to nested draggable lists with long-press gesture arbitration

This commit is contained in:
Mohamed Boudra
2026-03-04 10:27:01 +07:00
parent bf1cded8a1
commit 3c066f5dd9
14 changed files with 830 additions and 327 deletions
+4 -37
View File
@@ -8,46 +8,21 @@ export interface SidebarShortcutWorkspaceTarget {
workspaceId: string
}
export type SidebarWorkspaceTreeRow =
| {
kind: 'project'
rowKey: string
project: SidebarProjectEntry
displayName: string
}
| {
kind: 'workspace'
rowKey: string
projectKey: string
workspace: SidebarWorkspaceEntry
shortcutNumber: number | null
}
export interface SidebarWorkspaceViewModel {
rows: SidebarWorkspaceTreeRow[]
export interface SidebarShortcutModel {
shortcutTargets: SidebarShortcutWorkspaceTarget[]
shortcutIndexByWorkspaceKey: Map<string, number>
}
export function buildSidebarWorkspaceViewModel(input: {
export function buildSidebarShortcutModel(input: {
projects: SidebarProjectEntry[]
collapsedProjectKeys: ReadonlySet<string>
getProjectDisplayName: (project: SidebarProjectEntry) => string
shortcutLimit?: number
}): SidebarWorkspaceViewModel {
}): SidebarShortcutModel {
const maxShortcuts = Math.max(0, Math.floor(input.shortcutLimit ?? 9))
const rows: SidebarWorkspaceTreeRow[] = []
const shortcutTargets: SidebarShortcutWorkspaceTarget[] = []
const shortcutIndexByWorkspaceKey = new Map<string, number>()
for (const project of input.projects) {
rows.push({
kind: 'project',
rowKey: `project:${project.projectKey}`,
project,
displayName: input.getProjectDisplayName(project),
})
if (input.collapsedProjectKeys.has(project.projectKey)) {
continue
}
@@ -62,16 +37,8 @@ export function buildSidebarWorkspaceViewModel(input: {
})
shortcutIndexByWorkspaceKey.set(workspace.workspaceKey, shortcutNumber)
}
rows.push({
kind: 'workspace',
rowKey: `workspace:${project.projectKey}:${workspace.workspaceKey}`,
projectKey: project.projectKey,
workspace,
shortcutNumber,
})
}
}
return { rows, shortcutTargets, shortcutIndexByWorkspaceKey }
return { shortcutTargets, shortcutIndexByWorkspaceKey }
}