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: hide 2U specific fields #797

Closed
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NODE_ENV='production'
IDENTIFIER_2U='2U'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename this as well, and remove the "2U" default setting which does not make sense for all use cases.

Suggested change
IDENTIFIER_2U='2U'
COURSE_TYPE_FILTER=''

BASE_URL=null
LMS_BASE_URL=null
STUDIO_BASE_URL=null
Expand Down
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NODE_ENV='development'
IDENTIFIER_2U='2U'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
IDENTIFIER_2U='2U'
COURSE_TYPE_FILTER=''

PORT=18400
BASE_URL='localhost:18400'
LMS_BASE_URL='http://localhost:18000'
Expand Down
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico
SITE_NAME='edX'
IDENTIFIER_2U='2U'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
IDENTIFIER_2U='2U'
COURSE_TYPE_FILTER=''

64 changes: 37 additions & 27 deletions src/components/EditCoursePage/EditCourseForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import { Link } from 'react-router-dom';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { getConfig } from '@edx/frontend-platform';
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
import { Icon, Hyperlink, Chip } from '@edx/paragon';
import { CloseSmall } from '@edx/paragon/icons';
Expand Down Expand Up @@ -226,6 +227,10 @@ export class BaseEditCourseForm extends React.Component {
this.setCollapsible(true);
}

filterCourseTypes2U(courseType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove "2U" from the object and parameter names we can avoid confusion in the future, making this a truly generic feature.

Suggested change
filterCourseTypes2U(courseType) {
filterCourseTypes(courseType) {

return courseType.label.includes(getConfig().IDENTIFIER_2U);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return courseType.label.includes(getConfig().IDENTIFIER_2U);
return courseType.label.includes(getConfig().COURSE_TYPE_FILTER);

}

render() {
const {
handleSubmit,
Expand Down Expand Up @@ -306,6 +311,7 @@ export class BaseEditCourseForm extends React.Component {
priceLabels,
runTypeModes,
} = parsedTypeOptions;
const courseTypes2U = courseTypeOptions.filter(this.filterCourseTypes2U);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const courseTypes2U = courseTypeOptions.filter(this.filterCourseTypes2U);
const courseTypesToFilter = courseTypeOptions.filter(this.filterCourseTypes);

const disabled = courseInReview || !editable;
const showMarketingFields = !currentFormValues.type || !courseTypes[currentFormValues.type]
|| courseTypes[currentFormValues.type].course_run_types.some((crt) => crt.is_marketable);
Expand Down Expand Up @@ -1046,34 +1052,38 @@ export class BaseEditCourseForm extends React.Component {
className="course-skill"
/>
)}
<Field
name="organization_short_code_override"
component={RenderInputTextField}
label={
<FieldLabel text="Organization Short Code Override" optional />
}
extraInput={{ onInvalid: this.openCollapsible }}
disabled={disabled}
optional
/>
<Field
name="organization_logo_override_url"
component={ImageUpload}
label={(
<FieldLabel
id="organization_logo_override.label"
text="Organization Logo Override"
{courseTypes2U?.length > 0 && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{courseTypes2U?.length > 0 && (
{courseTypesToFilter?.length > 0 && (

<>
<Field
name="organization_short_code_override"
component={RenderInputTextField}
label={
<FieldLabel text="Organization Short Code Override" optional />
}
extraInput={{ onInvalid: this.openCollapsible }}
disabled={disabled}
optional
/>
)}
extraInput={{ onInvalid: this.openCollapsible }}
id="organization-logo-override"
className="course-image"
maxImageSizeKilo={256}
requiredWidth={110}
requiredHeight={110}
disabled={disabled}
optional
/>
<Field
name="organization_logo_override_url"
component={ImageUpload}
label={(
<FieldLabel
id="organization_logo_override.label"
text="Organization Logo Override"
/>
)}
extraInput={{ onInvalid: this.openCollapsible }}
id="organization-logo-override"
className="course-image"
maxImageSizeKilo={256}
requiredWidth={110}
requiredHeight={110}
disabled={disabled}
optional
/>
</>
)}
{administrator && (
<>
<FieldLabel text="Merchandising Location Restriction" className="mb-2" />
Expand Down
Loading