From a9aa6fb459540fd57480b711635f2ac6c6c26935 Mon Sep 17 00:00:00 2001 From: uzairr Date: Tue, 22 Nov 2022 15:51:22 +0500 Subject: [PATCH] feat: hide 2U specific fields Few 2U specific fields are appearing for all types of the course(s) which is creating confusion for the partners.Due to this change, 2U fields would only be displayed for 2U courses PROD-3032 --- .env | 1 + .env.development | 1 + .env.test | 1 + .../EditCoursePage/EditCourseForm.jsx | 64 ++-- .../EditCourseForm.test.jsx.snap | 282 ------------------ src/setupTest.js | 1 + 6 files changed, 41 insertions(+), 309 deletions(-) diff --git a/.env b/.env index 2b6ea295c..d3ac18775 100644 --- a/.env +++ b/.env @@ -1,4 +1,5 @@ NODE_ENV='production' +IDENTIFIER_2U='2U' BASE_URL=null LMS_BASE_URL=null STUDIO_BASE_URL=null diff --git a/.env.development b/.env.development index f7b22ae93..de756fce4 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,5 @@ NODE_ENV='development' +IDENTIFIER_2U='2U' PORT=18400 BASE_URL='localhost:18400' LMS_BASE_URL='http://localhost:18000' diff --git a/.env.test b/.env.test index 7e1d7dc70..6fa1e8e92 100644 --- a/.env.test +++ b/.env.test @@ -5,3 +5,4 @@ LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico SITE_NAME='edX' +IDENTIFIER_2U='2U' diff --git a/src/components/EditCoursePage/EditCourseForm.jsx b/src/components/EditCoursePage/EditCourseForm.jsx index cc0659a43..4921018b3 100644 --- a/src/components/EditCoursePage/EditCourseForm.jsx +++ b/src/components/EditCoursePage/EditCourseForm.jsx @@ -6,6 +6,7 @@ import { import { Link } from 'react-router-dom'; import { connect } from 'react-redux'; import { compose } from 'redux'; +import { getConfig } from '@edx/frontend-platform'; import { getAuthenticatedUser } from '@edx/frontend-platform/auth'; import { Icon, Hyperlink, Chip } from '@edx/paragon'; import { CloseSmall } from '@edx/paragon/icons'; @@ -226,6 +227,10 @@ export class BaseEditCourseForm extends React.Component { this.setCollapsible(true); } + filterCourseTypes2U(courseType) { + return courseType.label.includes(getConfig().IDENTIFIER_2U); + } + render() { const { handleSubmit, @@ -306,6 +311,7 @@ export class BaseEditCourseForm extends React.Component { priceLabels, runTypeModes, } = parsedTypeOptions; + const courseTypes2U = courseTypeOptions.filter(this.filterCourseTypes2U); const disabled = courseInReview || !editable; const showMarketingFields = !currentFormValues.type || !courseTypes[currentFormValues.type] || courseTypes[currentFormValues.type].course_run_types.some((crt) => crt.is_marketable); @@ -1046,34 +1052,38 @@ export class BaseEditCourseForm extends React.Component { className="course-skill" /> )} - - } - extraInput={{ onInvalid: this.openCollapsible }} - disabled={disabled} - optional - /> - 0 && ( + <> + + } + extraInput={{ onInvalid: this.openCollapsible }} + disabled={disabled} + optional /> - )} - extraInput={{ onInvalid: this.openCollapsible }} - id="organization-logo-override" - className="course-image" - maxImageSizeKilo={256} - requiredWidth={110} - requiredHeight={110} - disabled={disabled} - optional - /> + + )} + extraInput={{ onInvalid: this.openCollapsible }} + id="organization-logo-override" + className="course-image" + maxImageSizeKilo={256} + requiredWidth={110} + requiredHeight={110} + disabled={disabled} + optional + /> + + )} {administrator && ( <> diff --git a/src/components/EditCoursePage/__snapshots__/EditCourseForm.test.jsx.snap b/src/components/EditCoursePage/__snapshots__/EditCourseForm.test.jsx.snap index 03ffe9241..069c73d76 100644 --- a/src/components/EditCoursePage/__snapshots__/EditCourseForm.test.jsx.snap +++ b/src/components/EditCoursePage/__snapshots__/EditCourseForm.test.jsx.snap @@ -973,53 +973,6 @@ exports[`BaseEditCourseForm renders correctly when submitting for review 1`] = ` ] } /> - - } - name="organization_short_code_override" - optional={true} - /> - - } - maxImageSizeKilo={256} - name="organization_logo_override_url" - optional={true} - requiredHeight={110} - requiredWidth={110} - /> - - } - name="organization_short_code_override" - optional={true} - /> - - } - maxImageSizeKilo={256} - name="organization_logo_override_url" - optional={true} - requiredHeight={110} - requiredWidth={110} - /> - - } - name="organization_short_code_override" - optional={true} - /> - - } - maxImageSizeKilo={256} - name="organization_logo_override_url" - optional={true} - requiredHeight={110} - requiredWidth={110} - /> - - } - name="organization_short_code_override" - optional={true} - /> - - } - maxImageSizeKilo={256} - name="organization_logo_override_url" - optional={true} - requiredHeight={110} - requiredWidth={110} - /> - - } - name="organization_short_code_override" - optional={true} - /> - - } - maxImageSizeKilo={256} - name="organization_logo_override_url" - optional={true} - requiredHeight={110} - requiredWidth={110} - /> - - } - name="organization_short_code_override" - optional={true} - /> - - } - maxImageSizeKilo={256} - name="organization_logo_override_url" - optional={true} - requiredHeight={110} - requiredWidth={110} - /> { + // eslint-disable-next-line no-console console.log('Unhandled Rejection at: Promise', p, 'reason:', reason.stack); });