1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from "react";
6 import { WithStyles, withStyles, ButtonBase, StyleRulesCallback, Theme, Popover, Card, Tooltip, IconButton } from "@material-ui/core";
7 import classnames from "classnames";
8 import { DefaultTransformOrigin } from "components/popover/helpers";
9 import { grey } from "@material-ui/core/colors";
10 import { TCheckedList } from "components/data-table/data-table";
12 export type CssRules = "root" | "icon" | "iconButton" | "disabled" | "optionsContainer" | "option";
14 const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
18 backgroundColor: grey[200],
21 color: theme.palette.text.primary,
29 color: theme.palette.text.primary,
34 color: theme.palette.text.primary,
53 backgroundColor: "rgba(0, 0, 0, 0.08)",
58 export type DataTableMultiselectOption = {
60 fn: (checkedList) => void;
63 export interface DataTableMultiselectProps {
66 options: DataTableMultiselectOption[];
67 checkedList: TCheckedList;
70 interface DataTableFMultiselectPopState {
71 anchorEl?: HTMLElement;
74 export const DataTableMultiselectPopover = withStyles(styles)(
75 class extends React.Component<DataTableMultiselectProps & WithStyles<CssRules>, DataTableFMultiselectPopState> {
76 state: DataTableFMultiselectPopState = {
79 icon = React.createRef<HTMLElement>();
82 const { classes, children, options, checkedList, disabled } = this.props;
87 title="Select options"
88 data-cy="data-table-multiselect-popover"
91 className={classnames(classes.root)}
93 onClick={disabled ? () => {} : this.open}
99 classes={{ root: classes.iconButton }}
103 className={`${classnames(["fas fa-sort-down", classes.icon])}${disabled ? ` ${classes.disabled}` : ""}`}
104 data-fa-transform="shrink-3"
111 anchorEl={this.state.anchorEl}
112 open={!!this.state.anchorEl}
113 anchorOrigin={DefaultTransformOrigin}
114 transformOrigin={DefaultTransformOrigin}
118 <div className={classes.optionsContainer}>
120 options.map((option, i) => (
122 data-cy={`multiselect-popover-${option.name}`}
124 className={classes.option}
126 option.fn(checkedList);
141 this.setState({ anchorEl: this.icon.current || undefined });
145 this.setState(prev => ({