-
Notifications
You must be signed in to change notification settings - Fork 831
[Bulk User]: Handle bad-data errors w/ handleApiError (+ better side panel refresh handling)
#13769
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
Changes from 6 commits
5e7bafd
e353b29
08bca7f
627600e
6a89e60
1316f1e
f82d020
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,6 +128,7 @@ | |
| import { UserKinds } from 'kolibri/constants'; | ||
| import groupBy from 'lodash/groupBy'; | ||
| import { useGoBack } from 'kolibri-common/composables/usePreviousRoute'; | ||
| import { PageNames } from '../../../constants.js'; | ||
| import SelectableList from '../../common/SelectableList.vue'; | ||
| import { getRootRouteName, overrideRoute } from '../../../utils'; | ||
| import useActionWithUndo from '../../../composables/useActionWithUndo'; | ||
|
|
@@ -267,14 +268,20 @@ | |
| kind: UserKinds.COACH, | ||
| })) | ||
| : []; | ||
| await Promise.all([ | ||
| enrollments.length | ||
| ? MembershipResource.saveCollection({ data: enrollments }) | ||
| : Promise.resolve(), | ||
| assignments.length | ||
| ? RoleResource.saveCollection({ data: assignments }) | ||
| : Promise.resolve(), | ||
| ]); | ||
| try { | ||
| await Promise.all([ | ||
| enrollments.length | ||
| ? MembershipResource.saveCollection({ data: enrollments }) | ||
| : Promise.resolve(), | ||
| assignments.length | ||
| ? RoleResource.saveCollection({ data: assignments }) | ||
| : Promise.resolve(), | ||
| ]); | ||
| } catch (_) { | ||
| showErrorWarning.value = true; | ||
| } finally { | ||
| loading.value = false; | ||
| } | ||
|
Comment on lines
275
to
286
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pushed a change using a Snackbar - great catch Alex thank you! |
||
| props.onChange({ | ||
| affectedClasses: selectedOptions.value, | ||
| resetSelection: true, | ||
|
|
@@ -379,6 +386,19 @@ | |
| default: () => {}, | ||
| }, | ||
| }, | ||
| beforeRouteEnter(to, from, next) { | ||
| // We can't land here without having navigated to here from the users root page - we can't | ||
| // have selected any users if we load into this page, so go to the users table. | ||
| if (from.name === null) { | ||
| next( | ||
| // Override to to keep params like facility_id in place | ||
| overrideRoute(to, { | ||
| name: PageNames.USER_MGMT_PAGE, | ||
| }), | ||
| ); | ||
| } | ||
| next(); | ||
| }, | ||
| beforeRouteLeave(to, from, next) { | ||
| this.$refs.closeConfirmationGuardRef?.beforeRouteLeave(to, from, next); | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this specific side panel have a different error handling on its main action? The other side panels handle this by setting
showErrorWarningto true.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understood the issue Peter reported was that the error warning was unhelpful in this case because knowing something went wrong is half the battle - the other issue is that the most likely solution is to refresh the page & try again so dispatching the API error here ensures that happens.
To be honest, though, I think a more robust errors reporting would be ideal here to let the user know specifically what actually happened (ie, "The class you selected 'Class Name' no longer exists"). I'll think on this a bit more when I spin this up again in a bit. Thanks Alex