From 003a88d17b458289df4a7022bf936225661c5faf Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Thu, 26 Nov 2020 22:39:22 -0800 Subject: [PATCH] Add alert dialog for delete action in QueuesOverviewTable --- ui/src/components/QueuesOverviewTable.tsx | 329 ++++++++++++---------- 1 file changed, 185 insertions(+), 144 deletions(-) diff --git a/ui/src/components/QueuesOverviewTable.tsx b/ui/src/components/QueuesOverviewTable.tsx index 6eb0b10..fd53c84 100644 --- a/ui/src/components/QueuesOverviewTable.tsx +++ b/ui/src/components/QueuesOverviewTable.tsx @@ -2,6 +2,12 @@ import React, { useState } from "react"; import clsx from "clsx"; import { Link } from "react-router-dom"; import { makeStyles } from "@material-ui/core/styles"; +import Button from "@material-ui/core/Button"; +import Dialog from "@material-ui/core/Dialog"; +import DialogActions from "@material-ui/core/DialogActions"; +import DialogContent from "@material-ui/core/DialogContent"; +import DialogContentText from "@material-ui/core/DialogContentText"; +import DialogTitle from "@material-ui/core/DialogTitle"; import Table from "@material-ui/core/Table"; import TableBody from "@material-ui/core/TableBody"; import TableCell from "@material-ui/core/TableCell"; @@ -112,6 +118,7 @@ export default function QueuesOverviewTable(props: Props) { const [sortBy, setSortBy] = useState(SortBy.Queue); const [sortDir, setSortDir] = useState(SortDirection.Asc); const [activeRowIndex, setActiveRowIndex] = useState(-1); + const [queueToDelete, setQueueToDelete] = useState(null); const total = getAggregateCounts(props.queues); const createSortClickHandler = (sortKey: SortBy) => (e: React.MouseEvent) => { @@ -168,156 +175,190 @@ export default function QueuesOverviewTable(props: Props) { } }; + const handleDialogClose = () => { + setQueueToDelete(null); + }; + return ( - - - - - {colConfigs.map((cfg, i) => ( - - {cfg.sortBy !== SortBy.None ? ( - - {cfg.label} - - ) : ( -
{cfg.label}
- )} -
- ))} -
-
- - {sortQueues(props.queues, cmpFunc).map((q, i) => ( - setActiveRowIndex(i)} - onMouseLeave={() => setActiveRowIndex(-1)} - > - - - {q.queue} - {q.paused ? " (paused)" : ""} - - - - {q.size} - - - + +
+ + + {colConfigs.map((cfg, i) => ( + - {q.active} - - - - - {q.pending} - - - - - {q.scheduled} - - - - - {q.retry} - - - - - {q.dead} - - - -
- {activeRowIndex === i ? ( - - {q.paused ? ( - props.onResumeClick(q.queue)} - disabled={q.pauseRequestPending} - > - - - ) : ( - props.onPauseClick(q.queue)} - disabled={q.pauseRequestPending} - > - - - )} - console.log("TODO: delete this queue")} - > - - - + {cfg.sortBy !== SortBy.None ? ( + + {cfg.label} + ) : ( - - - +
{cfg.label}
)} -
+
+ ))} +
+
+ + {sortQueues(props.queues, cmpFunc).map((q, i) => ( + setActiveRowIndex(i)} + onMouseLeave={() => setActiveRowIndex(-1)} + > + + + {q.queue} + {q.paused ? " (paused)" : ""} + + + + {q.size} + + + + {q.active} + + + + + {q.pending} + + + + + {q.scheduled} + + + + + {q.retry} + + + + + {q.dead} + + + +
+ {activeRowIndex === i ? ( + + {q.paused ? ( + props.onResumeClick(q.queue)} + disabled={q.pauseRequestPending} + > + + + ) : ( + props.onPauseClick(q.queue)} + disabled={q.pauseRequestPending} + > + + + )} + setQueueToDelete(q)}> + + + + ) : ( + + + + )} +
+
+
+ ))} +
+ + + + Total + + + {total.size} + + + {total.active} + + + {total.pending} + + + {total.scheduled} + + + {total.retry} + + + {total.dead} - ))} - - - - - Total - - - {total.size} - - - {total.active} - - - {total.pending} - - - {total.scheduled} - - - {total.retry} - - - {total.dead} - - - -
-
+ + + + + {queueToDelete !== null && ( + <> + + Are you sure you want to delete "{queueToDelete.queue}"? + + + + All of the tasks in the queue will be deleted. You can't undo + this action. + + + + + + + + )} + + ); }