Skip to content

Commit

Permalink
fixup! feat: Adding human readable 403 error access restricted
Browse files Browse the repository at this point in the history
  • Loading branch information
farhaanbukhsh committed Dec 13, 2024
1 parent be3ca1e commit 4343567
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/course-outline/page-alerts/PageAlerts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,20 @@ const PageAlerts = ({
const renderApiErrors = () => {
let errorList = Object.entries(errors).filter(obj => obj[1] !== null).map(([k, v]) => {
switch (v.type) {
case API_ERROR_TYPES.serverError:
case API_ERROR_TYPES.serverError: {
let description = v.data || intl.formatMessage(messages.serverErrorAlertBody);
let alertTitle = intl.formatMessage(messages.serverErrorAlert);
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>
LMS: (
<Hyperlink
destinationdestination={`${getConfig().LMS_BASE_URL}`}
target="_blank"
showLaunchIcon={false}
>
{intl.formatMessage(messages.forbiddenAlertLmsUrl)}
</Hyperlink>
),
});
alertTitle = intl.formatMessage(messages.forbiddenAlert);
}
Expand All @@ -358,6 +366,7 @@ const PageAlerts = ({
title: alertTitle,
dismissible: v.dismissible,
};
}
case API_ERROR_TYPES.networkError:
return {
key: k,
Expand Down Expand Up @@ -386,7 +395,8 @@ const PageAlerts = ({
dismissError={() => dispatch(dismissError(msgObj.key))}
>
<Alert.Heading>{msgObj.title}</Alert.Heading>
{msgObj.desc}
{(typeof msgObj.desc === 'object')
? msgObj.desc : <Truncate lines={2}>{msgObj.desc}</Truncate>}
</ErrorAlert>
) : (
<Alert
Expand Down

0 comments on commit 4343567

Please sign in to comment.