From 4b61780e9b70b0339faa2051216ab36de4cf4495 Mon Sep 17 00:00:00 2001
From: srwang <12386424+srwang@users.noreply.github.com>
Date: Thu, 25 Aug 2022 03:53:12 -0400
Subject: [PATCH] Revert "feat: added dropdown fields to EditCourseForm.jsx
(#764)" (#771)
This reverts commit 86f73ea18d7a2c131f1146eab3bfcd4fdb0edaaa.
---
.../CreateCourseRunPage.test.jsx.snap | 124 ----
.../EditCoursePage/EditCourseForm.jsx | 61 --
.../EditCoursePage/EditCourseForm.test.jsx | 7 -
.../EditCoursePage/EditCoursePage.test.jsx | 28 -
.../EditCourseForm.test.jsx.snap | 575 ------------------
.../EditCoursePage.test.jsx.snap | 281 ---------
src/components/EditCoursePage/index.jsx | 23 -
.../updated-paragon-component.jsx | 71 ---
src/data/constants/testData.js | 32 -
9 files changed, 1202 deletions(-)
delete mode 100644 src/components/RenderSelectField/updated-paragon-component.jsx
diff --git a/src/components/CreateCourseRunPage/__snapshots__/CreateCourseRunPage.test.jsx.snap b/src/components/CreateCourseRunPage/__snapshots__/CreateCourseRunPage.test.jsx.snap
index d2a6a0609..002ea854c 100644
--- a/src/components/CreateCourseRunPage/__snapshots__/CreateCourseRunPage.test.jsx.snap
+++ b/src/components/CreateCourseRunPage/__snapshots__/CreateCourseRunPage.test.jsx.snap
@@ -35,68 +35,6 @@ exports[`CreateCourseRunPage renders html correctly 1`] = `
},
],
},
- "location_restriction": Object {
- "children": Object {
- "countries": Object {
- "child": Object {
- "choices": Array [
- Object {
- "label": "Afghanistan",
- "value": "AF",
- },
- Object {
- "label": "Åland Islands",
- "value": "AX",
- },
- Object {
- "label": "Algeria",
- "value": "DZ",
- },
- Object {
- "label": "American Samoa",
- "value": "AS",
- },
- Object {
- "label": "Andorra",
- "value": "AD",
- },
- ],
- },
- },
- "restriction_type": Object {
- "choices": Array [
- "blocklist",
- "allowlist",
- ],
- },
- "states": Object {
- "child": Object {
- "choices": Array [
- Object {
- "label": "Alabama",
- "value": "AL",
- },
- Object {
- "label": "Arizona",
- "value": "AZ",
- },
- Object {
- "label": "Arkansas",
- "value": "AR",
- },
- Object {
- "label": "California",
- "value": "CA",
- },
- Object {
- "label": "Colorado",
- "value": "CO",
- },
- ],
- },
- },
- },
- },
"subjects": Object {
"child": Object {
"choices": Array [
@@ -566,68 +504,6 @@ exports[`CreateCourseRunPage renders html correctly with Course Type 1`] = `
},
],
},
- "location_restriction": Object {
- "children": Object {
- "countries": Object {
- "child": Object {
- "choices": Array [
- Object {
- "label": "Afghanistan",
- "value": "AF",
- },
- Object {
- "label": "Åland Islands",
- "value": "AX",
- },
- Object {
- "label": "Algeria",
- "value": "DZ",
- },
- Object {
- "label": "American Samoa",
- "value": "AS",
- },
- Object {
- "label": "Andorra",
- "value": "AD",
- },
- ],
- },
- },
- "restriction_type": Object {
- "choices": Array [
- "blocklist",
- "allowlist",
- ],
- },
- "states": Object {
- "child": Object {
- "choices": Array [
- Object {
- "label": "Alabama",
- "value": "AL",
- },
- Object {
- "label": "Arizona",
- "value": "AZ",
- },
- Object {
- "label": "Arkansas",
- "value": "AR",
- },
- Object {
- "label": "California",
- "value": "CA",
- },
- Object {
- "label": "Colorado",
- "value": "CO",
- },
- ],
- },
- },
- },
- },
"subjects": Object {
"child": Object {
"choices": Array [
diff --git a/src/components/EditCoursePage/EditCourseForm.jsx b/src/components/EditCoursePage/EditCourseForm.jsx
index a33efce16..b2f5d2488 100644
--- a/src/components/EditCoursePage/EditCourseForm.jsx
+++ b/src/components/EditCoursePage/EditCourseForm.jsx
@@ -16,9 +16,6 @@ import FieldLabel from '../FieldLabel';
import ImageUpload from '../ImageUpload';
import RenderInputTextField from '../RenderInputTextField';
import RenderSelectField from '../RenderSelectField';
-// TODO: remove RenderSelectFieldNew when migrating off deprecated Paragon components,
-// i.e. as a part of https://github.com/openedx/frontend-app-publisher/pull/761
-import RenderSelectFieldNew from '../RenderSelectField/updated-paragon-component';
import RichEditor from '../RichEditor';
import Pill from '../Pill';
import Collapsible from '../Collapsible';
@@ -239,12 +236,6 @@ export class BaseEditCourseForm extends React.Component {
&& parseOptions(courseRunOptionsData.content_language.choices));
const programOptions = (courseRunOptionsData
&& parseOptions(courseRunOptionsData.expected_program_type.choices));
- const locationCountryOptions = courseOptionsData
- && parseOptions(courseOptionsData.location_restriction.children.countries.child.choices);
- const locationRestrictionTypeOptions = courseOptionsData
- && parseOptions(courseOptionsData.location_restriction.children.restriction_type.choices);
- const locationStateOptions = courseOptionsData
- && parseOptions(courseOptionsData.location_restriction.children.states.child.choices);
const {
data: {
@@ -944,53 +935,6 @@ export class BaseEditCourseForm extends React.Component {
disabled={disabled}
optional
/>
- {administrator && (
- <>
- I learned stuff! Stuff I learned stuff! Stuff I learned stuff! Stuff
learn
", @@ -853,16 +828,6 @@ exports[`EditCoursePage renders page correctly with courseInfo and courseOptions "key": "edX+Test101x", "learner_testimonials": null, "level_type": "intermediate", - "location_restriction": Object { - "countries": Array [ - "AF", - "AX", - ], - "restriction_type": "allowlist", - "states": Array [ - "AL", - ], - }, "organization_logo_override_url": "http://image.src.small", "organization_short_code_override": "test short code", "outcome": "learn
", @@ -925,68 +890,6 @@ exports[`EditCoursePage renders page correctly with courseInfo and courseOptions }, ], }, - "location_restriction": Object { - "children": Object { - "countries": Object { - "child": Object { - "choices": Array [ - Object { - "label": "Afghanistan", - "value": "AF", - }, - Object { - "label": "Åland Islands", - "value": "AX", - }, - Object { - "label": "Algeria", - "value": "DZ", - }, - Object { - "label": "American Samoa", - "value": "AS", - }, - Object { - "label": "Andorra", - "value": "AD", - }, - ], - }, - }, - "restriction_type": Object { - "choices": Array [ - "blocklist", - "allowlist", - ], - }, - "states": Object { - "child": Object { - "choices": Array [ - Object { - "label": "Alabama", - "value": "AL", - }, - Object { - "label": "Arizona", - "value": "AZ", - }, - Object { - "label": "Arkansas", - "value": "AR", - }, - Object { - "label": "California", - "value": "CA", - }, - Object { - "label": "Colorado", - "value": "CO", - }, - ], - }, - }, - }, - }, "subjects": Object { "child": Object { "choices": Array [ @@ -1423,16 +1326,6 @@ exports[`EditCoursePage renders page correctly with courseInfo and courseOptions }, "learner_testimonials": null, "level_type": "intermediate", - "location_restriction": Object { - "countries": Array [ - "AF", - "AX", - ], - "restriction_type": "allowlist", - "states": Array [ - "AL", - ], - }, "organization_logo_override_url": "http://image.src.small", "organization_short_code_override": "test short code", "outcome": "learn
", @@ -1604,11 +1497,6 @@ exports[`EditCoursePage renders page correctly with courseInfo error 1`] = ` }, "learner_testimonials": undefined, "level_type": undefined, - "location_restriction": Object { - "countries": null, - "restriction_type": null, - "states": null, - }, "organization_logo_override_url": undefined, "organization_short_code_override": undefined, "outcome": undefined, @@ -1852,16 +1740,6 @@ exports[`EditCoursePage renders page correctly with courseInfo, courseOptions, a "key": "edX+Test101x", "learner_testimonials": null, "level_type": "intermediate", - "location_restriction": Object { - "countries": Array [ - "AF", - "AX", - ], - "restriction_type": "allowlist", - "states": Array [ - "AL", - ], - }, "organization_logo_override_url": "http://image.src.small", "organization_short_code_override": "test short code", "outcome": "learn
", @@ -1924,68 +1802,6 @@ exports[`EditCoursePage renders page correctly with courseInfo, courseOptions, a }, ], }, - "location_restriction": Object { - "children": Object { - "countries": Object { - "child": Object { - "choices": Array [ - Object { - "label": "Afghanistan", - "value": "AF", - }, - Object { - "label": "Åland Islands", - "value": "AX", - }, - Object { - "label": "Algeria", - "value": "DZ", - }, - Object { - "label": "American Samoa", - "value": "AS", - }, - Object { - "label": "Andorra", - "value": "AD", - }, - ], - }, - }, - "restriction_type": Object { - "choices": Array [ - "blocklist", - "allowlist", - ], - }, - "states": Object { - "child": Object { - "choices": Array [ - Object { - "label": "Alabama", - "value": "AL", - }, - Object { - "label": "Arizona", - "value": "AZ", - }, - Object { - "label": "Arkansas", - "value": "AR", - }, - Object { - "label": "California", - "value": "CA", - }, - Object { - "label": "Colorado", - "value": "CO", - }, - ], - }, - }, - }, - }, "subjects": Object { "child": Object { "choices": Array [ @@ -2490,16 +2306,6 @@ exports[`EditCoursePage renders page correctly with courseInfo, courseOptions, a }, "learner_testimonials": null, "level_type": "intermediate", - "location_restriction": Object { - "countries": Array [ - "AF", - "AX", - ], - "restriction_type": "allowlist", - "states": Array [ - "AL", - ], - }, "organization_logo_override_url": "http://image.src.small", "organization_short_code_override": "test short code", "outcome": "learn
", @@ -2687,11 +2493,6 @@ exports[`EditCoursePage renders page correctly with courseInfo, courseOptions, a }, "learner_testimonials": undefined, "level_type": undefined, - "location_restriction": Object { - "countries": null, - "restriction_type": null, - "states": null, - }, "organization_logo_override_url": undefined, "organization_short_code_override": undefined, "outcome": undefined, @@ -2858,68 +2659,6 @@ exports[`EditCoursePage renders page correctly with courseOptions 1`] = ` }, ], }, - "location_restriction": Object { - "children": Object { - "countries": Object { - "child": Object { - "choices": Array [ - Object { - "label": "Afghanistan", - "value": "AF", - }, - Object { - "label": "Åland Islands", - "value": "AX", - }, - Object { - "label": "Algeria", - "value": "DZ", - }, - Object { - "label": "American Samoa", - "value": "AS", - }, - Object { - "label": "Andorra", - "value": "AD", - }, - ], - }, - }, - "restriction_type": Object { - "choices": Array [ - "blocklist", - "allowlist", - ], - }, - "states": Object { - "child": Object { - "choices": Array [ - Object { - "label": "Alabama", - "value": "AL", - }, - Object { - "label": "Arizona", - "value": "AZ", - }, - Object { - "label": "Arkansas", - "value": "AR", - }, - Object { - "label": "California", - "value": "CA", - }, - Object { - "label": "Colorado", - "value": "CO", - }, - ], - }, - }, - }, - }, "subjects": Object { "child": Object { "choices": Array [ @@ -3217,11 +2956,6 @@ exports[`EditCoursePage renders page correctly with courseOptions 1`] = ` }, "learner_testimonials": undefined, "level_type": undefined, - "location_restriction": Object { - "countries": null, - "restriction_type": null, - "states": null, - }, "organization_logo_override_url": undefined, "organization_short_code_override": undefined, "outcome": undefined, @@ -3391,11 +3125,6 @@ exports[`EditCoursePage renders page correctly with courseOptions error 1`] = ` }, "learner_testimonials": undefined, "level_type": undefined, - "location_restriction": Object { - "countries": null, - "restriction_type": null, - "states": null, - }, "organization_logo_override_url": undefined, "organization_short_code_override": undefined, "outcome": undefined, @@ -3640,11 +3369,6 @@ exports[`EditCoursePage renders page correctly with courseRunOptions 1`] = ` }, "learner_testimonials": undefined, "level_type": undefined, - "location_restriction": Object { - "countries": null, - "restriction_type": null, - "states": null, - }, "organization_logo_override_url": undefined, "organization_short_code_override": undefined, "outcome": undefined, @@ -3814,11 +3538,6 @@ exports[`EditCoursePage renders page correctly with courseRunOptions error 1`] = }, "learner_testimonials": undefined, "level_type": undefined, - "location_restriction": Object { - "countries": null, - "restriction_type": null, - "states": null, - }, "organization_logo_override_url": undefined, "organization_short_code_override": undefined, "outcome": undefined, diff --git a/src/components/EditCoursePage/index.jsx b/src/components/EditCoursePage/index.jsx index 271fb4c47..542c04b0b 100644 --- a/src/components/EditCoursePage/index.jsx +++ b/src/components/EditCoursePage/index.jsx @@ -212,21 +212,6 @@ class EditCoursePage extends React.Component { }; } - formatLocationRestrictionFields(courseData) { - if (courseData?.location_restriction) { - return { - restriction_type: courseData.location_restriction.restriction_type, - countries: courseData.location_restriction.countries, - states: courseData.location_restriction.states, - }; - } - return { - restriction_type: null, - countries: null, - states: null, - }; - } - prepareSendCourseData(courseData) { const { courseInfo: { @@ -253,7 +238,6 @@ class EditCoursePage extends React.Component { key, learner_testimonials: courseData.learner_testimonials, level_type: courseData.level_type, - location_restriction: courseData.location_restriction, organization_logo_override: courseData.organization_logo_override_url, organization_short_code_override: courseData.organization_short_code_override, outcome: courseData.outcome, @@ -280,12 +264,10 @@ class EditCoursePage extends React.Component { if (courseData.course_type === EXECUTIVE_EDUCATION_SLUG) { formattedCourseData.additional_metadata = this.formatAdditionalMetadataFields(courseData); } - // Check for values to prevent a new entry being created unnecessarily if (courseData.in_year_value && Object.values(courseData.in_year_value).some(value => value !== null)) { formattedCourseData.in_year_value = this.formatValueFields(courseData); } - return formattedCourseData; } @@ -462,10 +444,6 @@ class EditCoursePage extends React.Component { return this.formatValueFields(this.props.courseInfo.data); } - buildLocationRestriction() { - return this.formatLocationRestrictionFields(this.props.courseInfo.data); - } - buildInitialValues() { const { courseInfo: { @@ -531,7 +509,6 @@ class EditCoursePage extends React.Component { enterprise_subscription_inclusion, organization_short_code_override, organization_logo_override_url, - location_restriction: this.buildLocationRestriction(), in_year_value: this.buildInYearValue(), }; } diff --git a/src/components/RenderSelectField/updated-paragon-component.jsx b/src/components/RenderSelectField/updated-paragon-component.jsx deleted file mode 100644 index 5e690a2e3..000000000 --- a/src/components/RenderSelectField/updated-paragon-component.jsx +++ /dev/null @@ -1,71 +0,0 @@ -// TODO: This file can be deleted as a part of https://github.com/openedx/frontend-app-publisher/pull/761 -// When we migrate off deprecated paragon components, we want to replace the contents of ./index.jsx -// with the contents of this file and then delete this file. -// Adding this file to the codebase as a temporary measure -// because the existing select component doesn't have multiselect functionality -// and it doesn't make sense to edit paragon to add that functionality bc we're moving off that component soon. - -import React from 'react'; -import PropTypes from 'prop-types'; -import { Form } from '@edx/paragon'; - -const RenderSelectField = ({ - input, - extraInput, - name, - label, - disabled, - required, - meta: { touched, error }, - options, -}) => ( -