UNPKG

@skbkontur/cassandra-distributed-task-queue-ui

Version:

.NET library implementing distributed task queue machinery using Apache Cassandra

68 lines 8.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TaskDetailsPage = void 0; const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); const edi_ui_1 = require("@skbkontur/edi-ui"); const ArrowRoundTimeForwardIcon16Regular_1 = require("@skbkontur/icons/ArrowRoundTimeForwardIcon16Regular"); const TextAlignCenterJustifyIcon16Regular_1 = require("@skbkontur/icons/TextAlignCenterJustifyIcon16Regular"); 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 = tslib_1.__importDefault(require("react")); const CustomSettingsContext_1 = require("../../CustomSettingsContext"); const TaskStateExtensions_1 = require("../../Domain/TaskStateExtensions"); const TasksPageContainer_1 = require("../../containers/TasksPageContainer"); const CommonLayout_1 = require("../Layouts/CommonLayout"); const RouterLink_1 = require("../RouterLink/RouterLink"); const TaskDetailsMetaTable_1 = require("../TaskDetailsMetaTable/TaskDetailsMetaTable"); const TaskTimeLine_1 = require("../TaskTimeLine/TaskTimeLine"); const TaskDetailsPage_styles_1 = require("./TaskDetailsPage.styles"); function TaskDetailsPage({ parentLocation, taskDetails, getTaskLocation, allowRerunOrCancel, onRerun, onCancel, }) { const [openedModal, setOpenedModal] = react_1.default.useState(false); const [modalType, setModalType] = react_1.default.useState("Cancel"); const theme = react_1.default.useContext(react_ui_1.ThemeContext); const { customDetailRenderer } = CustomSettingsContext_1.useCustomSettings(); const rerun = () => { setOpenedModal(true); setModalType("Rerun"); }; const cancel = () => { setOpenedModal(true); setModalType("Cancel"); }; const closeModal = () => setOpenedModal(false); const renderButtons = () => { if (!taskDetails) { return null; } const canCancel = taskDetails.taskMeta.taskActions ? taskDetails.taskMeta.taskActions.canCancel : allowRerunOrCancel && TaskStateExtensions_1.cancelableStates.includes(taskDetails.taskMeta.state); const canRerun = taskDetails.taskMeta.taskActions ? taskDetails.taskMeta.taskActions.canRerun : allowRerunOrCancel && TaskStateExtensions_1.rerunableStates.includes(taskDetails.taskMeta.state); const relatedTasksRequest = customDetailRenderer.getRelatedTasksLocation(taskDetails); if (!canCancel && !canRerun && relatedTasksRequest == null) { return null; } return (jsx_runtime_1.jsxs(react_stack_layout_1.RowStack, Object.assign({ baseline: true, block: true, gap: 2 }, { children: [jsx_runtime_1.jsx(react_stack_layout_1.Fill, {}, void 0), relatedTasksRequest && (jsx_runtime_1.jsx(react_stack_layout_1.Fit, { children: jsx_runtime_1.jsxs(RouterLink_1.RouterLink, Object.assign({ "data-tid": "RelatedTaskTree", to: `../Tree${TasksPageContainer_1.searchRequestMapping.stringify(relatedTasksRequest)}` }, { children: [jsx_runtime_1.jsx(TextAlignCenterJustifyIcon16Regular_1.TextAlignCenterJustifyIcon16Regular, {}, void 0), "\u00A0", "View related tasks tree"] }), void 0) }, void 0)), canCancel && (jsx_runtime_1.jsx(react_stack_layout_1.Fit, { children: jsx_runtime_1.jsx(react_ui_1.Link, Object.assign({ icon: jsx_runtime_1.jsx(XIcon16Regular_1.XIcon16Regular, {}, void 0), use: "danger", "data-tid": "CancelButton", onClick: cancel }, { children: "Cancel task" }), void 0) }, void 0)), canRerun && (jsx_runtime_1.jsx(react_stack_layout_1.Fit, { children: jsx_runtime_1.jsx(react_ui_1.Button, Object.assign({ use: "link", icon: jsx_runtime_1.jsx(ArrowRoundTimeForwardIcon16Regular_1.ArrowRoundTimeForwardIcon16Regular, {}, void 0), "data-tid": "RerunButton", onClick: rerun }, { children: "Rerun task" }), void 0) }, void 0))] }), void 0)); }; const renderModal = () => { if (!taskDetails) { return null; } return (jsx_runtime_1.jsxs(react_ui_1.Modal, Object.assign({ onClose: closeModal, width: 500, "data-tid": "ConfirmOperationModal" }, { children: [jsx_runtime_1.jsx(react_ui_1.Modal.Header, { children: jsx_runtime_1.jsx("span", Object.assign({ className: TaskDetailsPage_styles_1.jsStyles.modalText(theme) }, { children: "\u041D\u0443\u0436\u043D\u043E \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043D\u0438\u0435" }), void 0) }, void 0), jsx_runtime_1.jsx(react_ui_1.Modal.Body, { children: jsx_runtime_1.jsx("span", Object.assign({ "data-tid": "ModalText", className: TaskDetailsPage_styles_1.jsStyles.modalText(theme) }, { children: modalType === "Rerun" ? "Уверен, что таску надо перезапустить?" : "Уверен, что таску надо остановить?" }), void 0) }, void 0), jsx_runtime_1.jsx(react_ui_1.Modal.Footer, { children: jsx_runtime_1.jsxs(react_stack_layout_1.RowStack, Object.assign({ gap: 2 }, { children: [jsx_runtime_1.jsx(react_stack_layout_1.Fit, { children: modalType === "Rerun" ? (jsx_runtime_1.jsx(react_ui_1.Button, Object.assign({ "data-tid": "RerunButton", use: "success", onClick: () => { onRerun(taskDetails.taskMeta.id); closeModal(); } }, { children: "\u041F\u0435\u0440\u0435\u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u044C" }), void 0)) : (jsx_runtime_1.jsx(react_ui_1.Button, Object.assign({ "data-tid": "CancelButton", use: "danger", onClick: () => { onCancel(taskDetails.taskMeta.id); closeModal(); } }, { children: "\u041E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C" }), void 0)) }, void 0), jsx_runtime_1.jsx(react_stack_layout_1.Fit, { children: jsx_runtime_1.jsx(react_ui_1.Button, Object.assign({ "data-tid": "CloseButton", onClick: closeModal }, { children: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C" }), void 0) }, void 0)] }), void 0) }, void 0)] }), void 0)); }; return (jsx_runtime_1.jsxs("div", { children: [jsx_runtime_1.jsxs(CommonLayout_1.CommonLayout, Object.assign({ withArrow: true }, { children: [jsx_runtime_1.jsx(CommonLayout_1.CommonLayout.GoBack, { to: parentLocation }, void 0), taskDetails && (jsx_runtime_1.jsx(CommonLayout_1.CommonLayout.Header, Object.assign({ borderBottom: true, "data-tid": "Header", title: `Задача ${taskDetails.taskMeta.name}`, tools: renderButtons() }, { children: jsx_runtime_1.jsx(TaskTimeLine_1.TaskTimeLine, { getHrefToTask: getTaskLocation, taskMeta: taskDetails.taskMeta, childTaskIds: taskDetails.childTaskIds }, void 0) }), void 0)), jsx_runtime_1.jsx(CommonLayout_1.CommonLayout.Content, { children: jsx_runtime_1.jsxs(react_stack_layout_1.ColumnStack, Object.assign({ block: true, stretch: true, gap: 2 }, { children: [taskDetails && (jsx_runtime_1.jsx(react_stack_layout_1.Fit, { children: jsx_runtime_1.jsx(TaskDetailsMetaTable_1.TaskDetailsMetaTable, { taskMeta: taskDetails.taskMeta, childTaskIds: taskDetails.childTaskIds }, void 0) }, void 0)), taskDetails && (jsx_runtime_1.jsx(react_stack_layout_1.Fit, Object.assign({ className: TaskDetailsPage_styles_1.jsStyles.taskDataContainer() }, { children: jsx_runtime_1.jsx(edi_ui_1.Accordion, { renderCaption: null, renderValue: customDetailRenderer.renderDetails, value: taskDetails.taskData, title: "TaskData" }, void 0) }), void 0)), taskDetails && taskDetails.exceptionInfos && (jsx_runtime_1.jsx(react_stack_layout_1.Fit, Object.assign({ className: TaskDetailsPage_styles_1.jsStyles.exceptionContainer(), "data-tid": "Exceptions" }, { children: taskDetails.exceptionInfos.map((exception, index) => (jsx_runtime_1.jsx("pre", Object.assign({ "data-tid": "Exception", className: TaskDetailsPage_styles_1.jsStyles.exception(theme) }, { children: exception }), index))) }), void 0))] }), void 0) }, void 0)] }), void 0), openedModal && renderModal()] }, void 0)); } exports.TaskDetailsPage = TaskDetailsPage; //# sourceMappingURL=TaskDetailsPage.js.map