mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -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
30 lines
761 B
TypeScript
30 lines
761 B
TypeScript
import React from 'react';
|
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
import { Checkbox } from '@grafana/ui';
|
|
|
|
import { DashboardsTreeCellProps, SelectionState } from '../types';
|
|
|
|
export default function CheckboxCell({
|
|
row: { original: row },
|
|
isSelected,
|
|
onItemSelectionChange,
|
|
}: DashboardsTreeCellProps) {
|
|
const item = row.item;
|
|
|
|
if (item.kind === 'ui-empty-folder' || !isSelected) {
|
|
return null;
|
|
}
|
|
|
|
const state = isSelected(item);
|
|
|
|
return (
|
|
<Checkbox
|
|
data-testid={selectors.pages.BrowseDashbards.table.checkbox(item.uid)}
|
|
value={state === SelectionState.Selected}
|
|
indeterminate={state === SelectionState.Mixed}
|
|
onChange={(ev) => onItemSelectionChange?.(item, ev.currentTarget.checked)}
|
|
/>
|
|
);
|
|
}
|