From e5360dc1f1330bb50142cab4a3e889afcba87dea Mon Sep 17 00:00:00 2001 From: Jillian Date: Wed, 26 Feb 2025 12:37:43 +1030 Subject: [PATCH] fix: allow users who can create orgs to see the full list of orgs when creating a course [FC-0076] (#1689) The fixes for https://github.com/openedx/frontend-app-authoring/issues/1577 caused issues with edx.org's Global Staff users not being able to create courses. edx.org/2U Global Staff are seeing an empty Organization drop-down list. This issue arose due to misuse of two similarly-named flags returned by the contentstore's home API * `can_create_organizations`: granted to Global Staff or everyone if `FEATURES[ENABLE_CREATOR_GROUP] == True`, * `allow_to_create_new_org`: which is actually about auto-creating organizations, so both `can_create_organizations` + `settings.ORGANIZATIONS_AUTOCREATE` must be True In this change, we use `canCreateOrganizations` to decide whether the user can see the full list of organizations when creating courses. We preserve the use of `allowToCreateNewOrg` when deciding whether to allow users to "typeahead" to create a new organization not in the drop-down list. --- src/generic/create-or-rerun-course/hooks.jsx | 6 +++--- src/studio-home/__mocks__/studioHomeMock.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/generic/create-or-rerun-course/hooks.jsx b/src/generic/create-or-rerun-course/hooks.jsx index d4860e7e0..2f98d617e 100644 --- a/src/generic/create-or-rerun-course/hooks.jsx +++ b/src/generic/create-or-rerun-course/hooks.jsx @@ -27,12 +27,12 @@ const useCreateOrRerunCourse = (initialValues) => { const allOrganizations = useSelector(getOrganizations); const postErrors = useSelector(getPostErrors); const { - allowToCreateNewOrg, + canCreateOrganizations, allowedOrganizations, } = useSelector(getStudioHomeData); const [isFormFilled, setFormFilled] = useState(false); const [showErrorBanner, setShowErrorBanner] = useState(false); - const organizations = allowToCreateNewOrg ? allOrganizations : allowedOrganizations; + const organizations = canCreateOrganizations ? allOrganizations : allowedOrganizations; const { specialCharsRule, noSpaceRule } = REGEX_RULES; const validationSchema = Yup.object().shape({ @@ -78,7 +78,7 @@ const useCreateOrRerunCourse = (initialValues) => { }); useEffect(() => { - if (allowToCreateNewOrg) { + if (canCreateOrganizations) { dispatch(fetchOrganizationsQuery()); } }, []); diff --git a/src/studio-home/__mocks__/studioHomeMock.js b/src/studio-home/__mocks__/studioHomeMock.js index cc135f259..25e210eee 100644 --- a/src/studio-home/__mocks__/studioHomeMock.js +++ b/src/studio-home/__mocks__/studioHomeMock.js @@ -26,7 +26,7 @@ module.exports = { cmsLink: '//localhost:18010/courses/course-v1:Design+123+e.g.2025', }, ], - canCreateOrganizations: true, + canCreateOrganizations: false, courseCreatorStatus: 'granted', courses: [ {