Skip to content

Commit

Permalink
Fix loss of permission selection for managed users when switching pages
Browse files Browse the repository at this point in the history
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 DependencyTrack/hyades#1651

Signed-off-by: nscuro <[email protected]>
  • Loading branch information
nscuro committed Jan 29, 2025
1 parent 3c11136 commit b0dfc8f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/views/administration/accessmanagement/ManagedUsers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand All @@ -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'));
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default {
queryParamsType: 'pageSize',
pageList: '[10, 25, 50, 100]',
pageSize: 10,
maintainMetaData: true,
icons: {
refresh: 'fa-refresh',
},
Expand Down

0 comments on commit b0dfc8f

Please sign in to comment.