From 234cc1d358656f1f679724486429018a234a0040 Mon Sep 17 00:00:00 2001 From: Dima Alipov Date: Fri, 6 Sep 2024 15:47:43 +0300 Subject: [PATCH] fix: no validation for combined length of org, number, run --- 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 65c330ef6d..6e97135e33 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 cffbf53f24..36bafc5974 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) ? (