@@ -1176,42 +1176,49 @@ $(function () {
11761176 } ) . forEach ( function ( userName , i ) {
11771177 // Loop through the sorted user list and generate the #userList element.
11781178 const user = users [ userName ]
1179-
11801179 const $user = $ ( '<span>' )
11811180
1182- // Check if user is current user.
1183- let me = false
1184- if ( userName === that . userNameFull ) {
1185- me = true
1186- if ( ! that . isRodsAdmin ) {
1187- $user . attr ( 'data-bs-toggle' , 'tooltip' )
1188- $user . attr ( 'data-bs-title' , 'You cannot change your own role or remove yourself from this group' )
1181+ // Check if the user is the current user.
1182+ const isCurrentUser = userName === that . userNameFull
1183+ let actionsDisabled = false
1184+
1185+ // Disable actions on self if not manager or rodsadmin.
1186+ if ( isCurrentUser ) {
1187+ if ( user . access !== 'manager' && ! that . isRodsAdmin ) {
1188+ actionsDisabled = true
1189+ $user . attr ( {
1190+ 'data-bs-toggle' : 'tooltip' ,
1191+ 'data-bs-title' : 'You cannot change your own role or remove yourself from this group'
1192+ } )
11891193 }
11901194 }
11911195
11921196 // Open SRAM invitation.
1193- let invited = false
1194- if ( typeof user . sram !== 'undefined' ) {
1195- invited = true
1196- $user . attr ( 'data-bs-toggle' , 'tooltip' )
1197- $user . attr ( 'data-bs-title' , 'This user has not accepted the SRAM invitation' )
1197+ const invited = typeof user . sram !== 'undefined'
1198+ if ( invited ) {
1199+ $user . attr ( {
1200+ 'data-bs-toggle' : 'tooltip' ,
1201+ 'data-bs-title' : 'This user has not accepted the SRAM invitation'
1202+ } )
11981203 }
11991204
1200- let displayName = userName
1205+ // Determine display name based on zone.
12011206 const nameAndZone = userName . split ( '#' )
1202- // Only display a user's zone if it differs
1203- // from the client's zone.
1204- if ( nameAndZone [ 1 ] === that . zone ) { displayName = nameAndZone [ 0 ] }
1205-
1206- $user . html ( '<a id="user-' + i + '" class="list-group-item list-group-item-action user user-access-' +
1207- user . access + ( ( invited || me ) ? ' disabled' : '' ) + ( me ? ' self' : '' ) + '" data-name="' + userName + '">' +
1208- '<input class="form-check-input" type="checkbox" value=""> <i class="fa-solid ' +
1209- ( invited ? that . accessIcons . invited : that . accessIcons [ user . access ] ) +
1210- '" aria-hidden="true" title="' +
1211- that . accessNames [ user . access ] +
1212- '"></i> ' +
1213- Yoda . htmlEncode ( displayName ) +
1214- '</a>' )
1207+ const displayName = ( nameAndZone [ 1 ] === that . zone ) ? nameAndZone [ 0 ] : userName
1208+
1209+ // Construct the user element with appropriate classes and attributes.
1210+ const userAccessClass = `user-access-${ user . access } `
1211+ const userStatusClass = ( invited || actionsDisabled ) ? 'disabled' : ''
1212+ const selfClass = isCurrentUser ? 'self' : ''
1213+
1214+ $user . html ( `
1215+ <a id="user-${ i } " class="list-group-item list-group-item-action user ${ userAccessClass } ${ userStatusClass } ${ selfClass } " data-name="${ userName } ">
1216+ <input class="form-check-input" type="checkbox" value="">
1217+ <i class="fa-solid ${ invited ? that . accessIcons . invited : that . accessIcons [ user . access ] } " aria-hidden="true" title="${ that . accessNames [ user . access ] } "></i>
1218+ ${ Yoda . htmlEncode ( displayName ) }
1219+ </a>
1220+ ` )
1221+
12151222 $userList . append ( $user )
12161223 } )
12171224
0 commit comments