Skip to content

Commit 625ac49

Browse files
claudisa-uulwesterhof
authored andcommitted
YDA-6552: make error message more informative if user already has role
1 parent 41fec3a commit 625ac49

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

group_manager/static/group_manager/js/group_manager.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -539,27 +539,32 @@ async function processUserroleChange (row, newRole, groupName) {
539539
// Set the internal administration with latest situation without having to reach for the dbs
540540
Yoda.groupManager.groups[groupName].members[userName].access = newRole
541541

542-
// when update-done length is equal to active length, all has been dealt with.
543-
// => Data must be reloaded
544-
if ($('#user-list .active').length === $('#user-list .update-done').length) {
545-
// Force-regenerate the user list after completion of the entire process
546-
Yoda.groupManager.deselectGroup()
547-
Yoda.groupManager.selectGroup(groupName)
548-
549-
Yoda.set_message('success', 'User roles were updated successfully.')
550-
}
542+
Yoda.set_message('success', `Roles for user ${userName.split('#')[0]} were updated successfully.`)
551543
} else {
552544
// Something went wrong
553545
$('#user-list .user.update-pending[data-name="' + Yoda.escapeQuotes(userName) + '"]')
554546
.removeClass('update-pending disabled')
555547
.attr('title', '')
556548

549+
// Row that failed should be removed from active
550+
row.removeClass('active')
551+
557552
// Handle error
558-
const errorMessage = result.message ||
553+
const errorMessage = result.message || result.status_info ||
559554
'Error: Could not change the role for the selected member due to an internal error.\n' +
560555
'Please contact a Yoda administrator'
561-
window.alert(errorMessage)
556+
Yoda.set_message('error', errorMessage)
562557
}
558+
559+
// When number of selected rows is equal to number of successfully updated rows, all has been dealt with.
560+
// => Data must be reloaded
561+
if ($('#user-list .active').length === $('#user-list .update-done').length) {
562+
// Force-regenerate the user list after completion of the entire process
563+
Yoda.groupManager.deselectGroup()
564+
Yoda.groupManager.selectGroup(groupName)
565+
}
566+
567+
document.querySelector('.alert').scrollIntoView({ behavior: 'smooth' })
563568
}
564569

565570
async function removeUserFromGroup (row, groupName) {

0 commit comments

Comments
 (0)