From b0dfc8fc6be8436831fcce780c4dd033baef6bea Mon Sep 17 00:00:00 2001 From: nscuro Date: Wed, 29 Jan 2025 12:41:36 +0100 Subject: [PATCH] Fix loss of permission selection for managed users when switching pages Additionally, when multiple permissions are selected, applies them serially, rather than in parallel. This is necessary because the UI is updated based on the response to each update, which caused the UI to only show partial changes before. There are many more places where a similar fix is needed. Partially addresses https://github.com/DependencyTrack/hyades/issues/1651 Signed-off-by: nscuro --- .../accessmanagement/ManagedUsers.vue | 36 +++++++++++-------- .../SelectPermissionModal.vue | 1 + 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/views/administration/accessmanagement/ManagedUsers.vue b/src/views/administration/accessmanagement/ManagedUsers.vue index 086538a3..4e793d91 100644 --- a/src/views/administration/accessmanagement/ManagedUsers.vue +++ b/src/views/administration/accessmanagement/ManagedUsers.vue @@ -288,25 +288,31 @@ export default { }, updatePermissionSelection: function (selections) { this.$root.$emit('bv::hide::modal', 'selectPermissionModal'); + let updatePromise = Promise.resolve(); for (let i = 0; i < selections.length; i++) { let selection = selections[i]; let url = `${this.$api.BASE_URL}/${this.$api.URL_PERMISSION}/${selection.name}/user/${this.username}`; - this.axios - .post(url) - .then((response) => { + updatePromise = updatePromise.then((response) => { + if (response && response.data) { this.syncVariables(response.data); - this.$toastr.s(this.$t('message.updated')); - }) - .catch((error) => { - if (error.response.status === 304) { - //this.$toastr.w(this.$t('condition.unsuccessful_action')); - } else { - this.$toastr.w( - this.$t('condition.unsuccessful_action'), - ); - } - }); + } + return this.axios.post(url); + }); } + updatePromise + .then((response) => { + if (response && response.data) { + this.syncVariables(response.data); + } + this.$toastr.s(this.$t('message.updated')); + }) + .catch((error) => { + if (error.response.status === 304) { + //this.$toastr.w(this.$t('condition.unsuccessful_action')); + } else { + this.$toastr.w(this.$t('condition.unsuccessful_action')); + } + }); }, removePermission: function (permission) { let url = `${this.$api.BASE_URL}/${this.$api.URL_PERMISSION}/${permission.name}/user/${this.username}`; @@ -316,7 +322,7 @@ export default { this.syncVariables(response.data); this.$toastr.s(this.$t('message.updated')); }) - .catch((error) => { + .catch(() => { this.$toastr.w(this.$t('condition.unsuccessful_action')); }); }, diff --git a/src/views/administration/accessmanagement/SelectPermissionModal.vue b/src/views/administration/accessmanagement/SelectPermissionModal.vue index d0ed8b59..af05258b 100644 --- a/src/views/administration/accessmanagement/SelectPermissionModal.vue +++ b/src/views/administration/accessmanagement/SelectPermissionModal.vue @@ -66,6 +66,7 @@ export default { queryParamsType: 'pageSize', pageList: '[10, 25, 50, 100]', pageSize: 10, + maintainMetaData: true, icons: { refresh: 'fa-refresh', },