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 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 { batchDeleteCompletedTasksAsync, deleteAllCompletedTasksAsync, deleteCompletedTaskAsync, listCompletedTasksAsync, } from "../actions/tasksActions"; import { taskDetailsPath } from "../paths"; import { AppState } from "../store"; import { TableColumn } from "../types/table"; import { durationFromSeconds, prettifyPayload, stringifyDuration, timeAgo, uuidPrefix, } from "../utils"; import SyntaxHighlighter from "./SyntaxHighlighter"; import TasksTable, { RowProps, useRowStyles } from "./TasksTable"; function mapStateToProps(state: AppState) { return { loading: state.tasks.completedTasks.loading, error: state.tasks.completedTasks.error, tasks: state.tasks.completedTasks.data, batchActionPending: state.tasks.completedTasks.batchActionPending, allActionPending: state.tasks.completedTasks.allActionPending, pollInterval: state.settings.pollInterval, pageSize: state.settings.taskRowsPerPage, }; } const mapDispatchToProps = { listTasks: listCompletedTasksAsync, deleteTask: deleteCompletedTaskAsync, deleteAllTasks: deleteAllCompletedTasksAsync, batchDeleteTasks: batchDeleteCompletedTasksAsync, taskRowsPerPageChange, }; const connector = connect(mapStateToProps, mapDispatchToProps); type ReduxProps = ConnectedProps; interface Props { queue: string; // name of the queue. totalTaskCount: number; // totoal number of completed tasks. } const columns: TableColumn[] = [ { key: "id", label: "ID", align: "left" }, { key: "type", label: "Type", align: "left" }, { key: "payload", label: "Payload", align: "left" }, { key: "completed_at", label: "Completed", align: "left" }, { key: "result", label: "Result", align: "left" }, { key: "ttl", label: "TTL", align: "left" }, { 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)} {timeAgo(task.completed_at)} {prettifyPayload(task.result)} {task.ttl_seconds > 0 ? `${stringifyDuration(durationFromSeconds(task.ttl_seconds))} left` : `expired`} {!window.READ_ONLY && ( e.stopPropagation()} > {props.showActions ? ( ) : ( )} )}
); } function CompletedTasksTable(props: Props & ReduxProps) { return ( } {...props} /> ); } export default connector(CompletedTasksTable);