1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { WithStyles, StyleRulesCallback, withStyles, IconButton, Paper, List, Checkbox, ListItemText, ListItem, Tooltip } from '@material-ui/core';
7 import MenuIcon from "@material-ui/icons/Menu";
8 import { DataColumn } from '../data-table/data-column';
9 import { Popover } from "../popover/popover";
10 import { IconButtonProps } from '@material-ui/core/IconButton';
11 import { DataColumns } from '../data-table/data-table';
12 import { ArvadosTheme } from "~/common/custom-theme";
14 interface ColumnSelectorDataProps {
15 columns: DataColumns<any>;
16 onColumnToggle: (column: DataColumn<any>) => void;
19 type CssRules = "checkbox";
21 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
28 export type ColumnSelectorProps = ColumnSelectorDataProps & WithStyles<CssRules>;
30 export const ColumnSelector = withStyles(styles)(
31 ({ columns, onColumnToggle, classes }: ColumnSelectorProps) =>
32 <Popover triggerComponent={ColumnSelectorTrigger}>
36 .filter(column => column.configurable)
37 .map((column, index) =>
41 onClick={() => onColumnToggle(column)}>
45 checked={column.selected}
46 className={classes.checkbox} />
57 export const ColumnSelectorTrigger = (props: IconButtonProps) =>
58 <Tooltip title="Filters">
59 <IconButton {...props}>
60 <MenuIcon aria-label="Filters" />