fix(UAC): put team into resource control when editing as team lead [EE-4457] (#7886)

* fix(UAC): put team into resource control when editing as team lead [EE-4457]

* populate form values & payload correctly
pull/7899/head
itsconquest 2 years ago committed by GitHub
parent c1f94be9b2
commit 16dc66f173
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -71,19 +71,16 @@ angular.module('portainer.app').controller('porAccessControlFormController', [
})
.then(function success(data) {
ctrl.availableUsers = _.orderBy(data.availableUsers, 'Username', 'asc');
var availableTeams = _.orderBy(data.availableTeams, 'Name', 'asc');
ctrl.availableTeams = availableTeams;
if (!isAdmin && availableTeams.length === 1) {
ctrl.formData.AuthorizedTeams = availableTeams;
ctrl.availableTeams = _.orderBy(data.availableTeams, 'Name', 'asc');
if (!isAdmin && ctrl.availableTeams.length === 1) {
ctrl.formData.AuthorizedTeams = ctrl.availableTeams;
}
return $q.when(ctrl.resourceControl && ResourceControlService.retrieveOwnershipDetails(ctrl.resourceControl));
})
.then(function success(data) {
if (data) {
var authorizedUsers = data.authorizedUsers;
var authorizedTeams = data.authorizedTeams;
const authorizedTeams = !isAdmin && ctrl.availableTeams.length === 1 ? ctrl.availableTeams : data.authorizedTeams;
const authorizedUsers = !isAdmin && authorizedTeams.length === 1 ? [] : data.authorizedUsers;
setOwnership(ctrl.resourceControl, isAdmin);
setAuthorizedUsersAndTeams(authorizedUsers, authorizedTeams);
}

Loading…
Cancel
Save