Skip to content

Conversation

nucleogenesis
Copy link
Member

Summary

  • In the apiResource.js file, the logError function expected an error object to have a particular shape - but the error that this issue fixes was getting swallowed up by the errors thrown when the error object in logError wasn't the shape expected. I added some existence checks to ensure errors don't get annihilated.
  • I noticed that refreshing w/ a side panel open would load the page w/ the side panel visible. I added checks in onMounted hooks to redirect to the root page (using the goBack module function) whenever there are no users selected.

This will give the user the ability to refresh the page, which will remove stale data.

References

Fixes #13550

Reviewer guidance

@nucleogenesis nucleogenesis added the P0 - critical Priority: Release blocker or regression label Sep 23, 2025
@github-actions github-actions bot added APP: Facility Re: Facility App (user/class management, facility settings, csv import/export, etc.) DEV: frontend SIZE: small labels Sep 23, 2025
Copy link
Contributor

github-actions bot commented Sep 23, 2025

@pcenov
Copy link
Member

pcenov commented Sep 23, 2025

Hi @nucleogenesis - I confirm that now if I try to enrol a user in an already deleted class then I am seeing the "Sorry! Something went wrong" screen and the user can refresh the page.

Will you be handling the following similar edge cases in a similar manner within the scope of this PR or I should report them separately:

  1. Trying to remove a user from a deleted class results in a success message (which is incorrect as the action was never completed) and consequently clicking the UNDO button results in an error message in the snackbar.:
remove.from.deleted.class.mp4

I would expect to see the generic error page in this case too, allowing me to refresh.

  1. Similarly when assigning coaches to a deleted class the user is stuck at the side panel:
assign.coach.mp4
  1. When creating a new user and attempting to assign or enrol the user in the deleted class there's no indication to the user that this is no longer possible:
create.a.new.user.and.assign.or.enrol.in.class.mp4
  1. Actions performed on an already deleted user:
actions.with.deleted.user.mp4
  1. Attempts to interact with a permanently deleted user:
attempts.to.interact.with.permanently.deleted.user.mp4

Comment on lines 137 to 142
onMounted(() => {
// Answering the question "what happens when we refresh?"
if (props.selectedUsers.size === 0) {
goBack();
}
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just reflecting if we should wait until the component is mounted to do this check? I think we can also prevent the load data API calls like this https://github.com/learningequality/kolibri/pull/13769/files#diff-1004c38374e2196707382df426d82066fb2c3e124faa549273ceff802b59695bR203 if the are no selected users.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your link might be pointing to the wrong place it's just bringing me back to this comment.

I did try it w/out the onMounted hook but it didn't work but if there's a better way I'll apply it here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've ended up moving this into a beforeRouteEnter guard @AlexVelezLl so that should avoid unneeded API calls.

@rtibbles rtibbles self-assigned this Sep 23, 2025
Copy link
Member

@marcellamaki marcellamaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changes you just pushed do seem to simplify things, although having read the code, I'm not sure that I'm the best positioned to be a final approver, since it seems like both @AlexVelezLl and @rtibbles had some concrete recommendations/feedback

createdMemberships.value = newMemberships;
} catch (error) {
showErrorWarning.value = true;
// Why doesn't this ever get run here?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what this comment means?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this lol - it is an artifact of my confusion caused by the errors being swallowed up in the apiResource module 😅

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had far fewer opinions than I thought I would. This is fine to go as long as manual testing of these specific points check out (others will be filed in follow ups).

Copy link
Member

@marcellamaki marcellamaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refresh the page on each of the side panels ✅
Perform the replication steps noted in #13550 and see that when you get a bad-data error there, you are shown the API error page and that when you click "Refresh" you are taken to a fresh users table. ✅

manual testing confirms both of these. I will leave more robust edge case finding to peter in our beta0 :) good to go

Copy link
Member

@AlexVelezLl AlexVelezLl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just flagging that the implementation of the beforeRouteEnter is partially incorrect, because these side panels can also be opened from the new users page. So redirecting them to the main user management page feel a bit weird? It is an edge case though, so will let you decide if this is a blocker or not!

Screenshare.-.2025-09-23.6_29_37.PM.mp4

@AlexVelezLl
Copy link
Member

AlexVelezLl commented Sep 23, 2025

In general I think that it does not makes much sense of having these side panels as route components. IIRC, the reason for having the side panels as route components was to respond to the question of "what happens if the user refresh the page?" and the reason of using routes for displaying the side panels was to keep the side panel open after the user refresh. But in this case this does not apply well because the user selection gets removed when they refresh. And now with this beforeRouteLeave we are basically just removing the reason why we were using routes for displaying the side panels.

Having these side panels coming from different parent routes have made the implementation of the routes definition, the dependencies definition of the components (as all of them are hidden behind the router-view tag), and the close side panel handling a bit more complex, and I think we are not getting anything good from having them as route components.

An option for making it worth could be exploring saving the selected users state in the local storage or route query params, so when the user reloads they keep seeing the side panels with the previously selected users, but I think that this will also add some more complexity to the implementation.

Copy link
Member

@AlexVelezLl AlexVelezLl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a blocking review until we figure out how to proceed regarding the previous review.

@nucleogenesis
Copy link
Member Author

Thanks Alex - I'll definitely apply the changes to ensure the panels all work on the new/removed users pages.

I agree re: the routing - but I may put that into a follow-up issue.

@rtibbles rtibbles assigned AlexVelezLl and unassigned rtibbles Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APP: Facility Re: Facility App (user/class management, facility settings, csv import/export, etc.) DEV: frontend P0 - critical Priority: Release blocker or regression SIZE: small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUM - Error when trying to enroll a learner in an already deleted class
5 participants