Skip to content

Commit

Permalink
Fixing "access denied" visualization for locked-in students.
Browse files Browse the repository at this point in the history
  • Loading branch information
krulis-martin committed May 21, 2024
1 parent d61146d commit 416675e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
21 changes: 15 additions & 6 deletions src/containers/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import './recodex.css';

library.add(regularIcons, solidIcons, brandIcons);

const someStatusesFailed = (...statuses) =>
const reloadIsRequired = (...statuses) =>
statuses.includes(resourceStatus.FAILED) && !statuses.includes(resourceStatus.PENDING);

class App extends Component {
Expand Down Expand Up @@ -66,27 +66,36 @@ class App extends Component {
constructor() {
super();
this.isRefreshingToken = false;
this.reloadsCount = 0;
}

componentDidMount() {
const hasCustomLoadGroups = pathHasCustomLoadGroups(this.props.location.pathname + this.props.location.search);
this.props.loadAsync(this.props.userId, hasCustomLoadGroups);
this.reloadsCount = 0;
}

componentDidUpdate(prevProps) {
this.checkAuthentication();

const hadCustomLoadGroups = pathHasCustomLoadGroups(prevProps.location.pathname + prevProps.location.search);
const hasCustomLoadGroups = pathHasCustomLoadGroups(this.props.location.pathname + this.props.location.search);

if (this.props.userId !== prevProps.userId || (hadCustomLoadGroups && !hasCustomLoadGroups)) {
this.reloadsCount = 0;
}

if (
this.props.userId !== prevProps.userId ||
(hadCustomLoadGroups && !hasCustomLoadGroups) ||
someStatusesFailed(
this.props.fetchUserStatus,
!pathHasCustomLoadGroups && this.props.fetchManyGroupsStatus,
this.props.fetchManyUserInstancesStatus
)
(this.reloadsCount < 3 &&
reloadIsRequired(
this.props.fetchUserStatus,
!pathHasCustomLoadGroups && this.props.fetchManyGroupsStatus,
this.props.fetchManyUserInstancesStatus
))
) {
this.reloadsCount++;
this.props.loadAsync(this.props.userId, hasCustomLoadGroups);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/EditGroup/EditGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class EditGroup extends Component {
title={<FormattedMessage id="app.editGroup.title" defaultMessage="Change Group Settings" />}>
{group => (
<div>
<GroupNavigation group={group} />
{group.privateData && <GroupNavigation group={group} />}

{!hasOneOfPermissions(group, 'update', 'archive', 'remove', 'relocate') && (
<Row>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/GroupAssignments/GroupAssignments.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class GroupAssignments extends Component {

return (
<div>
<GroupNavigation group={data} emails={studentEmails || null} />
{data.privateData && <GroupNavigation group={data} emails={studentEmails || null} />}

{canLeaveGroup && (
<div className="my-3">
Expand All @@ -183,7 +183,7 @@ class GroupAssignments extends Component {
</Row>
)}

<GroupExamPending {...data} currentUser={currentUser} />
{data.privateData && <GroupExamPending {...data} currentUser={currentUser} />}

{data.organizational && (
<Row>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/GroupExams/GroupExams.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class GroupExams extends Component {
title={<FormattedMessage id="app.groupExams.title" defaultMessage="Group Exam Terms" />}>
{(group, currentUser) => (
<div>
<GroupNavigation group={group} />
{group.privateData && <GroupNavigation group={group} />}

<GroupArchivedWarning {...group} groupsDataAccessor={groupsAccessor} linkFactory={GROUP_EDIT_URI_FACTORY} />

Expand Down
4 changes: 2 additions & 2 deletions src/pages/GroupInfo/GroupInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class GroupInfo extends Component {
failed={<FailedGroupLoading />}>
{(data, currentUser) => (
<div>
<GroupNavigation group={data} />
{data.privateData && <GroupNavigation group={data} />}

{!isAdmin &&
!isSupervisor &&
Expand All @@ -137,7 +137,7 @@ class GroupInfo extends Component {
</div>
)}

<GroupExamPending {...data} currentUser={currentUser} />
{data.privateData && <GroupExamPending {...data} currentUser={currentUser} />}

<GroupArchivedWarning {...data} groupsDataAccessor={groupsAccessor} linkFactory={GROUP_INFO_URI_FACTORY} />

Expand Down
4 changes: 2 additions & 2 deletions src/pages/GroupStudents/GroupStudents.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class GroupStudents extends Component {

return (
<div>
<GroupNavigation group={data} emails={studentEmails || null} />
{data.privateData && <GroupNavigation group={data} emails={studentEmails || null} />}

{canLeaveGroup && (
<div className="my-3">
Expand All @@ -174,7 +174,7 @@ class GroupStudents extends Component {
</Row>
)}

{<GroupExamPending {...data} currentUser={loggedUser} />}
{data.privateData && <GroupExamPending {...data} currentUser={loggedUser} />}

{data.organizational && (
<Row>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/GroupUserSolutions/GroupUserSolutions.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ class GroupUserSolutions extends Component {
}>
{(group, currentUser) => (
<div>
<GroupNavigation group={group} userId={userId} />
{group.privateData && <GroupNavigation group={group} userId={userId} />}

<GroupExamPending {...group} currentUser={currentUser} />
{group.privateData && <GroupExamPending {...group} currentUser={currentUser} />}

<GroupArchivedWarning
{...group}
Expand Down

0 comments on commit 416675e

Please sign in to comment.