mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-10-20 21:36:12 +08:00
add copy id feature for task tables
This commit is contained in:
@@ -1,45 +1,36 @@
|
||||
import React, { useCallback, useState } from "react";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import { connect, ConnectedProps } from "react-redux";
|
||||
import Checkbox from "@material-ui/core/Checkbox";
|
||||
import IconButton from "@material-ui/core/IconButton";
|
||||
import Paper from "@material-ui/core/Paper";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import Table from "@material-ui/core/Table";
|
||||
import TableBody from "@material-ui/core/TableBody";
|
||||
import TableCell from "@material-ui/core/TableCell";
|
||||
import Alert from "@material-ui/lab/Alert";
|
||||
import AlertTitle from "@material-ui/lab/AlertTitle";
|
||||
import TableContainer from "@material-ui/core/TableContainer";
|
||||
import TableFooter from "@material-ui/core/TableFooter";
|
||||
import TableHead from "@material-ui/core/TableHead";
|
||||
import TablePagination from "@material-ui/core/TablePagination";
|
||||
import TableRow from "@material-ui/core/TableRow";
|
||||
import Tooltip from "@material-ui/core/Tooltip";
|
||||
import Paper from "@material-ui/core/Paper";
|
||||
import Checkbox from "@material-ui/core/Checkbox";
|
||||
import IconButton from "@material-ui/core/IconButton";
|
||||
import TableFooter from "@material-ui/core/TableFooter";
|
||||
import TablePagination from "@material-ui/core/TablePagination";
|
||||
import DeleteIcon from "@material-ui/icons/Delete";
|
||||
import ArchiveIcon from "@material-ui/icons/Archive";
|
||||
import DeleteIcon from "@material-ui/icons/Delete";
|
||||
import FileCopyOutlinedIcon from '@material-ui/icons/FileCopyOutlined';
|
||||
import MoreHorizIcon from "@material-ui/icons/MoreHoriz";
|
||||
import SyntaxHighlighter from "./SyntaxHighlighter";
|
||||
import TablePaginationActions, {
|
||||
rowsPerPageOptions,
|
||||
} from "./TablePaginationActions";
|
||||
import TableActions from "./TableActions";
|
||||
import {
|
||||
listPendingTasksAsync,
|
||||
deletePendingTaskAsync,
|
||||
batchDeletePendingTasksAsync,
|
||||
deleteAllPendingTasksAsync,
|
||||
archivePendingTaskAsync,
|
||||
batchArchivePendingTasksAsync,
|
||||
archiveAllPendingTasksAsync,
|
||||
} from "../actions/tasksActions";
|
||||
import Alert from "@material-ui/lab/Alert";
|
||||
import AlertTitle from "@material-ui/lab/AlertTitle";
|
||||
import React, { useCallback, useState } from "react";
|
||||
import { connect, ConnectedProps } from "react-redux";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import { taskRowsPerPageChange } from "../actions/settingsActions";
|
||||
import { AppState } from "../store";
|
||||
import { archiveAllPendingTasksAsync, archivePendingTaskAsync, batchArchivePendingTasksAsync, batchDeletePendingTasksAsync, deleteAllPendingTasksAsync, deletePendingTaskAsync, listPendingTasksAsync } from "../actions/tasksActions";
|
||||
import { usePolling } from "../hooks";
|
||||
import { uuidPrefix, prettifyPayload } from "../utils";
|
||||
import { TableColumn } from "../types/table";
|
||||
import { TaskInfoExtended } from "../reducers/tasksReducer";
|
||||
import { taskDetailsPath } from "../paths";
|
||||
import { TaskInfoExtended } from "../reducers/tasksReducer";
|
||||
import { AppState } from "../store";
|
||||
import { TableColumn } from "../types/table";
|
||||
import { prettifyPayload, uuidPrefix } from "../utils";
|
||||
import SyntaxHighlighter from "./SyntaxHighlighter";
|
||||
import TableActions from "./TableActions";
|
||||
import TablePaginationActions, { rowsPerPageOptions } from "./TablePaginationActions";
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
table: {
|
||||
@@ -95,7 +86,6 @@ function PendingTasksTable(props: Props & ReduxProps) {
|
||||
const [page, setPage] = useState(0);
|
||||
const [selectedIds, setSelectedIds] = useState<string[]>([]);
|
||||
const [activeTaskId, setActiveTaskId] = useState<string>("");
|
||||
|
||||
const handlePageChange = (
|
||||
event: React.MouseEvent<HTMLButtonElement> | null,
|
||||
newPage: number
|
||||
@@ -296,13 +286,20 @@ function PendingTasksTable(props: Props & ReduxProps) {
|
||||
const useRowStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
cursor: "pointer",
|
||||
"& #copy-button": {
|
||||
display: "none"
|
||||
},
|
||||
"&:hover": {
|
||||
boxShadow: theme.shadows[2],
|
||||
"& #copy-button": {
|
||||
display: "inline-block"
|
||||
}
|
||||
},
|
||||
"&:hover .MuiTableCell-root": {
|
||||
borderBottomColor: theme.palette.background.paper,
|
||||
},
|
||||
},
|
||||
|
||||
actionCell: {
|
||||
width: "96px",
|
||||
},
|
||||
@@ -345,8 +342,22 @@ function Row(props: RowProps) {
|
||||
/>
|
||||
</IconButton>
|
||||
</TableCell>
|
||||
<TableCell component="th" scope="row">
|
||||
<TableCell component="th" scope="row" style={{width:'200px'}}>
|
||||
{uuidPrefix(task.id)}
|
||||
<Tooltip title="Copy text to clipboard">
|
||||
<IconButton
|
||||
onClick={(e) =>
|
||||
{
|
||||
e.stopPropagation()
|
||||
navigator.clipboard.writeText(task.id) }
|
||||
}
|
||||
size="small"
|
||||
id="copy-button"
|
||||
className={classes.actionButton}
|
||||
>
|
||||
<FileCopyOutlinedIcon fontSize="small" style={{height:"12px", width:"12px"}} />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</TableCell>
|
||||
<TableCell>{task.type}</TableCell>
|
||||
<TableCell>
|
||||
|
Reference in New Issue
Block a user