34 lines
805 B
TypeScript
34 lines
805 B
TypeScript
export type CollapsedAllocationGroups = Set<string> | "all";
|
|
|
|
export function createInitialCollapsedAllocationGroups(): CollapsedAllocationGroups {
|
|
return new Set<string>();
|
|
}
|
|
|
|
export function toggleCollapsedAllocationGroup(
|
|
previous: CollapsedAllocationGroups,
|
|
groupIds: string[],
|
|
resourceId: string,
|
|
): CollapsedAllocationGroups {
|
|
if (previous === "all") {
|
|
const next = new Set(groupIds);
|
|
next.delete(resourceId);
|
|
return next;
|
|
}
|
|
|
|
const next = new Set(previous);
|
|
if (next.has(resourceId)) {
|
|
next.delete(resourceId);
|
|
} else {
|
|
next.add(resourceId);
|
|
}
|
|
return next;
|
|
}
|
|
|
|
export function collapseAllAllocationGroups(): CollapsedAllocationGroups {
|
|
return "all";
|
|
}
|
|
|
|
export function expandAllAllocationGroups(): CollapsedAllocationGroups {
|
|
return new Set<string>();
|
|
}
|