-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [FC-0070] Remove backend redirects (use SPA functionality) (#1372)
Introduces the ability to utilize SPA functionality when the relevant waffle flags are enabled for current MFE pages. When any new MFE page is loaded, a request is made to retrieve the waffle flags. This includes both global waffle flags related to MFE Authoring pages, as well as waffle flags specific to the current course.
- Loading branch information
1 parent
979c69b
commit f9ef00e
Showing
47 changed files
with
983 additions
and
356 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 75 additions & 50 deletions
125
src/course-checklist/ChecklistSection/ChecklistItemBody.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,95 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { injectIntl, intlShape, FormattedMessage } from '@edx/frontend-platform/i18n'; | ||
import { | ||
ActionRow, | ||
Button, | ||
Hyperlink, | ||
Icon, | ||
} from '@openedx/paragon'; | ||
import { Link } from 'react-router-dom'; | ||
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n'; | ||
import { ActionRow, Button, Icon } from '@openedx/paragon'; | ||
import { useSelector } from 'react-redux'; | ||
import { CheckCircle, RadioButtonUnchecked } from '@openedx/paragon/icons'; | ||
import { getConfig } from '@edx/frontend-platform'; | ||
|
||
import { getWaffleFlags } from '../../data/selectors'; | ||
import messages from './messages'; | ||
|
||
const getUpdateLinks = (courseId, waffleFlags) => { | ||
const baseUrl = getConfig().STUDIO_BASE_URL; | ||
const isLegacyGradingUrl = !waffleFlags.useNewGradingPage; | ||
const isLegacyCertificateUrl = !waffleFlags.useNewCertificatesPage; | ||
const isLegacyCourseDatesUrl = !waffleFlags.useNewScheduleDetailsPage; | ||
const isLegacyOutlineUrl = !waffleFlags.useNewCourseOutlinePage; | ||
|
||
return { | ||
welcomeMessage: `/course/${courseId}/course_info`, | ||
gradingPolicy: isLegacyGradingUrl | ||
? `${baseUrl}/settings/grading/${courseId}` : `/course/${courseId}/settings/grading`, | ||
certificate: isLegacyCertificateUrl | ||
? `${baseUrl}/certificates/${courseId}` : `/course/${courseId}/certificates`, | ||
courseDates: isLegacyCourseDatesUrl | ||
? `${baseUrl}/settings/details/${courseId}#schedule` : `/course/${courseId}/settings/details/#schedule`, | ||
proctoringEmail: `${baseUrl}/pages-and-resources/proctoring/settings`, | ||
outline: isLegacyOutlineUrl ? `${baseUrl}/course/${courseId}` : `/course/${courseId}`, | ||
}; | ||
}; | ||
|
||
const ChecklistItemBody = ({ | ||
courseId, | ||
checkId, | ||
isCompleted, | ||
updateLink, | ||
// injected | ||
intl, | ||
}) => ( | ||
<ActionRow> | ||
<div className="mr-3" id={`icon-${checkId}`} data-testid={`icon-${checkId}`}> | ||
{isCompleted ? ( | ||
<Icon | ||
data-testid="completed-icon" | ||
src={CheckCircle} | ||
className="text-success" | ||
style={{ height: '32px', width: '32px' }} | ||
screenReaderText={intl.formatMessage(messages.completedItemLabel)} | ||
/> | ||
) : ( | ||
<Icon | ||
data-testid="uncompleted-icon" | ||
src={RadioButtonUnchecked} | ||
style={{ height: '32px', width: '32px' }} | ||
screenReaderText={intl.formatMessage(messages.uncompletedItemLabel)} | ||
/> | ||
)} | ||
</div> | ||
<div> | ||
<div> | ||
<FormattedMessage {...messages[`${checkId}ShortDescription`]} /> | ||
}) => { | ||
const intl = useIntl(); | ||
const waffleFlags = useSelector(getWaffleFlags); | ||
const updateLinks = getUpdateLinks(courseId, waffleFlags); | ||
|
||
return ( | ||
<ActionRow> | ||
<div className="mr-3" id={`icon-${checkId}`} data-testid={`icon-${checkId}`}> | ||
{isCompleted ? ( | ||
<Icon | ||
data-testid="completed-icon" | ||
src={CheckCircle} | ||
className="text-success" | ||
style={{ height: '32px', width: '32px' }} | ||
screenReaderText={intl.formatMessage(messages.completedItemLabel)} | ||
/> | ||
) : ( | ||
<Icon | ||
data-testid="uncompleted-icon" | ||
src={RadioButtonUnchecked} | ||
style={{ height: '32px', width: '32px' }} | ||
screenReaderText={intl.formatMessage(messages.uncompletedItemLabel)} | ||
/> | ||
)} | ||
</div> | ||
<div className="small"> | ||
<FormattedMessage {...messages[`${checkId}LongDescription`]} /> | ||
<div> | ||
<div> | ||
<FormattedMessage {...messages[`${checkId}ShortDescription`]} /> | ||
</div> | ||
<div className="small"> | ||
<FormattedMessage {...messages[`${checkId}LongDescription`]} /> | ||
</div> | ||
</div> | ||
</div> | ||
<ActionRow.Spacer /> | ||
{updateLink && ( | ||
<Hyperlink destination={updateLink} data-testid="update-hyperlink"> | ||
<Button size="sm"> | ||
<FormattedMessage {...messages.updateLinkLabel} /> | ||
</Button> | ||
</Hyperlink> | ||
)} | ||
</ActionRow> | ||
); | ||
<ActionRow.Spacer /> | ||
{updateLinks?.[checkId] && ( | ||
<Link | ||
to={updateLinks[checkId]} | ||
data-testid="update-link" | ||
> | ||
<Button size="sm"> | ||
<FormattedMessage {...messages.updateLinkLabel} /> | ||
</Button> | ||
</Link> | ||
)} | ||
</ActionRow> | ||
); | ||
}; | ||
|
||
ChecklistItemBody.defaultProps = { | ||
updateLink: null, | ||
}; | ||
|
||
ChecklistItemBody.propTypes = { | ||
courseId: PropTypes.string.isRequired, | ||
checkId: PropTypes.string.isRequired, | ||
isCompleted: PropTypes.bool.isRequired, | ||
updateLink: PropTypes.string, | ||
// injected | ||
intl: intlShape.isRequired, | ||
}; | ||
|
||
export default injectIntl(ChecklistItemBody); | ||
export default ChecklistItemBody; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.