X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/9fff947ecd25b0494e8e3c6a27a4fa4fea67668f..2a0558ceed0332333908344cd1274d2827716d87:/src/components/data-table-multiselect-popover/data-table-multiselect-popover.tsx diff --git a/src/components/data-table-multiselect-popover/data-table-multiselect-popover.tsx b/src/components/data-table-multiselect-popover/data-table-multiselect-popover.tsx index 8b4175b3..0248c826 100644 --- a/src/components/data-table-multiselect-popover/data-table-multiselect-popover.tsx +++ b/src/components/data-table-multiselect-popover/data-table-multiselect-popover.tsx @@ -2,46 +2,33 @@ // // SPDX-License-Identifier: AGPL-3.0 -import React, { useEffect } from 'react'; -import { - WithStyles, - withStyles, - ButtonBase, - StyleRulesCallback, - Theme, - Popover, - Button, - Card, - CardActions, - Typography, - CardContent, - Tooltip, - IconButton, -} from '@material-ui/core'; -import classnames from 'classnames'; -import { DefaultTransformOrigin } from 'components/popover/helpers'; -import debounce from 'lodash/debounce'; -import { grey } from '@material-ui/core/colors'; +import React from "react"; +import { WithStyles, withStyles, ButtonBase, StyleRulesCallback, Theme, Popover, Card, Tooltip, IconButton } from "@material-ui/core"; +import classnames from "classnames"; +import { DefaultTransformOrigin } from "components/popover/helpers"; +import { grey } from "@material-ui/core/colors"; +import { TCheckedList } from "components/data-table/data-table"; -export type CssRules = 'root' | 'icon' | 'iconButton' | 'optionsContainer' | 'option'; +export type CssRules = "root" | "icon" | "iconButton" | "disabled" | "optionsContainer" | "option"; const styles: StyleRulesCallback = (theme: Theme) => ({ root: { - borderRadius: '7px', - '&:hover': { + borderRadius: "7px", + "&:hover": { backgroundColor: grey[200], }, - '&:focus': { + "&:focus": { color: theme.palette.text.primary, }, }, icon: { - cursor: 'pointer', + cursor: "pointer", fontSize: 20, - userSelect: 'none', - '&:hover': { + userSelect: "none", + "&:hover": { color: theme.palette.text.primary, }, + paddingBottom: "5px", }, iconButton: { color: theme.palette.text.primary, @@ -49,18 +36,21 @@ const styles: StyleRulesCallback = (theme: Theme) => ({ padding: 1, paddingBottom: 5, }, + disabled: { + color: grey[500], + }, optionsContainer: { - paddingBottom: '3px', + padding: "1rem 0", flex: 1, }, option: { - cursor: 'pointer', - display: 'flex', - padding: '3px 15px', - fontSize: '1rem', - alignItems: 'center', - '&:hover': { - backgroundColor: 'rgba(0, 0, 0, 0.08)', + cursor: "pointer", + display: "flex", + padding: "3px 2rem", + fontSize: "0.9rem", + alignItems: "center", + "&:hover": { + backgroundColor: "rgba(0, 0, 0, 0.08)", }, }, }); @@ -72,8 +62,9 @@ export type DataTableMultiselectOption = { export interface DataTableMultiselectProps { name: string; + disabled: boolean; options: DataTableMultiselectOption[]; - checkedList: Record; + checkedList: TCheckedList; } interface DataTableFMultiselectPopState { @@ -88,14 +79,30 @@ export const DataTableMultiselectPopover = withStyles(styles)( icon = React.createRef(); render() { - const { name, classes, children, options, checkedList } = this.props; + const { classes, children, options, checkedList, disabled } = this.props; return ( <> - - + + {} : this.open} + disableRipple + > {children} - - + + @@ -107,25 +114,23 @@ export const DataTableMultiselectPopover = withStyles(styles)( onClose={this.close} > - - {name} -
{options.length && options.map((option, i) => ( -
option.fn(checkedList)}> +
{ + option.fn(checkedList); + this.close(); + }} + > {option.name}
))}
- - - - ); } @@ -134,24 +139,8 @@ export const DataTableMultiselectPopover = withStyles(styles)( this.setState({ anchorEl: this.icon.current || undefined }); }; - submit = debounce(() => { - // const { onChange } = this.props; - // if (onChange) { - // onChange(this.state.filters); - // } - }, 1000); - - MountHandler = () => { - useEffect(() => { - return () => { - this.submit.cancel(); - }; - }, []); - return null; - }; - close = () => { - this.setState((prev) => ({ + this.setState(prev => ({ ...prev, anchorEl: undefined, }));