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: front-end changes required for EE courses on LP #783

Merged
merged 1 commit into from
Jul 17, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import { EmailSettingsModal } from './email-settings';
import { UnenrollModal } from './unenroll';
import { COURSE_STATUSES, COURSE_PACING, EXECUTIVE_EDUCATION_COURSE_MODES } from '../../../../../constants';
import { EXEC_ED_COURSE_TYPE, PRODUCT_SOURCE_2U } from '../data/constants';

const BADGE_PROPS_BY_COURSE_STATUS = {
[COURSE_STATUSES.inProgress]: {
Expand Down Expand Up @@ -50,12 +51,12 @@

getDropdownMenuItems = () => {
const {
hasEmailsEnabled, title, dropdownMenuItems, canUnenroll,
hasEmailsEnabled, title, dropdownMenuItems, canUnenroll, courseType, productSource,
} = this.props;
const firstMenuItems = [];
const lastMenuItems = [];

if (hasEmailsEnabled !== null) {
if (hasEmailsEnabled !== null && (productSource !== PRODUCT_SOURCE_2U && courseType !== EXEC_ED_COURSE_TYPE)) {
firstMenuItems.push({
key: 'email-settings',
type: 'button',
Expand Down Expand Up @@ -124,7 +125,7 @@
if (pacing) {
message += 'This course ';
message += isCourseEnded ? 'was ' : 'is ';
message += `${pacing}-paced. `;
message += `${pacing}-led. `;
}
if (dateMessage) {
message += dateMessage;
Expand Down Expand Up @@ -199,7 +200,7 @@

renderUnenrollModal = () => {
const {
canUnenroll, courseRunId, type,
canUnenroll, courseRunId, type, courseType, productSource,
} = this.props;
const { modals } = this.state;

Expand All @@ -210,6 +211,8 @@
return (
<UnenrollModal
courseRunId={courseRunId}
courseType={courseType}
productSource={productSource}
onClose={this.handleUnenrollModalOnClose}
onSuccess={this.handleUnenrollModalOnSuccess}
isOpen={modals.unenroll.open}
Expand Down Expand Up @@ -241,7 +244,8 @@
};

renderSettingsDropdown = (menuItems) => {
const { title } = this.props;
const { title, courseType, productSource } = this.props;
const execEdClass = courseType === EXEC_ED_COURSE_TYPE && productSource === PRODUCT_SOURCE_2U ? 'text-light-100' : '';
if (menuItems && menuItems.length > 0) {
return (
<div className="ml-auto">
Expand All @@ -252,6 +256,7 @@
iconAs={Icon}
alt={`course settings for ${title}`}
id="course-enrollment-card-settings-dropdown-toggle"
iconClassNames={execEdClass}
/>
<Dropdown.Menu>
{menuItems.map(menuItem => (
Expand Down Expand Up @@ -320,12 +325,24 @@
return null;
};

renderIsCourseStarted = () => {
const { startDate, courseType, productSource } = this.props;
const formattedStartDate = startDate ? moment(startDate).format('MMMM Do, YYYY') : null;

if (courseType === EXEC_ED_COURSE_TYPE && productSource === PRODUCT_SOURCE_2U) {
return <>&#x2022; Start date: {formattedStartDate}</>;
}

return null;

Check warning on line 336 in src/components/dashboard/main-content/course-enrollments/course-cards/BaseCourseCard.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/dashboard/main-content/course-enrollments/course-cards/BaseCourseCard.jsx#L336

Added line #L336 was not covered by tests
};

renderOrganizationName = () => {
const { orgName, mode } = this.props;

const isExecutiveEducation2UCourse = EXECUTIVE_EDUCATION_COURSE_MODES.includes(mode);
const execEdClass = isExecutiveEducation2UCourse ? 'text-light-300' : '';
if (orgName) {
return <p className="mb-0">{orgName} {isExecutiveEducation2UCourse && <>&#x2022; Executive Education</>}</p>;
return <p className={`mb-0 ${execEdClass}`}>{orgName} {isExecutiveEducation2UCourse && <>&#x2022; Executive Education</>} {this.renderIsCourseStarted()}</p>;
}
return null;
};
Expand Down Expand Up @@ -403,7 +420,7 @@
{this.renderMicroMastersTitle()}
<div className="d-flex align-items-start justify-content-between mb-1">
<h4 className="course-title mb-0 mr-2">
<a className={`h3 ${isExecutiveEducation2UCourse && 'text-light-100'}`} href={linkToCourse}>{title}</a>
<a className={`h3 ${isExecutiveEducation2UCourse && 'text-white'}`} href={linkToCourse}>{title}</a>
</h4>
{
BADGE_PROPS_BY_COURSE_STATUS[type] && (
Expand All @@ -421,7 +438,7 @@
{this.renderButtons()}
{this.renderChildren()}
<div className="course-misc-text row">
<div className={`col ${isExecutiveEducation2UCourse ? 'text-light-900' : 'text-gray' }`}>
<div className={`col ${isExecutiveEducation2UCourse ? 'text-light-300' : 'text-gray'}`}>
<small className="mb-0">
{this.getCourseMiscText()}
</small>
Expand All @@ -448,6 +465,8 @@
buttons: PropTypes.element,
children: PropTypes.node,
startDate: PropTypes.string,
courseType: PropTypes.string,
productSource: PropTypes.string,
endDate: PropTypes.string,
hasEmailsEnabled: PropTypes.bool,
canUnenroll: PropTypes.bool,
Expand All @@ -469,6 +488,8 @@
BaseCourseCard.defaultProps = {
children: null,
startDate: null,
courseType: null,
productSource: null,
endDate: null,
hasEmailsEnabled: null,
canUnenroll: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ const CompletedCourseCard = (props) => {
title,
linkToCourse,
courseRunId,
startDate,
endDate,
courseType,
productSource,
} = props;
const config = getConfig();

Expand All @@ -30,6 +33,9 @@ const CompletedCourseCard = (props) => {
linkToCourse={linkToCourse}
title={title}
courseRunId={courseRunId}
courseType={courseType}
productSource={productSource}
startDate={startDate}
/>
);
};
Expand Down Expand Up @@ -64,6 +70,9 @@ const CompletedCourseCard = (props) => {
buttons={renderButtons()}
type="completed"
hasViewCertificateLink={false}
courseType={courseType}
productSource={productSource}
startDate={startDate}
{...props}
>
{renderCertificateInfo()}
Expand All @@ -78,11 +87,17 @@ CompletedCourseCard.propTypes = {
linkToCertificate: PropTypes.string,
courseRunStatus: PropTypes.string.isRequired,
endDate: PropTypes.string,
startDate: PropTypes.string,
courseType: PropTypes.string,
productSource: PropTypes.string,
};

CompletedCourseCard.defaultProps = {
linkToCertificate: null,
endDate: null,
startDate: null,
courseType: null,
productSource: null,
};

export default CompletedCourseCard;
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import classNames from 'classnames';

import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils';
import moment from 'moment';
import { EXEC_ED_COURSE_TYPE, PRODUCT_SOURCE_2U } from '../data/constants';

/**
* A 'Continue Learning' button with parameters.
Expand All @@ -20,6 +22,9 @@
linkToCourse,
title,
courseRunId,
courseType,
productSource,
startDate,
}) => {
const { enterpriseConfig } = useContext(AppContext);

Expand All @@ -32,27 +37,46 @@
},
);
};

const isCourseStarted = () => moment(startDate) <= moment();

const execClassName = (courseType === EXEC_ED_COURSE_TYPE && productSource === PRODUCT_SOURCE_2U) && (!isCourseStarted()) ? ' disabled btn-outline-secondary' : undefined;

const renderContent = () => {
if ((courseType === EXEC_ED_COURSE_TYPE && productSource === PRODUCT_SOURCE_2U) && !isCourseStarted()) {
const formattedStartDate = moment(startDate).format('MMM D, YYYY');
return `Available on ${formattedStartDate}`;

Check warning on line 48 in src/components/dashboard/main-content/course-enrollments/course-cards/ContinueLearningButton.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/dashboard/main-content/course-enrollments/course-cards/ContinueLearningButton.jsx#L47-L48

Added lines #L47 - L48 were not covered by tests
}
return 'Resume';
};

return (
<a
className={classNames('btn btn-xs-block', className)}
className={classNames('btn btn-xs-block', execClassName, className)}
href={linkToCourse}
onClick={onClickHandler}
>
Resume
{renderContent()}
<span className="sr-only">for {title}</span>
</a>
);
};

ContinueLearningButton.defaultProps = {
className: 'btn-outline-primary',
startDate: null,
courseType: null,
productSource: null,
};

ContinueLearningButton.propTypes = {
className: PropTypes.string,
linkToCourse: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
courseRunId: PropTypes.string.isRequired,
startDate: PropTypes.string,
courseType: PropTypes.string,
productSource: PropTypes.string,
};

export default ContinueLearningButton;
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export const InProgressCourseCard = ({
title,
notifications,
courseRunStatus,
startDate,
courseType,
productSource,
...rest
}) => {
const {
Expand All @@ -45,6 +48,9 @@ export const InProgressCourseCard = ({
linkToCourse={licenseUpgradeUrl ?? linkToCourse}
title={title}
courseRunId={courseRunId}
courseType={courseType}
productSource={productSource}
startDate={startDate}
/>
{shouldShowUpgradeButton && <UpgradeCourseButton className="ml-1" title={title} />}
</>
Expand Down Expand Up @@ -152,6 +158,9 @@ export const InProgressCourseCard = ({
linkToCourse={licenseUpgradeUrl ?? linkToCourse}
courseRunId={courseRunId}
isLoading={isLoadingUpgradeUrl}
courseType={courseType}
productSource={productSource}
startDate={startDate}
{...rest}
>
{renderNotifications()}
Expand All @@ -177,6 +186,15 @@ InProgressCourseCard.propTypes = {
})).isRequired,
title: PropTypes.string.isRequired,
courseRunStatus: PropTypes.string.isRequired,
startDate: PropTypes.string,
courseType: PropTypes.string,
productSource: PropTypes.string,
};

InProgressCourseCard.defaultProps = {
startDate: null,
courseType: null,
productSource: null,
};

export default InProgressCourseCard;
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ RequestedCourseCard.propTypes = {
isRevoked: PropTypes.bool,
courseRunStatus: PropTypes.string.isRequired,
endDate: PropTypes.string,
startDate: PropTypes.string,
courseType: PropTypes.string,
productSource: PropTypes.string,
};

RequestedCourseCard.defaultProps = {
linkToCertificate: null,
endDate: null,
isRevoked: false,
startDate: null,
courseType: null,
productSource: null,
};

export default RequestedCourseCard;
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const SavedForLaterCourseCard = (props) => {
courseRunStatus,
endDate,
isRevoked,
startDate,
courseType,
productSource,
} = props;
const {
updateCourseEnrollmentStatus,
Expand Down Expand Up @@ -100,6 +103,9 @@ const SavedForLaterCourseCard = (props) => {
linkToCourse={linkToCourse}
title={title}
courseRunId={courseRunId}
courseType={courseType}
productSource={productSource}
startDate={startDate}
/>
);
};
Expand All @@ -110,6 +116,9 @@ const SavedForLaterCourseCard = (props) => {
dropdownMenuItems={getDropdownMenuItems()}
type={COURSE_STATUSES.savedForLater}
hasViewCertificateLink={false}
courseType={courseType}
productSource={productSource}
startDate={startDate}
{...props}
>
<MoveToInProgressModal
Expand All @@ -132,11 +141,17 @@ SavedForLaterCourseCard.propTypes = {
isRevoked: PropTypes.bool.isRequired,
courseRunStatus: PropTypes.string.isRequired,
endDate: PropTypes.string,
startDate: PropTypes.string,
courseType: PropTypes.string,
productSource: PropTypes.string,
};

SavedForLaterCourseCard.defaultProps = {
linkToCertificate: null,
endDate: null,
startDate: null,
courseType: null,
productSource: null,
};

export default SavedForLaterCourseCard;
Loading
Loading