feat: add workspace and tab navigation keyboard shortcuts
This commit is contained in:
@@ -39,6 +39,10 @@ describe("buildSidebarShortcutModel", () => {
|
||||
collapsedProjectKeys: new Set<string>(["p2"]),
|
||||
});
|
||||
|
||||
expect(model.visibleTargets).toEqual([
|
||||
{ serverId: "s1", workspaceId: "/repo/main" },
|
||||
{ serverId: "s1", workspaceId: "/repo/feat-a" },
|
||||
]);
|
||||
expect(model.shortcutTargets).toEqual([
|
||||
{ serverId: "s1", workspaceId: "/repo/main" },
|
||||
{ serverId: "s1", workspaceId: "/repo/feat-a" },
|
||||
@@ -57,6 +61,8 @@ describe("buildSidebarShortcutModel", () => {
|
||||
collapsedProjectKeys: new Set<string>(),
|
||||
});
|
||||
|
||||
expect(model.visibleTargets).toHaveLength(20);
|
||||
expect(model.visibleTargets[19]).toEqual({ serverId: "s", workspaceId: "/repo/w20" });
|
||||
expect(model.shortcutTargets).toHaveLength(9);
|
||||
expect(model.shortcutTargets[0]).toEqual({ serverId: "s", workspaceId: "/repo/w1" });
|
||||
expect(model.shortcutTargets[8]).toEqual({ serverId: "s", workspaceId: "/repo/w9" });
|
||||
|
||||
@@ -9,6 +9,7 @@ export interface SidebarShortcutWorkspaceTarget {
|
||||
}
|
||||
|
||||
export interface SidebarShortcutModel {
|
||||
visibleTargets: SidebarShortcutWorkspaceTarget[]
|
||||
shortcutTargets: SidebarShortcutWorkspaceTarget[]
|
||||
shortcutIndexByWorkspaceKey: Map<string, number>
|
||||
}
|
||||
@@ -19,6 +20,7 @@ export function buildSidebarShortcutModel(input: {
|
||||
shortcutLimit?: number
|
||||
}): SidebarShortcutModel {
|
||||
const maxShortcuts = Math.max(0, Math.floor(input.shortcutLimit ?? 9))
|
||||
const visibleTargets: SidebarShortcutWorkspaceTarget[] = []
|
||||
const shortcutTargets: SidebarShortcutWorkspaceTarget[] = []
|
||||
const shortcutIndexByWorkspaceKey = new Map<string, number>()
|
||||
|
||||
@@ -28,6 +30,10 @@ export function buildSidebarShortcutModel(input: {
|
||||
}
|
||||
|
||||
for (const workspace of project.workspaces) {
|
||||
visibleTargets.push({
|
||||
serverId: workspace.serverId,
|
||||
workspaceId: workspace.workspaceId,
|
||||
})
|
||||
const shortcutNumber =
|
||||
shortcutTargets.length < maxShortcuts ? shortcutTargets.length + 1 : null
|
||||
if (shortcutNumber !== null) {
|
||||
@@ -40,5 +46,5 @@ export function buildSidebarShortcutModel(input: {
|
||||
}
|
||||
}
|
||||
|
||||
return { shortcutTargets, shortcutIndexByWorkspaceKey }
|
||||
return { visibleTargets, shortcutTargets, shortcutIndexByWorkspaceKey }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user