Skip to content

Commit

Permalink
temp: disable price edits if course has a published run (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
DawoudSheraz authored Dec 20, 2024
1 parent 4a6684f commit fc63106
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/EditCoursePage/EditCourseForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,11 @@ export class BaseEditCourseForm extends React.Component {
disabled={disabled || !!entitlement.sku}
/>
<PriceList
name="course_price_list"
priceLabels={currentFormValues.type ? priceLabels[currentFormValues.type] : {}}
extraInput={{ onInvalid: this.openCollapsible }}
disabled={disabled}
// temp: Disable price updates if one of runs is published.
disabled={courseStatuses.includes(PUBLISHED) || disabled}
required={isSubmittingForReview}
/>
<FieldLabel
Expand Down
21 changes: 21 additions & 0 deletions src/components/EditCoursePage/EditCourseForm.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,27 @@ describe('BaseEditCourseForm', () => {
expect(disabledFields).toHaveLength(1);
});

it('renders with price disabled if course has Published status among status list', () => {
const component = shallow(<BaseEditCourseForm
handleSubmit={() => null}
title={initialValuesFull.title}
initialValues={initialValuesFull}
currentFormValues={initialValuesFull}
number="Test101x"
entitlement={{ sku: 'ABC1234' }}
courseStatuses={[REVIEWED, PUBLISHED]}
courseInfo={courseInfo}
courseOptions={courseOptions}
courseRunOptions={courseRunOptions}
uuid={initialValuesFull.uuid}
type={initialValuesFull.type}
id="edit-course-form"
/>);

const disabledFields = component.find({ name: 'course_price_list', disabled: true });
expect(disabledFields).toHaveLength(1);
});

it('Check if watchers field is disabled after being reviewed', () => {
const courseInfoWithCourseRunStatuses = {
...courseInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ exports[`BaseEditCourseForm override slug format when IS_NEW_SLUG_FORMAT_ENABLED
"onInvalid": [Function],
}
}
name="course_price_list"
priceLabels={
{
"verified": "Verified",
Expand Down Expand Up @@ -2183,6 +2184,7 @@ exports[`BaseEditCourseForm renders correctly when submitting for review 1`] = `
"onInvalid": [Function],
}
}
name="course_price_list"
priceLabels={
{
"verified": "Verified",
Expand Down Expand Up @@ -4030,6 +4032,7 @@ exports[`BaseEditCourseForm renders html correctly while fetching collaborator o
"onInvalid": [Function],
}
}
name="course_price_list"
priceLabels={{}}
required={false}
/>
Expand Down Expand Up @@ -5415,6 +5418,7 @@ exports[`BaseEditCourseForm renders html correctly while submitting 1`] = `
"onInvalid": [Function],
}
}
name="course_price_list"
priceLabels={
{
"verified": "Verified",
Expand Down Expand Up @@ -7303,6 +7307,7 @@ exports[`BaseEditCourseForm renders html correctly with administrator being true
"onInvalid": [Function],
}
}
name="course_price_list"
priceLabels={
{
"verified": "Verified",
Expand Down Expand Up @@ -9497,6 +9502,7 @@ exports[`BaseEditCourseForm renders html correctly with all data present 1`] = `
"onInvalid": [Function],
}
}
name="course_price_list"
priceLabels={
{
"verified": "Verified",
Expand Down Expand Up @@ -11385,6 +11391,7 @@ exports[`BaseEditCourseForm renders html correctly with minimal data 1`] = `
"onInvalid": [Function],
}
}
name="course_price_list"
priceLabels={{}}
required={false}
/>
Expand Down Expand Up @@ -12774,6 +12781,7 @@ exports[`BaseEditCourseForm renders html correctly with skills data when skills
"onInvalid": [Function],
}
}
name="course_price_list"
priceLabels={{}}
required={false}
/>
Expand Down
5 changes: 4 additions & 1 deletion src/containers/MainApp/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ import SitewideBanner from '../../components/SitewideBanner';
const MainApp = () => (
<div>
<Header />
{/* Only display the banner if there is content to display. */}
{process.env.SITEWIDE_BANNER_CONTENT && (
<SitewideBanner
message={process.env.SITEWIDE_BANNER_CONTENT || ''}
message={process.env.SITEWIDE_BANNER_CONTENT}
type="warning"
dismissible
cookieName="publisherSiteWideBannerDismissed"
cookieExpiryDays={30}
/>
)}
<main>
<Routes>
<Route path="/course-runs/:courseRunKey" element={<CourseRunRedirectComponent />} />
Expand Down

0 comments on commit fc63106

Please sign in to comment.