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 Checkbox from "@material-ui/core/Checkbox";
|
||||||
import { useHistory } from "react-router-dom";
|
import IconButton from "@material-ui/core/IconButton";
|
||||||
import { connect, ConnectedProps } from "react-redux";
|
import Paper from "@material-ui/core/Paper";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
import Table from "@material-ui/core/Table";
|
import Table from "@material-ui/core/Table";
|
||||||
import TableBody from "@material-ui/core/TableBody";
|
import TableBody from "@material-ui/core/TableBody";
|
||||||
import TableCell from "@material-ui/core/TableCell";
|
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 TableContainer from "@material-ui/core/TableContainer";
|
||||||
|
import TableFooter from "@material-ui/core/TableFooter";
|
||||||
import TableHead from "@material-ui/core/TableHead";
|
import TableHead from "@material-ui/core/TableHead";
|
||||||
|
import TablePagination from "@material-ui/core/TablePagination";
|
||||||
import TableRow from "@material-ui/core/TableRow";
|
import TableRow from "@material-ui/core/TableRow";
|
||||||
import Tooltip from "@material-ui/core/Tooltip";
|
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 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 MoreHorizIcon from "@material-ui/icons/MoreHoriz";
|
||||||
import SyntaxHighlighter from "./SyntaxHighlighter";
|
import Alert from "@material-ui/lab/Alert";
|
||||||
import TablePaginationActions, {
|
import AlertTitle from "@material-ui/lab/AlertTitle";
|
||||||
rowsPerPageOptions,
|
import React, { useCallback, useState } from "react";
|
||||||
} from "./TablePaginationActions";
|
import { connect, ConnectedProps } from "react-redux";
|
||||||
import TableActions from "./TableActions";
|
import { useHistory } from "react-router-dom";
|
||||||
import {
|
|
||||||
listPendingTasksAsync,
|
|
||||||
deletePendingTaskAsync,
|
|
||||||
batchDeletePendingTasksAsync,
|
|
||||||
deleteAllPendingTasksAsync,
|
|
||||||
archivePendingTaskAsync,
|
|
||||||
batchArchivePendingTasksAsync,
|
|
||||||
archiveAllPendingTasksAsync,
|
|
||||||
} from "../actions/tasksActions";
|
|
||||||
import { taskRowsPerPageChange } from "../actions/settingsActions";
|
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 { usePolling } from "../hooks";
|
||||||
import { uuidPrefix, prettifyPayload } from "../utils";
|
|
||||||
import { TableColumn } from "../types/table";
|
|
||||||
import { TaskInfoExtended } from "../reducers/tasksReducer";
|
|
||||||
import { taskDetailsPath } from "../paths";
|
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) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
table: {
|
table: {
|
||||||
@@ -95,7 +86,6 @@ function PendingTasksTable(props: Props & ReduxProps) {
|
|||||||
const [page, setPage] = useState(0);
|
const [page, setPage] = useState(0);
|
||||||
const [selectedIds, setSelectedIds] = useState<string[]>([]);
|
const [selectedIds, setSelectedIds] = useState<string[]>([]);
|
||||||
const [activeTaskId, setActiveTaskId] = useState<string>("");
|
const [activeTaskId, setActiveTaskId] = useState<string>("");
|
||||||
|
|
||||||
const handlePageChange = (
|
const handlePageChange = (
|
||||||
event: React.MouseEvent<HTMLButtonElement> | null,
|
event: React.MouseEvent<HTMLButtonElement> | null,
|
||||||
newPage: number
|
newPage: number
|
||||||
@@ -296,13 +286,20 @@ function PendingTasksTable(props: Props & ReduxProps) {
|
|||||||
const useRowStyles = makeStyles((theme) => ({
|
const useRowStyles = makeStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
|
"& #copy-button": {
|
||||||
|
display: "none"
|
||||||
|
},
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
boxShadow: theme.shadows[2],
|
boxShadow: theme.shadows[2],
|
||||||
|
"& #copy-button": {
|
||||||
|
display: "inline-block"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"&:hover .MuiTableCell-root": {
|
"&:hover .MuiTableCell-root": {
|
||||||
borderBottomColor: theme.palette.background.paper,
|
borderBottomColor: theme.palette.background.paper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
actionCell: {
|
actionCell: {
|
||||||
width: "96px",
|
width: "96px",
|
||||||
},
|
},
|
||||||
@@ -345,8 +342,22 @@ function Row(props: RowProps) {
|
|||||||
/>
|
/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell component="th" scope="row">
|
<TableCell component="th" scope="row" style={{width:'200px'}}>
|
||||||
{uuidPrefix(task.id)}
|
{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>
|
||||||
<TableCell>{task.type}</TableCell>
|
<TableCell>{task.type}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
|
Reference in New Issue
Block a user