@skbkontur/cassandra-distributed-task-queue-ui
Version:
.NET library implementing distributed task queue machinery using Apache Cassandra
29 lines • 5.21 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskDetails = TaskDetails;
const jsx_runtime_1 = require("react/jsx-runtime");
const edi_ui_1 = require("@skbkontur/edi-ui");
const ArrowRoundTimeForwardIcon16Regular_1 = require("@skbkontur/icons/ArrowRoundTimeForwardIcon16Regular");
const XIcon16Regular_1 = require("@skbkontur/icons/XIcon16Regular");
const react_stack_layout_1 = require("@skbkontur/react-stack-layout");
const react_ui_1 = require("@skbkontur/react-ui");
const react_1 = require("react");
const CustomSettingsContext_1 = require("../../../CustomSettingsContext");
const TaskStateExtensions_1 = require("../../../Domain/TaskStateExtensions");
const RouterLink_1 = require("../../RouterLink/RouterLink");
const TaskDetails_styles_1 = require("./TaskDetails.styles");
function dateFormatter(item, selector) {
return (0, jsx_runtime_1.jsx)(edi_ui_1.Timestamp, { value: selector(item) });
}
function TaskDetails(props) {
const { allowRerunOrCancel, taskInfo, isChecked, onCancel, onRerun, onCheck, getTaskLocation } = props;
const theme = (0, react_1.useContext)(react_ui_1.ThemeContext);
const { customStateCaptions } = (0, CustomSettingsContext_1.useCustomSettings)();
const canCancel = taskInfo.taskActions ? taskInfo.taskActions.canCancel : TaskStateExtensions_1.cancelableStates.includes(taskInfo.state);
const canRerun = taskInfo.taskActions ? taskInfo.taskActions.canRerun : TaskStateExtensions_1.rerunableStates.includes(taskInfo.state);
const renderTaskDate = (taskInfo, caption, selector) => {
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: TaskDetails_styles_1.jsStyles.dateCaption(theme), children: caption }), (0, jsx_runtime_1.jsx)("span", { children: dateFormatter(taskInfo, selector) })] }));
};
return ((0, jsx_runtime_1.jsxs)(react_stack_layout_1.RowStack, { block: true, className: `${TaskDetails_styles_1.jsStyles.taskDetails()} ${TaskDetails_styles_1.jsStyles.state(theme, taskInfo.state)}`, gap: 2, children: [(0, jsx_runtime_1.jsx)(react_stack_layout_1.Fit, { children: (0, jsx_runtime_1.jsx)(react_ui_1.Checkbox, { className: TaskDetails_styles_1.jsStyles.checkbox(), onValueChange: onCheck, checked: isChecked }) }), (0, jsx_runtime_1.jsxs)(react_stack_layout_1.ColumnStack, { block: true, gap: 1, children: [(0, jsx_runtime_1.jsx)(react_stack_layout_1.Fit, { className: TaskDetails_styles_1.jsStyles.name(), children: (0, jsx_runtime_1.jsx)(RouterLink_1.RouterLink, { "data-tid": "Name", to: getTaskLocation(taskInfo.id), children: taskInfo.name }) }), (0, jsx_runtime_1.jsx)(react_stack_layout_1.Fit, { children: (0, jsx_runtime_1.jsxs)(react_stack_layout_1.RowStack, { verticalAlign: "stretch", block: true, gap: 2, children: [(0, jsx_runtime_1.jsxs)(react_stack_layout_1.Fit, { tag: react_stack_layout_1.ColumnStack, className: TaskDetails_styles_1.jsStyles.infoBlock1(), children: [(0, jsx_runtime_1.jsx)(react_stack_layout_1.Fit, { className: TaskDetails_styles_1.jsStyles.id(), children: (0, jsx_runtime_1.jsx)(edi_ui_1.AllowCopyToClipboard, { children: (0, jsx_runtime_1.jsx)("span", { "data-tid": "TaskId", children: taskInfo.id }) }) }), (0, jsx_runtime_1.jsxs)(react_stack_layout_1.Fit, { children: [(0, jsx_runtime_1.jsx)("span", { className: TaskDetails_styles_1.jsStyles.stateName(), "data-tid": "State", children: customStateCaptions[taskInfo.state] }), (0, jsx_runtime_1.jsxs)("span", { className: TaskDetails_styles_1.jsStyles.attempts(), children: ["Attempts: ", (0, jsx_runtime_1.jsx)("span", { "data-tid": "Attempts", children: taskInfo.attempts })] })] }), (0, jsx_runtime_1.jsx)(react_stack_layout_1.Fill, { className: TaskDetails_styles_1.jsStyles.parentTask(), children: (0, jsx_runtime_1.jsxs)("div", { children: ["Parent:", " ", taskInfo.parentTaskId ? ((0, jsx_runtime_1.jsx)(edi_ui_1.AllowCopyToClipboard, { children: taskInfo.parentTaskId })) : ("-")] }) }), allowRerunOrCancel && ((0, jsx_runtime_1.jsx)(react_stack_layout_1.Fit, { children: (0, jsx_runtime_1.jsxs)(react_stack_layout_1.RowStack, { baseline: true, block: true, gap: 2, children: [(0, jsx_runtime_1.jsx)(react_stack_layout_1.Fit, { children: (0, jsx_runtime_1.jsx)(react_ui_1.Link, { "data-tid": "Cancel", disabled: !canCancel, onClick: onCancel, icon: (0, jsx_runtime_1.jsx)(XIcon16Regular_1.XIcon16Regular, {}), children: "Cancel" }) }), (0, jsx_runtime_1.jsx)(react_stack_layout_1.Fit, { children: (0, jsx_runtime_1.jsx)(react_ui_1.Link, { "data-tid": "Rerun", disabled: !canRerun, onClick: onRerun, icon: (0, jsx_runtime_1.jsx)(ArrowRoundTimeForwardIcon16Regular_1.ArrowRoundTimeForwardIcon16Regular, {}), children: "Rerun" }) })] }) }))] }), (0, jsx_runtime_1.jsxs)(react_stack_layout_1.Fit, { className: TaskDetails_styles_1.jsStyles.dates(), children: [renderTaskDate(taskInfo, "Enqueued", x => x.ticks), renderTaskDate(taskInfo, "Started", x => x.startExecutingTicks), renderTaskDate(taskInfo, "Finished", x => x.finishExecutingTicks), renderTaskDate(taskInfo, "StateTime", x => x.minimalStartTicks), renderTaskDate(taskInfo, "Expiration", x => x.expirationTimestampTicks)] })] }) })] })] }));
}
//# sourceMappingURL=TaskDetails.js.map
;