From 1d40ff520dc0711b2a65a2f9662c656c98cd21ed Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Tue, 22 Dec 2020 06:05:24 -0800 Subject: [PATCH] Add cancel action button to ActiveTasksTable --- ui/src/components/ActiveTasksTable.tsx | 148 ++++++++++++++----------- 1 file changed, 85 insertions(+), 63 deletions(-) diff --git a/ui/src/components/ActiveTasksTable.tsx b/ui/src/components/ActiveTasksTable.tsx index 6ed5395..c52baea 100644 --- a/ui/src/components/ActiveTasksTable.tsx +++ b/ui/src/components/ActiveTasksTable.tsx @@ -17,6 +17,7 @@ import Box from "@material-ui/core/Box"; import Checkbox from "@material-ui/core/Checkbox"; import Collapse from "@material-ui/core/Collapse"; import IconButton from "@material-ui/core/IconButton"; +import CancelIcon from "@material-ui/icons/Cancel"; import KeyboardArrowUpIcon from "@material-ui/icons/KeyboardArrowUp"; import KeyboardArrowDownIcon from "@material-ui/icons/KeyboardArrowDown"; import Typography from "@material-ui/core/Typography"; @@ -31,6 +32,7 @@ import TablePaginationActions, { rowsPerPageOptions, defaultPageSize, } from "./TablePaginationActions"; +import TableActions from "./TableActions"; import { usePolling } from "../hooks"; import { ActiveTaskExtended } from "../reducers/tasksReducer"; import { uuidPrefix } from "../utils"; @@ -115,72 +117,92 @@ function ActiveTasksTable(props: Props & ReduxProps) { const rowCount = props.tasks.length; const numSelected = selectedIds.length; return ( - - - - - - 0 && numSelected < rowCount} - checked={rowCount > 0 && numSelected === rowCount} - onChange={handleSelectAllClick} - inputProps={{ - "aria-label": "select all tasks shown in the table", +
+ 0} + iconButtonActions={[ + { + tooltip: "Cancel", + icon: , + onClick: () => console.log("TODO"), + disabled: false, + }, + ]} + menuItemActions={[ + { + label: "Cancel All", + onClick: () => console.log("TODO"), + disabled: false, + }, + ]} + /> + +
+ + + + 0 && numSelected < rowCount} + checked={rowCount > 0 && numSelected === rowCount} + onChange={handleSelectAllClick} + inputProps={{ + "aria-label": "select all tasks shown in the table", + }} + /> + + {columns.map((col) => ( + + {col.label} + + ))} + + + + {/* TODO: loading and empty state */} + {props.tasks.map((task) => ( + { + if (checked) { + setSelectedIds(selectedIds.concat(task.id)); + } else { + setSelectedIds(selectedIds.filter((id) => id !== task.id)); + } + }} + onCancelClick={() => { + props.cancelActiveTaskAsync(queue, task.id); }} /> - - {columns.map((col) => ( - - {col.label} - ))} - - - - {/* TODO: loading and empty state */} - {props.tasks.map((task) => ( - { - if (checked) { - setSelectedIds(selectedIds.concat(task.id)); - } else { - setSelectedIds(selectedIds.filter((id) => id !== task.id)); - } - }} - onCancelClick={() => { - props.cancelActiveTaskAsync(queue, task.id); - }} - /> - ))} - - - - - - -
-
+ + + + + + + + + ); }