mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
* 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
18 lines
530 B
TypeScript
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)}
|
|
/>
|
|
);
|
|
}
|