1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import 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, any>;
16 onColumnToggle: (column: DataColumn<any, any>) => void;
20 type CssRules = "checkbox" | "listItem" | "listItemText";
22 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
35 export type ColumnSelectorProps = ColumnSelectorDataProps & WithStyles<CssRules>;
37 export const ColumnSelector = withStyles(styles)(
38 ({ columns, onColumnToggle, classes }: ColumnSelectorProps) =>
39 <Popover triggerComponent={ColumnSelectorTrigger}>
43 .filter(column => column.configurable)
44 .map((column, index) =>
48 className={classes.listItem}
49 onClick={() => onColumnToggle(column)}>
53 checked={column.selected}
54 className={classes.checkbox} />
56 className={classes.listItemText}>
66 export const ColumnSelectorTrigger = (props: IconButtonProps) =>
67 <Tooltip disableFocusListener title="Select columns">
68 <IconButton {...props}>
69 <MenuIcon aria-label="Select columns" />