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: Adding human readable 403 error access restricted #1569

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
14 changes: 11 additions & 3 deletions src/course-outline/page-alerts/PageAlerts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,18 @@
let errorList = Object.entries(errors).filter(obj => obj[1] !== null).map(([k, v]) => {
switch (v.type) {
case API_ERROR_TYPES.serverError:
let description = v.data || intl.formatMessage(messages.serverErrorAlertBody);

Check failure on line 347 in src/course-outline/page-alerts/PageAlerts.jsx

View workflow job for this annotation

GitHub Actions / tests

Unexpected lexical declaration in case block
let alertTitle = intl.formatMessage(messages.serverErrorAlert);

Check failure on line 348 in src/course-outline/page-alerts/PageAlerts.jsx

View workflow job for this annotation

GitHub Actions / tests

Unexpected lexical declaration in case block
if (v.status === 403) {
description = intl.formatMessage(messages.forbiddenAlertBody, {
LMS: <Hyperlink destination={`${getConfig().LMS_BASE_URL}`} target="_blank" showLaunchIcon={false}>{intl.formatMessage(messages.forbiddenAlertLmsUrl)}</Hyperlink>

Check failure on line 351 in src/course-outline/page-alerts/PageAlerts.jsx

View workflow job for this annotation

GitHub Actions / tests

Missing trailing comma
});
alertTitle = intl.formatMessage(messages.forbiddenAlert);
}
return {
key: k,
desc: v.data || intl.formatMessage(messages.serverErrorAlertBody),
title: intl.formatMessage(messages.serverErrorAlert),
desc: description,
title: alertTitle,
dismissible: v.dismissible,
};
case API_ERROR_TYPES.networkError:
Expand Down Expand Up @@ -378,7 +386,7 @@
dismissError={() => dispatch(dismissError(msgObj.key))}
>
<Alert.Heading>{msgObj.title}</Alert.Heading>
{msgObj.desc && <Truncate lines={2}>{msgObj.desc}</Truncate>}
{msgObj.desc}
</ErrorAlert>
) : (
<Alert
Expand Down
15 changes: 15 additions & 0 deletions src/course-outline/page-alerts/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,21 @@ const messages = defineMessages({
defaultMessage: 'Network error',
description: 'Generic network error alert.',
},
forbiddenAlert: {
id: 'course-authoring.course-outline.page-alert.forbidden.title',
defaultMessage: 'Access Restricted',
description: 'Forbidden(403) alert title',
},
forbiddenAlertBody: {
id: 'course-authoring.course-outline.page-alert.forbidden.body',
defaultMessage: 'It looks like you’re trying to access a page you don’t have permission to view. Contact your admin if you think this is a mistake, or head back to the {LMS}.',
description: 'Forbidden(403) alert body',
},
forbiddenAlertLmsUrl: {
id: 'course-authoring.course-outline.page-alert.lms',
defaultMessage: 'LMS',
description: 'LMS base redirection url',
},
});

export default messages;
Loading