From 513309c1608a0995e85eb3688cadf76791ecc587 Mon Sep 17 00:00:00 2001 From: Dmytro <98233552+DmytroAlipov@users.noreply.github.com> Date: Tue, 10 Sep 2024 16:24:11 +0200 Subject: [PATCH] fix: no validation for combined length of org, number, run (#1262) Co-authored-by: Dima Alipov --- src/data/constants.js | 4 ++++ .../CreateOrRerunCourseForm.jsx | 8 ++++--- .../CreateOrRerunCourseForm.test.jsx | 22 +++++++++++++++++++ src/generic/create-or-rerun-course/hooks.jsx | 8 ++++++- .../create-or-rerun-course/messages.js | 5 +++++ 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/data/constants.js b/src/data/constants.js index 65c330ef6..6e97135e3 100644 --- a/src/data/constants.js +++ b/src/data/constants.js @@ -53,3 +53,7 @@ export const VisibilityTypes = /** @type {const} */ ({ UNSCHEDULED: 'unscheduled', NEEDS_ATTENTION: 'needs_attention', }); + +export const TOTAL_LENGTH_KEY = 'total-length'; + +export const MAX_TOTAL_LENGTH = 65; diff --git a/src/generic/create-or-rerun-course/CreateOrRerunCourseForm.jsx b/src/generic/create-or-rerun-course/CreateOrRerunCourseForm.jsx index cffbf53f2..36bafc597 100644 --- a/src/generic/create-or-rerun-course/CreateOrRerunCourseForm.jsx +++ b/src/generic/create-or-rerun-course/CreateOrRerunCourseForm.jsx @@ -16,7 +16,7 @@ import TypeaheadDropdown from '../../editors/sharedComponents/TypeaheadDropdown' import AlertMessage from '../alert-message'; import { STATEFUL_BUTTON_STATES } from '../../constants'; -import { RequestStatus } from '../../data/constants'; +import { RequestStatus, TOTAL_LENGTH_KEY } from '../../data/constants'; import { getSavingStatus } from '../data/selectors'; import { getStudioHomeData } from '../../studio-home/data/selectors'; import { updatePostErrors } from '../data/slice'; @@ -132,6 +132,8 @@ const CreateOrRerunCourseForm = ({ }, ]; + const errorMessage = errors[TOTAL_LENGTH_KEY] || postErrors?.errMsg; + const createButtonState = { labels: { default: intl.formatMessage(isCreateNewCourse ? messages.createButton : messages.rerunCreateButton), @@ -202,11 +204,11 @@ const CreateOrRerunCourseForm = ({ return (
- {showErrorBanner ? ( + {(errors[TOTAL_LENGTH_KEY] || showErrorBanner) ? (