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) { .then(function success(data) {
ctrl.availableUsers = _.orderBy(data.availableUsers, 'Username', 'asc'); ctrl.availableUsers = _.orderBy(data.availableUsers, 'Username', 'asc');
ctrl.availableTeams = _.orderBy(data.availableTeams, 'Name', 'asc');
var availableTeams = _.orderBy(data.availableTeams, 'Name', 'asc'); if (!isAdmin && ctrl.availableTeams.length === 1) {
ctrl.availableTeams = availableTeams; ctrl.formData.AuthorizedTeams = ctrl.availableTeams;
if (!isAdmin && availableTeams.length === 1) {
ctrl.formData.AuthorizedTeams = availableTeams;
} }
return $q.when(ctrl.resourceControl && ResourceControlService.retrieveOwnershipDetails(ctrl.resourceControl)); return $q.when(ctrl.resourceControl && ResourceControlService.retrieveOwnershipDetails(ctrl.resourceControl));
}) })
.then(function success(data) { .then(function success(data) {
if (data) { if (data) {
var authorizedUsers = data.authorizedUsers; const authorizedTeams = !isAdmin && ctrl.availableTeams.length === 1 ? ctrl.availableTeams : data.authorizedTeams;
var authorizedTeams = data.authorizedTeams; const authorizedUsers = !isAdmin && authorizedTeams.length === 1 ? [] : data.authorizedUsers;
setOwnership(ctrl.resourceControl, isAdmin); setOwnership(ctrl.resourceControl, isAdmin);
setAuthorizedUsersAndTeams(authorizedUsers, authorizedTeams); setAuthorizedUsersAndTeams(authorizedUsers, authorizedTeams);
} }

Loading…
Cancel
Save