Skip to content

Commit 11b7840

Browse files
committed
feat: add all selected functionality
1 parent 27b4502 commit 11b7840

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

frontend/testing-view/src/features/filtering/store/filteringSlice.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export interface FilteringSlice {
6868
category: BoardName,
6969
) => number;
7070
getTotalCount: (scope: FilterScope) => number;
71+
isAllSelected: (scope: FilterScope) => boolean;
7172
getSelectionState: (scope: FilterScope, category: BoardName) => CheckboxState;
7273

7374
/** Virtualization & Expansion */
@@ -336,6 +337,10 @@ export const createFilteringSlice: StateCreator<
336337
const catalog = get().getCatalog(scope);
337338
return Object.values(catalog).reduce((acc, items) => acc + items.length, 0);
338339
},
340+
isAllSelected: (scope) => {
341+
const total = get().getTotalCount(scope);
342+
return total > 0 && get().getFilteredCount(scope) === total;
343+
},
339344

340345
getSelectionState: (scope, category) => {
341346
const selectedCount = get().getFilteredCountByCategory(scope, category);

frontend/testing-view/src/hooks/useTransformedBoards.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export function useTransformedBoards(
2424
)
2525
return;
2626

27+
const store = useStore.getState();
28+
const wasAllCommands = store.isAllSelected("commands");
29+
const wasAllTelemetry = store.isAllSelected("telemetry");
30+
const wasAllLogs = store.isAllSelected("logs");
31+
2732
setTelemetryCatalog(transformedBoards.telemetryCatalog);
2833
setCommandsCatalog(transformedBoards.commandsCatalog);
2934
setBoards(Array.from(transformedBoards.boards));
@@ -33,7 +38,12 @@ export function useTransformedBoards(
3338
const hasCommandsData =
3439
Object.keys(transformedBoards.commandsCatalog).length > 0;
3540

36-
if (hasTelemetryData && hasCommandsData) initializeWorkspaceFilters();
41+
if (hasTelemetryData && hasCommandsData) {
42+
initializeWorkspaceFilters();
43+
if (wasAllCommands) useStore.getState().selectAllFilters("commands");
44+
if (wasAllTelemetry) useStore.getState().selectAllFilters("telemetry");
45+
if (wasAllLogs) useStore.getState().selectAllFilters("logs");
46+
}
3747
}, [
3848
transformedBoards,
3949
setTelemetryCatalog,

0 commit comments

Comments
 (0)