mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Update pr based on feedback
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
function EditCredentialsController (models, $state, $scope, strings, componentsStrings) {
|
function EditCredentialsController (models, $state, $scope, strings, componentsStrings) {
|
||||||
const vm = this || {};
|
const vm = this || {};
|
||||||
|
|
||||||
const { me, credential, credentialType, organization } = models;
|
const { me, credential, credentialType, organization, isOrgCredAdmin } = models;
|
||||||
|
|
||||||
const omit = ['user', 'team', 'inputs'];
|
const omit = ['user', 'team', 'inputs'];
|
||||||
const isEditable = credential.isEditable();
|
const isEditable = credential.isEditable();
|
||||||
@@ -43,11 +43,11 @@ function EditCredentialsController (models, $state, $scope, strings, componentsS
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isOrgAdmin = _.some(me.get('related.admin_of_organizations.results'), (org) => org.id === organization.get('id'));
|
const isOrgAdmin = _.some(me.get('related.admin_of_organizations.results'), (org) => org.id === organization.get('id'));
|
||||||
const isOrgCredentialAdmin = organization.search({ role_level: 'credential_admin_role' }).then((data) => data);
|
|
||||||
const isSuperuser = me.get('is_superuser');
|
const isSuperuser = me.get('is_superuser');
|
||||||
const isCurrentAuthor = Boolean(credential.get('summary_fields.created_by.id') === me.get('id'));
|
const isCurrentAuthor = Boolean(credential.get('summary_fields.created_by.id') === me.get('id'));
|
||||||
vm.form.organization._disabled = true;
|
vm.form.organization._disabled = true;
|
||||||
if (isSuperuser || isOrgAdmin || isOrgCredentialAdmin || (credential.get('organization') === null && isCurrentAuthor)) {
|
|
||||||
|
if (isSuperuser || isOrgAdmin || isOrgCredAdmin || (credential.get('organization') === null && isCurrentAuthor)) {
|
||||||
vm.form.organization._disabled = false;
|
vm.form.organization._disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,11 +33,13 @@ function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType, O
|
|||||||
credentialType: new CredentialType('get', typeId),
|
credentialType: new CredentialType('get', typeId),
|
||||||
organization: new Organization('get', orgId)
|
organization: new Organization('get', orgId)
|
||||||
};
|
};
|
||||||
|
dependents.isOrgCredAdmin = dependents.organization.then((org) => org.search({ role_level: 'credential_admin_role' }));
|
||||||
|
|
||||||
return $q.all(dependents)
|
return $q.all(dependents)
|
||||||
.then(related => {
|
.then(related => {
|
||||||
models.credentialType = related.credentialType;
|
models.credentialType = related.credentialType;
|
||||||
models.organization = related.organization;
|
models.organization = related.organization;
|
||||||
|
models.isOrgCredAdmin = related.isOrgCredAdmin;
|
||||||
|
|
||||||
return models;
|
return models;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user