Skip to content

Commit

Permalink
Cpappas/variant id in publisher less strict (#769)
Browse files Browse the repository at this point in the history
* Revert "Revert "feat: add variant_id to publisher UI for exec ed courses (#765)" (#768)"

This reverts commit 8c9b4f7.

* fix: allow additionalMetadata variant_id field in be blank
  • Loading branch information
christopappas authored Aug 22, 2022
1 parent 86f73ea commit 16f8ae8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/EditCoursePage/AdditionalMetadataFields.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ function AdditionalMetadataFields(props) {
disabled={disabled}
required
/>
<Field
name="additional_metadata.variant_id"
component={RenderInputTextField}
label=<FieldLabel id="variant_id.label" text="Course Variant Id" />
disabled={disabled}
required={false}
/>
<FieldLabel text="Fact 1" className="h3 font-weight-normal" />
<Field
name="additional_metadata.facts_1_heading"
Expand Down
3 changes: 3 additions & 0 deletions src/components/EditCoursePage/EditCoursePage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('EditCoursePage', () => {
}],
start_date: '2019-05-10T00:00:00Z',
registration_deadline: '2019-05-10T00:00:00Z',
variant_id: '00000000-0000-0000-0000-000000000000',
},
course_runs: [
{
Expand Down Expand Up @@ -355,6 +356,7 @@ describe('EditCoursePage', () => {
facts_2_blurb: 'facts_2_blurb',
start_date: '2019-05-10T00:00:00Z',
registration_deadline: '2019-05-10T00:00:00Z',
variant_id: '00000000-0000-0000-0000-000000000000',
},
course_runs: [unpublishedCourseRun, publishedCourseRun],
faq: '<p>Help?</p>',
Expand Down Expand Up @@ -917,6 +919,7 @@ describe('EditCoursePage', () => {
}],
start_date: '2019-05-10T00:00:00Z',
registration_deadline: '2019-05-10T00:00:00Z',
variant_id: '00000000-0000-0000-0000-000000000000',
},
draft: false,
collaborators: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ exports[`AdditionalMetadata Fields Display all fields 1`] = `
name="additional_metadata.organic_url"
required={true}
/>
<Field
component={[Function]}
disabled={false}
label={
<FieldLabel
className=""
extraText=""
helpText=""
id="variant_id.label"
optional={false}
text="Course Variant Id"
/>
}
name="additional_metadata.variant_id"
required={false}
/>
<FieldLabel
className="h3 font-weight-normal"
extraText=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ exports[`EditCoursePage renders page correctly with courseInfo 1`] = `
"organic_url": "https://www.organic_url.com",
"registration_deadline": "2019-05-10T00:00:00Z",
"start_date": "2019-05-10T00:00:00Z",
"variant_id": "00000000-0000-0000-0000-000000000000",
},
"collaborators": Array [],
"course_runs": Array [
Expand Down Expand Up @@ -538,6 +539,7 @@ exports[`EditCoursePage renders page correctly with courseInfo 1`] = `
"organic_url": "https://www.organic_url.com",
"registration_deadline": "2019-05-10T00:00:00Z",
"start_date": "2019-05-10T00:00:00Z",
"variant_id": "00000000-0000-0000-0000-000000000000",
},
"collaborators": Array [],
"course_runs": Array [
Expand Down Expand Up @@ -774,6 +776,7 @@ exports[`EditCoursePage renders page correctly with courseInfo and courseOptions
"organic_url": "https://www.organic_url.com",
"registration_deadline": "2019-05-10T00:00:00Z",
"start_date": "2019-05-10T00:00:00Z",
"variant_id": "00000000-0000-0000-0000-000000000000",
},
"collaborators": Array [],
"course_runs": Array [
Expand Down Expand Up @@ -1350,6 +1353,7 @@ exports[`EditCoursePage renders page correctly with courseInfo and courseOptions
"organic_url": "https://www.organic_url.com",
"registration_deadline": "2019-05-10T00:00:00Z",
"start_date": "2019-05-10T00:00:00Z",
"variant_id": "00000000-0000-0000-0000-000000000000",
},
"collaborators": Array [],
"course_runs": Array [
Expand Down Expand Up @@ -1771,6 +1775,7 @@ exports[`EditCoursePage renders page correctly with courseInfo, courseOptions, a
"organic_url": "https://www.organic_url.com",
"registration_deadline": "2019-05-10T00:00:00Z",
"start_date": "2019-05-10T00:00:00Z",
"variant_id": "00000000-0000-0000-0000-000000000000",
},
"collaborators": Array [],
"course_runs": Array [
Expand Down Expand Up @@ -2415,6 +2420,7 @@ exports[`EditCoursePage renders page correctly with courseInfo, courseOptions, a
"organic_url": "https://www.organic_url.com",
"registration_deadline": "2019-05-10T00:00:00Z",
"start_date": "2019-05-10T00:00:00Z",
"variant_id": "00000000-0000-0000-0000-000000000000",
},
"collaborators": Array [],
"course_runs": Array [
Expand Down
3 changes: 3 additions & 0 deletions src/components/EditCoursePage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class EditCoursePage extends React.Component {
}

formatAdditionalMetadataFields(courseData) {
const variantId = courseData.additional_metadata.variant_id || null;
return {
external_url: courseData.additional_metadata.external_url,
external_identifier: courseData.additional_metadata.external_identifier,
Expand All @@ -190,6 +191,7 @@ class EditCoursePage extends React.Component {
}],
start_date: courseData.additional_metadata.start_date,
registration_deadline: courseData.additional_metadata.registration_deadline,
variant_id: variantId,
};
}

Expand Down Expand Up @@ -398,6 +400,7 @@ class EditCoursePage extends React.Component {
facts_2_blurb: additional_metadata.facts[1]?.blurb,
start_date: additional_metadata.start_date,
registration_deadline: additional_metadata.registration_deadline,
variant_id: additional_metadata.variant_id,
};
}
return {};
Expand Down

0 comments on commit 16f8ae8

Please sign in to comment.