Fix sidebar shortcut hints shifting rows
This commit is contained in:
@@ -199,6 +199,37 @@ describe("buildStatusSidebarShortcutModel", () => {
|
||||
expect(model.shortcutIndexByWorkspaceKey.get("s1:running-old")).toBe(3);
|
||||
expect(model.shortcutIndexByWorkspaceKey.get("s1:done-old")).toBe(4);
|
||||
});
|
||||
|
||||
it("excludes collapsed status groups from shortcut targets", () => {
|
||||
const workspaces = [
|
||||
workspace({
|
||||
serverId: "s1",
|
||||
workspaceId: "needs-input",
|
||||
workspaceDirectory: "/repo/needs-input",
|
||||
name: "needs input",
|
||||
projectKey: "p1",
|
||||
statusBucket: "needs_input",
|
||||
}),
|
||||
workspace({
|
||||
serverId: "s1",
|
||||
workspaceId: "running",
|
||||
workspaceDirectory: "/repo/running",
|
||||
name: "running",
|
||||
projectKey: "p1",
|
||||
statusBucket: "running",
|
||||
}),
|
||||
];
|
||||
|
||||
const model = buildStatusSidebarShortcutModel({
|
||||
workspaces,
|
||||
projectNamesByKey: new Map([["p1", "Project 1"]]),
|
||||
collapsedStatusGroupKeys: new Set(["needs_input"]),
|
||||
});
|
||||
|
||||
expect(model.shortcutTargets).toEqual([{ serverId: "s1", workspaceId: "running" }]);
|
||||
expect(model.shortcutIndexByWorkspaceKey.get("s1:needs-input")).toBeUndefined();
|
||||
expect(model.shortcutIndexByWorkspaceKey.get("s1:running")).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getRelativeSidebarShortcutTarget", () => {
|
||||
|
||||
@@ -53,6 +53,7 @@ export function buildSidebarShortcutModel(input: {
|
||||
export function buildStatusSidebarShortcutModel(input: {
|
||||
workspaces: SidebarWorkspaceEntry[];
|
||||
projectNamesByKey: Map<string, string>;
|
||||
collapsedStatusGroupKeys?: ReadonlySet<string>;
|
||||
shortcutLimit?: number;
|
||||
}): SidebarShortcutModel {
|
||||
const maxShortcuts = Math.max(0, Math.floor(input.shortcutLimit ?? 9));
|
||||
@@ -61,6 +62,10 @@ export function buildStatusSidebarShortcutModel(input: {
|
||||
const shortcutIndexByWorkspaceKey = new Map<string, number>();
|
||||
|
||||
for (const group of groups) {
|
||||
if (input.collapsedStatusGroupKeys?.has(group.bucket)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const workspace of group.rows) {
|
||||
if (shortcutTargets.length >= maxShortcuts) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user