Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add watchers field to course edit form #889

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/components/EditCoursePage/EditCourseForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,29 @@ export class BaseEditCourseForm extends React.Component {
disabled={disabled}
optional
/>
{administrator && (
<Field
name="watchers"
component={RenderInputTextField}
label={(
<FieldLabel
text="Watchers"
optional
helpText={(
<div>
<p>
A comma-separated list of email addresses that will be notified if the any of the course run
of the course is published or scheduled.
</p>
</div>
)}
/>
)}
extraInput={{ onInvalid: this.openCollapsible }}
disabled={disabled}
optional
/>
)}
{administrator && (
<>
<FieldLabel text="Merchandising Location Restriction" className="mb-2" />
Expand Down Expand Up @@ -1313,6 +1336,7 @@ BaseEditCourseForm.propTypes = {
external_course_marketing_type: PropTypes.string,
}),
topics: PropTypes.arrayOf(PropTypes.string),
watchers: PropTypes.arrayOf(PropTypes.string),
}),
}),
courseSubmitInfo: PropTypes.shape({
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 @@ -161,6 +161,7 @@ describe('EditCoursePage', () => {
skill_names: [],
organization_logo_override_url: 'http://image.src.small',
organization_short_code_override: 'test short code',
watchers: [],
location_restriction: {
restriction_type: 'allowlist',
countries: [
Expand Down Expand Up @@ -426,6 +427,7 @@ describe('EditCoursePage', () => {
},
organization_logo_override: 'http://image.src.small',
organization_short_code_override: 'test short code',
watchers: [],
outcome: '<p>Stuff</p>',
prerequisites_raw: '',
prices: {
Expand Down Expand Up @@ -967,6 +969,7 @@ describe('EditCoursePage', () => {
},
organization_logo_override: 'http://image.src.small',
organization_short_code_override: 'test short code',
watchers: [],
outcome: '<p>Stuff</p>',
prerequisites_raw: '',
prices: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6706,6 +6706,33 @@ exports[`BaseEditCourseForm renders html correctly with administrator being true
requiredHeight={110}
requiredWidth={110}
/>
<Field
component={[Function]}
disabled={true}
extraInput={
Object {
"onInvalid": [Function],
}
}
label={
<FieldLabel
className=""
extraText=""
helpText={
<div>
<p>
A comma-separated list of email addresses that will be notified if the any of the course run of the course is published or scheduled.
</p>
</div>
}
id={null}
optional={true}
text="Watchers"
/>
}
name="watchers"
optional={true}
/>
<FieldLabel
className="mb-2"
extraText=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ exports[`EditCoursePage renders html correctly 1`] = `
"type": undefined,
"url_slug": undefined,
"videoSrc": undefined,
"watchers": undefined,
}
}
onSubmit={[Function]}
Expand Down Expand Up @@ -471,6 +472,7 @@ exports[`EditCoursePage renders page correctly with courseInfo 1`] = `
"image": null,
"src": "https://www.video.information/watch?v=cVsQLlk-T0s",
},
"watchers": Array [],
},
"error": null,
"isFetching": false,
Expand Down Expand Up @@ -693,6 +695,7 @@ exports[`EditCoursePage renders page correctly with courseInfo 1`] = `
"type": "8a8f30e1-23ce-4ed3-a361-1325c656b67b",
"url_slug": undefined,
"videoSrc": "https://www.video.information/watch?v=cVsQLlk-T0s",
"watchers": Array [],
}
}
number="Test101x"
Expand Down Expand Up @@ -975,6 +978,7 @@ exports[`EditCoursePage renders page correctly with courseInfo and courseOptions
"image": null,
"src": "https://www.video.information/watch?v=cVsQLlk-T0s",
},
"watchers": Array [],
},
"error": null,
"isFetching": false,
Expand Down Expand Up @@ -1570,6 +1574,7 @@ exports[`EditCoursePage renders page correctly with courseInfo and courseOptions
"type": "8a8f30e1-23ce-4ed3-a361-1325c656b67b",
"url_slug": undefined,
"videoSrc": "https://www.video.information/watch?v=cVsQLlk-T0s",
"watchers": Array [],
}
}
number="Test101x"
Expand Down Expand Up @@ -1767,6 +1772,7 @@ exports[`EditCoursePage renders page correctly with courseInfo error 1`] = `
"type": undefined,
"url_slug": undefined,
"videoSrc": undefined,
"watchers": undefined,
}
}
onSubmit={[Function]}
Expand Down Expand Up @@ -2070,6 +2076,7 @@ exports[`EditCoursePage renders page correctly with courseInfo, courseOptions, a
"image": null,
"src": "https://www.video.information/watch?v=cVsQLlk-T0s",
},
"watchers": Array [],
},
"error": null,
"isFetching": false,
Expand Down Expand Up @@ -2733,6 +2740,7 @@ exports[`EditCoursePage renders page correctly with courseInfo, courseOptions, a
"type": "8a8f30e1-23ce-4ed3-a361-1325c656b67b",
"url_slug": undefined,
"videoSrc": "https://www.video.information/watch?v=cVsQLlk-T0s",
"watchers": Array [],
}
}
number="Test101x"
Expand Down Expand Up @@ -2946,6 +2954,7 @@ exports[`EditCoursePage renders page correctly with courseInfo, courseOptions, a
"type": undefined,
"url_slug": undefined,
"videoSrc": undefined,
"watchers": undefined,
}
}
onSubmit={[Function]}
Expand Down Expand Up @@ -3537,6 +3546,7 @@ exports[`EditCoursePage renders page correctly with courseOptions 1`] = `
"type": undefined,
"url_slug": undefined,
"videoSrc": undefined,
"watchers": undefined,
}
}
onSubmit={[Function]}
Expand Down Expand Up @@ -3734,6 +3744,7 @@ exports[`EditCoursePage renders page correctly with courseOptions error 1`] = `
"type": undefined,
"url_slug": undefined,
"videoSrc": undefined,
"watchers": undefined,
}
}
onSubmit={[Function]}
Expand Down Expand Up @@ -4016,6 +4027,7 @@ exports[`EditCoursePage renders page correctly with courseRunOptions 1`] = `
"type": undefined,
"url_slug": undefined,
"videoSrc": undefined,
"watchers": undefined,
}
}
onSubmit={[Function]}
Expand Down Expand Up @@ -4213,6 +4225,7 @@ exports[`EditCoursePage renders page correctly with courseRunOptions error 1`] =
"type": undefined,
"url_slug": undefined,
"videoSrc": undefined,
"watchers": undefined,
}
}
onSubmit={[Function]}
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 @@ -370,6 +370,7 @@ class EditCoursePage extends React.Component {
organization_logo_override: courseData.organization_logo_override_url,
organization_short_code_override:
courseData.organization_short_code_override,
watchers: courseData.watchers ? courseData.watchers.split(',') : [],
outcome: courseData.outcome,
prerequisites_raw: courseData.prerequisites_raw,
...priceData,
Expand Down Expand Up @@ -615,6 +616,7 @@ class EditCoursePage extends React.Component {
enterprise_subscription_inclusion,
organization_short_code_override,
organization_logo_override_url,
watchers,
},
},
} = this.props;
Expand Down Expand Up @@ -657,6 +659,7 @@ class EditCoursePage extends React.Component {
enterprise_subscription_inclusion,
organization_short_code_override,
organization_logo_override_url,
watchers,
location_restriction: this.buildLocationRestriction(),
in_year_value: this.buildInYearValue(),
tags: topics?.length ? topics.map(t => ({ label: t, value: t })) : null,
Expand Down