Skip to content

Commit

Permalink
feat: update save button state for certificate info (#957)
Browse files Browse the repository at this point in the history
PROD-3419
  • Loading branch information
uzairr authored Apr 3, 2024
1 parent b3f2bb8 commit ad9b6a3
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ exports[`Collapsible Course Run renders correctly variant_id field for external
className="text-primary ml-2"
fade={false}
fixedWidth={false}
flip={null}
flip={false}
icon={
Object {
"icon": Array [
512,
448,
512,
Array [],
"f0c5",
"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z",
"M384 336H192c-8.8 0-16-7.2-16-16V64c0-8.8 7.2-16 16-16l140.1 0L400 115.9V320c0 8.8-7.2 16-16 16zM192 384H384c35.3 0 64-28.7 64-64V115.9c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1H192c-35.3 0-64 28.7-64 64V320c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64V448c0 35.3 28.7 64 64 64H256c35.3 0 64-28.7 64-64V416H272v32c0 8.8-7.2 16-16 16H64c-8.8 0-16-7.2-16-16V192c0-8.8 7.2-16 16-16H96V128H64z",
],
"iconName": "copy",
"prefix": "far",
Expand All @@ -92,6 +92,8 @@ exports[`Collapsible Course Run renders correctly variant_id field for external
shake={false}
size={null}
spin={false}
spinPulse={false}
spinReverse={false}
swapOpacity={false}
symbol={false}
title=""
Expand Down Expand Up @@ -715,15 +717,15 @@ exports[`Collapsible Course Run renders correctly when given a published course
className="text-primary ml-2"
fade={false}
fixedWidth={false}
flip={null}
flip={false}
icon={
Object {
"icon": Array [
512,
448,
512,
Array [],
"f0c5",
"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z",
"M384 336H192c-8.8 0-16-7.2-16-16V64c0-8.8 7.2-16 16-16l140.1 0L400 115.9V320c0 8.8-7.2 16-16 16zM192 384H384c35.3 0 64-28.7 64-64V115.9c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1H192c-35.3 0-64 28.7-64 64V320c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64V448c0 35.3 28.7 64 64 64H256c35.3 0 64-28.7 64-64V416H272v32c0 8.8-7.2 16-16 16H64c-8.8 0-16-7.2-16-16V192c0-8.8 7.2-16 16-16H96V128H64z",
],
"iconName": "copy",
"prefix": "far",
Expand All @@ -740,6 +742,8 @@ exports[`Collapsible Course Run renders correctly when given a published course
shake={false}
size={null}
spin={false}
spinPulse={false}
spinReverse={false}
swapOpacity={false}
symbol={false}
title=""
Expand Down Expand Up @@ -1329,15 +1333,15 @@ exports[`Collapsible Course Run renders correctly when given an unpublished cour
className="text-primary ml-2"
fade={false}
fixedWidth={false}
flip={null}
flip={false}
icon={
Object {
"icon": Array [
512,
448,
512,
Array [],
"f0c5",
"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z",
"M384 336H192c-8.8 0-16-7.2-16-16V64c0-8.8 7.2-16 16-16l140.1 0L400 115.9V320c0 8.8-7.2 16-16 16zM192 384H384c35.3 0 64-28.7 64-64V115.9c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1H192c-35.3 0-64 28.7-64 64V320c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64V448c0 35.3 28.7 64 64 64H256c35.3 0 64-28.7 64-64V416H272v32c0 8.8-7.2 16-16 16H64c-8.8 0-16-7.2-16-16V192c0-8.8 7.2-16 16-16H96V128H64z",
],
"iconName": "copy",
"prefix": "far",
Expand All @@ -1354,6 +1358,8 @@ exports[`Collapsible Course Run renders correctly when given an unpublished cour
shake={false}
size={null}
spin={false}
spinPulse={false}
spinReverse={false}
swapOpacity={false}
symbol={false}
title=""
Expand Down Expand Up @@ -1943,15 +1949,15 @@ exports[`Collapsible Course Run renders correctly when submitting for review 1`]
className="text-primary ml-2"
fade={false}
fixedWidth={false}
flip={null}
flip={false}
icon={
Object {
"icon": Array [
512,
448,
512,
Array [],
"f0c5",
"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z",
"M384 336H192c-8.8 0-16-7.2-16-16V64c0-8.8 7.2-16 16-16l140.1 0L400 115.9V320c0 8.8-7.2 16-16 16zM192 384H384c35.3 0 64-28.7 64-64V115.9c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1H192c-35.3 0-64 28.7-64 64V320c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64V448c0 35.3 28.7 64 64 64H256c35.3 0 64-28.7 64-64V416H272v32c0 8.8-7.2 16-16 16H64c-8.8 0-16-7.2-16-16V192c0-8.8 7.2-16 16-16H96V128H64z",
],
"iconName": "copy",
"prefix": "far",
Expand All @@ -1968,6 +1974,8 @@ exports[`Collapsible Course Run renders correctly when submitting for review 1`]
shake={false}
size={null}
spin={false}
spinPulse={false}
spinReverse={false}
swapOpacity={false}
symbol={false}
title=""
Expand Down Expand Up @@ -2557,15 +2565,15 @@ exports[`Collapsible Course Run renders correctly when submitting for review and
className="text-primary ml-2"
fade={false}
fixedWidth={false}
flip={null}
flip={false}
icon={
Object {
"icon": Array [
512,
448,
512,
Array [],
"f0c5",
"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z",
"M384 336H192c-8.8 0-16-7.2-16-16V64c0-8.8 7.2-16 16-16l140.1 0L400 115.9V320c0 8.8-7.2 16-16 16zM192 384H384c35.3 0 64-28.7 64-64V115.9c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1H192c-35.3 0-64 28.7-64 64V320c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64V448c0 35.3 28.7 64 64 64H256c35.3 0 64-28.7 64-64V416H272v32c0 8.8-7.2 16-16 16H64c-8.8 0-16-7.2-16-16V192c0-8.8 7.2-16 16-16H96V128H64z",
],
"iconName": "copy",
"prefix": "far",
Expand All @@ -2582,6 +2590,8 @@ exports[`Collapsible Course Run renders correctly when submitting for review and
shake={false}
size={null}
spin={false}
spinPulse={false}
spinReverse={false}
swapOpacity={false}
symbol={false}
title=""
Expand Down Expand Up @@ -3171,15 +3181,15 @@ exports[`Collapsible Course Run renders correctly with a course run type 1`] = `
className="text-primary ml-2"
fade={false}
fixedWidth={false}
flip={null}
flip={false}
icon={
Object {
"icon": Array [
512,
448,
512,
Array [],
"f0c5",
"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z",
"M384 336H192c-8.8 0-16-7.2-16-16V64c0-8.8 7.2-16 16-16l140.1 0L400 115.9V320c0 8.8-7.2 16-16 16zM192 384H384c35.3 0 64-28.7 64-64V115.9c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1H192c-35.3 0-64 28.7-64 64V320c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64V448c0 35.3 28.7 64 64 64H256c35.3 0 64-28.7 64-64V416H272v32c0 8.8-7.2 16-16 16H64c-8.8 0-16-7.2-16-16V192c0-8.8 7.2-16 16-16H96V128H64z",
],
"iconName": "copy",
"prefix": "far",
Expand All @@ -3196,6 +3206,8 @@ exports[`Collapsible Course Run renders correctly with a course run type 1`] = `
shake={false}
size={null}
spin={false}
spinPulse={false}
spinReverse={false}
swapOpacity={false}
symbol={false}
title=""
Expand Down Expand Up @@ -3797,15 +3809,15 @@ exports[`Collapsible Course Run renders correctly with external key field enable
className="text-primary ml-2"
fade={false}
fixedWidth={false}
flip={null}
flip={false}
icon={
Object {
"icon": Array [
512,
448,
512,
Array [],
"f0c5",
"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z",
"M384 336H192c-8.8 0-16-7.2-16-16V64c0-8.8 7.2-16 16-16l140.1 0L400 115.9V320c0 8.8-7.2 16-16 16zM192 384H384c35.3 0 64-28.7 64-64V115.9c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1H192c-35.3 0-64 28.7-64 64V320c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64V448c0 35.3 28.7 64 64 64H256c35.3 0 64-28.7 64-64V416H272v32c0 8.8-7.2 16-16 16H64c-8.8 0-16-7.2-16-16V192c0-8.8 7.2-16 16-16H96V128H64z",
],
"iconName": "copy",
"prefix": "far",
Expand All @@ -3822,6 +3834,8 @@ exports[`Collapsible Course Run renders correctly with external key field enable
shake={false}
size={null}
spin={false}
spinPulse={false}
spinReverse={false}
swapOpacity={false}
symbol={false}
title=""
Expand Down Expand Up @@ -4447,15 +4461,15 @@ exports[`Collapsible Course Run renders correctly with no fields 1`] = `
className="text-primary ml-2"
fade={false}
fixedWidth={false}
flip={null}
flip={false}
icon={
Object {
"icon": Array [
512,
448,
512,
Array [],
"f0c5",
"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z",
"M384 336H192c-8.8 0-16-7.2-16-16V64c0-8.8 7.2-16 16-16l140.1 0L400 115.9V320c0 8.8-7.2 16-16 16zM192 384H384c35.3 0 64-28.7 64-64V115.9c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1H192c-35.3 0-64 28.7-64 64V320c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64V448c0 35.3 28.7 64 64 64H256c35.3 0 64-28.7 64-64V416H272v32c0 8.8-7.2 16-16 16H64c-8.8 0-16-7.2-16-16V192c0-8.8 7.2-16 16-16H96V128H64z",
],
"iconName": "copy",
"prefix": "far",
Expand All @@ -4472,6 +4486,8 @@ exports[`Collapsible Course Run renders correctly with no fields 1`] = `
shake={false}
size={null}
spin={false}
spinPulse={false}
spinReverse={false}
swapOpacity={false}
symbol={false}
title=""
Expand Down
9 changes: 9 additions & 0 deletions src/data/actions/courseInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function updateFormValuesAfterSave(change, currentFormValues, initialValues) {
4. url_slug: Auto-generated on backend if not provided
5. tags: To maintain ordering returned by the backend
6. in_year_value: each dict key has default backend value which is not read by form unless changed.
7. additional_metadata.certificate_info: exec-ed courses needs it and is not read by form unless changed.
*/
return (dispatch) => {
const {
Expand All @@ -118,6 +119,12 @@ function updateFormValuesAfterSave(change, currentFormValues, initialValues) {
per_click_usa: perClickUSA,
per_click_international: perClicknternational,
},
additional_metadata: {
certificate_info: {
heading,
blurb,
},
},
} = initialValues;

// This emits a redux action called CHANGE that will update:
Expand All @@ -131,6 +138,8 @@ function updateFormValuesAfterSave(change, currentFormValues, initialValues) {
change('in_year_value.per_lead_international', perLeadInternational);
change('in_year_value.per_click_usa', perClickUSA);
change('in_year_value.per_click_international', perClicknternational);
change('additional_metadata.certificate_info.heading', heading);
change('additional_metadata.certificate_info.blurb', blurb);
for (let i = 0; i < initialCourseRuns.length; i += 1) {
change(`course_runs[${i}].status`, initialCourseRuns[i].status);
change(`course_runs[${i}].transcript_languages`, initialCourseRuns[i].transcript_languages);
Expand Down
12 changes: 10 additions & 2 deletions src/data/actions/courseInfo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ describe('courseInfo edit course actions', () => {
per_click_usa: 25,
per_click_international: 30,
},
additional_metadata: {
certificate_info: {
heading: 'Test Certificate',
blurb: 'test blurb',
},
},
imageSrc: 'http://updated.image.src/woo.small',
course_runs: [
{
Expand All @@ -224,8 +230,10 @@ describe('courseInfo edit course actions', () => {
expect(changeMock).toHaveBeenNthCalledWith(8, 'in_year_value.per_lead_international', 20);
expect(changeMock).toHaveBeenNthCalledWith(9, 'in_year_value.per_click_usa', 25);
expect(changeMock).toHaveBeenNthCalledWith(10, 'in_year_value.per_click_international', 30);
expect(changeMock).toHaveBeenNthCalledWith(11, 'course_runs[0].status', 'published');
expect(changeMock).toHaveBeenNthCalledWith(12, 'course_runs[0].transcript_languages', ['en-us']);
expect(changeMock).toHaveBeenNthCalledWith(11, 'additional_metadata.certificate_info.heading', 'Test Certificate');
expect(changeMock).toHaveBeenNthCalledWith(12, 'additional_metadata.certificate_info.blurb', 'test blurb');
expect(changeMock).toHaveBeenNthCalledWith(13, 'course_runs[0].status', 'published');
expect(changeMock).toHaveBeenNthCalledWith(14, 'course_runs[0].transcript_languages', ['en-us']);
});
});

Expand Down

0 comments on commit ad9b6a3

Please sign in to comment.