From 358408a1ceed6ca78ea584187c24e76b6de980c3 Mon Sep 17 00:00:00 2001 From: ducica Date: Mon, 9 Dec 2024 13:22:06 +0100 Subject: [PATCH 1/4] using new links structure --- .../common/actions/DirectCreateAndSubmit.jsx | 11 +++++--- .../common/actions/RequestActionButton.jsx | 1 + .../common/components/RequestCommentInput.jsx | 1 + .../common/components/RequestModalContent.jsx | 16 ++++++----- .../common/components/SideRequestInfo.jsx | 16 ++++++----- .../common/components/TopicPreview.jsx | 2 +- .../oarepo_requests_ui/common/utils/hooks.js | 27 +++++++++++-------- .../record-requests/index.js | 4 +-- .../components/RequestDetail.jsx | 2 +- 9 files changed, 49 insertions(+), 31 deletions(-) diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/actions/DirectCreateAndSubmit.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/actions/DirectCreateAndSubmit.jsx index 24a828ad..8221796c 100644 --- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/actions/DirectCreateAndSubmit.jsx +++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/actions/DirectCreateAndSubmit.jsx @@ -22,6 +22,7 @@ const DirectCreateAndSubmit = ({ isLoading, mutate: createAndSubmit, isError, + error, reset, } = useAction({ action: saveAndSubmit, @@ -69,9 +70,13 @@ const DirectCreateAndSubmit = ({ {isError && ( - {i18next.t( - "Request not created successfully. Please try again in a moment." - )} + {error?.response?.data?.errors?.length > 0 + ? i18next.t( + "Record has validation errors. Redirecting to form..." + ) + : i18next.t( + "Request not created successfully. Please try again in a moment." + )} )} diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/actions/RequestActionButton.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/actions/RequestActionButton.jsx index a4febd72..7a548f9d 100644 --- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/actions/RequestActionButton.jsx +++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/actions/RequestActionButton.jsx @@ -27,6 +27,7 @@ export const RequestActionButton = ({ requestOrRequestType: requestOrRequestType, formik, modalControl, + requestActionName, }); const handleClick = () => { diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/RequestCommentInput.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/RequestCommentInput.jsx index d1ee5fb5..a96e9c27 100644 --- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/RequestCommentInput.jsx +++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/RequestCommentInput.jsx @@ -37,6 +37,7 @@ export const RequestCommentInput = ({ editorConfig={{ auto_focus: true, min_height: 100, + width: "100%", toolbar: "blocks | bold italic | bullist numlist | outdent indent | undo redo", }} diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/RequestModalContent.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/RequestModalContent.jsx index 7305aa20..6c51f06f 100644 --- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/RequestModalContent.jsx +++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/RequestModalContent.jsx @@ -38,13 +38,15 @@ export const RequestModalContent = ({ {description && ( {" "} - - ({i18next.t("Request details")}) - + {request?.links?.self_html && ( + + ({i18next.t("Request details")}) + + )} )} diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/SideRequestInfo.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/SideRequestInfo.jsx index 2b3350c2..c47a80b7 100644 --- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/SideRequestInfo.jsx +++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/SideRequestInfo.jsx @@ -15,9 +15,9 @@ export const SideRequestInfo = ({ request }) => { - {_has(request, "links.created_by_html") ? ( + {_has(request, "links.created_by.self_html") ? ( @@ -34,9 +34,9 @@ export const SideRequestInfo = ({ request }) => { - {_has(request, "links.receiver_html") ? ( + {_has(request, "links.receiver.self_html") ? ( @@ -61,11 +61,15 @@ export const SideRequestInfo = ({ request }) => { {i18next.t("Created")} {request.created} - {request?.links?.topic_html && ( + {request?.links?.topic?.self_html && ( {i18next.t("Topic")} - + {request?.topic?.label ? _truncate(request?.topic?.label, { length: 350, diff --git a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/TopicPreview.jsx b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/TopicPreview.jsx index 4b3e17ff..488ebb82 100644 --- a/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/TopicPreview.jsx +++ b/oarepo_requests/ui/theme/assets/semantic-ui/js/oarepo_requests_ui/common/components/TopicPreview.jsx @@ -31,7 +31,7 @@ export const TopicPreview = ({ request }) => { )}