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

temp: disable price edits if course has a published run #994

Merged
merged 1 commit into from
Dec 20, 2024
Merged
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
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
Loading