import Checkbox from "@material-ui/core/Checkbox"; import IconButton from "@material-ui/core/IconButton"; import TableCell from "@material-ui/core/TableCell"; import TableRow from "@material-ui/core/TableRow"; import Tooltip from "@material-ui/core/Tooltip"; 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 React from "react"; import { connect, ConnectedProps } from "react-redux"; import { useHistory } from "react-router-dom"; import { taskRowsPerPageChange } from "../actions/settingsActions"; import { archiveAllPendingTasksAsync, archivePendingTaskAsync, batchArchivePendingTasksAsync, batchDeletePendingTasksAsync, deleteAllPendingTasksAsync, deletePendingTaskAsync, listPendingTasksAsync, } from "../actions/tasksActions"; import { taskDetailsPath } from "../paths"; import { AppState } from "../store"; import { TableColumn } from "../types/table"; import { prettifyPayload, uuidPrefix } from "../utils"; import SyntaxHighlighter from "./SyntaxHighlighter"; import TasksTable, { RowProps, useRowStyles } from "./TasksTable"; function mapStateToProps(state: AppState) { return { loading: state.tasks.pendingTasks.loading, error: state.tasks.pendingTasks.error, tasks: state.tasks.pendingTasks.data, batchActionPending: state.tasks.pendingTasks.batchActionPending, allActionPending: state.tasks.pendingTasks.allActionPending, pollInterval: state.settings.pollInterval, pageSize: state.settings.taskRowsPerPage, }; } const mapDispatchToProps = { listTasks: listPendingTasksAsync, deleteTask: deletePendingTaskAsync, batchDeleteTasks: batchDeletePendingTasksAsync, deleteAllTasks: deleteAllPendingTasksAsync, archiveTask: archivePendingTaskAsync, batchArchiveTasks: batchArchivePendingTasksAsync, archiveAllTasks: archiveAllPendingTasksAsync, taskRowsPerPageChange, }; const connector = connect(mapStateToProps, mapDispatchToProps); type ReduxProps = ConnectedProps; interface Props { queue: string; totalTaskCount: number; // total number of pending tasks } const columns: TableColumn[] = [ { key: "id", label: "ID", align: "left" }, { key: "type", label: "Type", align: "left" }, { key: "paylod", label: "Payload", align: "left" }, { key: "retried", label: "Retried", align: "right" }, { key: "max_retry", label: "Max Retry", align: "right" }, { key: "actions", label: "Actions", align: "center" }, ]; function Row(props: RowProps) { const { task } = props; const classes = useRowStyles(); const history = useHistory(); return ( history.push(taskDetailsPath(task.queue, task.id))} > {!window.READ_ONLY && ( e.stopPropagation()}> ) => props.onSelectChange(event.target.checked) } checked={props.isSelected} /> )}
{uuidPrefix(task.id)} { e.stopPropagation(); navigator.clipboard.writeText(task.id); }} size="small" className={classes.copyButton} >
{task.type} {prettifyPayload(task.payload)} {task.retried} {task.max_retry} {!window.READ_ONLY && ( e.stopPropagation()} > {props.showActions ? ( ) : ( )} )}
); } function PendingTasksTable(props: Props & ReduxProps) { return ( } {...props} /> ); } export default connector(PendingTasksTable);