1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { CustomStyleRulesCallback } from 'common/custom-theme';
7 import { IconButton, Paper, List, Checkbox, ListItemText, ListItem, Tooltip } from '@mui/material';
8 import { WithStyles } from '@mui/styles';
9 import withStyles from '@mui/styles/withStyles';
10 import MenuIcon from "@mui/icons-material/Menu";
11 import { DataColumn, DataColumns } from '../data-table/data-column';
12 import { Popover } from "../popover/popover";
13 import { IconButtonProps } from '@mui/material/IconButton';
14 import { ArvadosTheme } from "common/custom-theme";
16 interface ColumnSelectorDataProps {
17 columns: DataColumns<any, any>;
18 onColumnToggle: (column: DataColumn<any, any>) => void;
22 type CssRules = "checkbox" | "listItem" | "listItemText";
24 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
37 export type ColumnSelectorProps = ColumnSelectorDataProps & WithStyles<CssRules>;
39 export const ColumnSelector = withStyles(styles)(
40 ({ columns, onColumnToggle, classes }: ColumnSelectorProps) =>
41 <Popover triggerComponent={ColumnSelectorTrigger}>
45 .filter(column => column.configurable)
46 .map((column, index) =>
50 className={classes.listItem}
51 data-cy={'column-selector-li'}
52 onClick={() => onColumnToggle(column)}>
56 checked={column.selected}
57 className={classes.checkbox} />
59 className={classes.listItemText}>
69 export const ColumnSelectorTrigger = (props: IconButtonProps) =>
70 <Tooltip disableFocusListener title="Select columns">
71 <IconButton {...props} size="large">
72 <MenuIcon aria-label="Select columns" data-cy="column-selector-button" />