grafana/public/app/features/browse-dashboards/components/CheckboxHeaderCell.tsx
Josh Hunt 32d3e895b3
NestedFolders: Indicate when folders have mixed-selection children (#67337)
* Show indeterminate checkbox for folders with partially selected children

* When selecting an item, check ancestors to see if all their children are now selected

* reword comment

* fix test

* fix lint

* Check all descendants for mixed state

* Use indeterminate checkbox

* fix test description

* make header checkbox select/unselect automatically

* mixed header checkbox:

* fix tests

* add tests
2023-05-02 13:17:25 +03:00

18 lines
530 B
TypeScript

import React from 'react';
import { Checkbox } from '@grafana/ui';
import { DashboardTreeHeaderProps, SelectionState } from '../types';
export default function CheckboxHeaderCell({ isSelected, onAllSelectionChange }: DashboardTreeHeaderProps) {
const state = isSelected?.('$all') ?? SelectionState.Unselected;
return (
<Checkbox
value={state === SelectionState.Selected}
indeterminate={state === SelectionState.Mixed}
onChange={(ev) => onAllSelectionChange?.(ev.currentTarget.checked)}
/>
);
}