mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 14:27:42 -02:30
adding org-admin check for projects and teams
This commit is contained in:
@@ -3,7 +3,7 @@ import AddController from './add-credentials.controller';
|
|||||||
import EditController from './edit-credentials.controller';
|
import EditController from './edit-credentials.controller';
|
||||||
import CredentialsStrings from './credentials.strings'
|
import CredentialsStrings from './credentials.strings'
|
||||||
|
|
||||||
function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType, Organization) {
|
function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType, Organization, OrgAdmin) {
|
||||||
let id = $stateParams.credential_id;
|
let id = $stateParams.credential_id;
|
||||||
|
|
||||||
let promises = {
|
let promises = {
|
||||||
@@ -14,6 +14,7 @@ function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType, O
|
|||||||
promises.credential = new Credential('options');
|
promises.credential = new Credential('options');
|
||||||
promises.credentialType = new CredentialType();
|
promises.credentialType = new CredentialType();
|
||||||
promises.organization = new Organization();
|
promises.organization = new Organization();
|
||||||
|
promises.orgAdmin = new OrgAdmin();
|
||||||
|
|
||||||
return $q.all(promises)
|
return $q.all(promises)
|
||||||
}
|
}
|
||||||
@@ -24,16 +25,19 @@ function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType, O
|
|||||||
.then(models => {
|
.then(models => {
|
||||||
let typeId = models.credential.get('credential_type');
|
let typeId = models.credential.get('credential_type');
|
||||||
let orgId = models.credential.get('organization');
|
let orgId = models.credential.get('organization');
|
||||||
|
let userId = models.me.get('results')[0].id;
|
||||||
|
|
||||||
let dependents = {
|
let dependents = {
|
||||||
credentialType: new CredentialType('get', typeId),
|
credentialType: new CredentialType('get', typeId),
|
||||||
organization: new Organization('get', orgId)
|
organization: new Organization('get', orgId),
|
||||||
|
orgAdmin: new OrgAdmin('get', userId)
|
||||||
};
|
};
|
||||||
|
|
||||||
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.is_org_admin = related.orgAdmin;
|
||||||
|
|
||||||
return models;
|
return models;
|
||||||
});
|
});
|
||||||
@@ -46,7 +50,8 @@ CredentialsResolve.$inject = [
|
|||||||
'MeModel',
|
'MeModel',
|
||||||
'CredentialModel',
|
'CredentialModel',
|
||||||
'CredentialTypeModel',
|
'CredentialTypeModel',
|
||||||
'OrganizationModel'
|
'OrganizationModel',
|
||||||
|
'OrgAdminModel'
|
||||||
];
|
];
|
||||||
|
|
||||||
function CredentialsConfig ($stateExtenderProvider, legacyProvider, pathProvider, stringProvider) {
|
function CredentialsConfig ($stateExtenderProvider, legacyProvider, pathProvider, stringProvider) {
|
||||||
|
|||||||
19
awx/ui/client/lib/models/OrgAdmin.js
Normal file
19
awx/ui/client/lib/models/OrgAdmin.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
let BaseModel;
|
||||||
|
|
||||||
|
function OrgAdminModel (method, resource, graft) {
|
||||||
|
BaseModel.call(this, {path: 'users', subPath: 'admin_of_organizations'});
|
||||||
|
|
||||||
|
this.Constructor = OrgAdminModel;
|
||||||
|
|
||||||
|
return this.create(method, resource, graft);
|
||||||
|
}
|
||||||
|
|
||||||
|
function OrgAdminModelLoader (_BaseModel_) {
|
||||||
|
BaseModel = _BaseModel_;
|
||||||
|
|
||||||
|
return OrgAdminModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
OrgAdminModelLoader.$inject = ['BaseModel'];
|
||||||
|
|
||||||
|
export default OrgAdminModelLoader;
|
||||||
@@ -4,6 +4,7 @@ import Credential from './Credential';
|
|||||||
import CredentialType from './CredentialType';
|
import CredentialType from './CredentialType';
|
||||||
import Me from './Me';
|
import Me from './Me';
|
||||||
import Organization from './Organization';
|
import Organization from './Organization';
|
||||||
|
import OrgAdmin from './OrgAdmin';
|
||||||
|
|
||||||
angular
|
angular
|
||||||
.module('at.lib.models', [])
|
.module('at.lib.models', [])
|
||||||
@@ -12,5 +13,5 @@ angular
|
|||||||
.service('CredentialModel', Credential)
|
.service('CredentialModel', Credential)
|
||||||
.service('CredentialTypeModel', CredentialType)
|
.service('CredentialTypeModel', CredentialType)
|
||||||
.service('MeModel', Me)
|
.service('MeModel', Me)
|
||||||
.service('OrganizationModel', Organization);
|
.service('OrganizationModel', Organization)
|
||||||
|
.service('OrgAdminModel', OrgAdmin);
|
||||||
|
|||||||
@@ -8,11 +8,12 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
|
|||||||
'Alert', 'ProcessErrors', 'GenerateForm', 'Prompt',
|
'Alert', 'ProcessErrors', 'GenerateForm', 'Prompt',
|
||||||
'GetBasePath', 'GetProjectPath', 'Authorization', 'GetChoices', 'Empty',
|
'GetBasePath', 'GetProjectPath', 'Authorization', 'GetChoices', 'Empty',
|
||||||
'Wait', 'ProjectUpdate', '$state', 'CreateSelect2', 'ToggleNotification',
|
'Wait', 'ProjectUpdate', '$state', 'CreateSelect2', 'ToggleNotification',
|
||||||
'i18n', 'CredentialTypes',
|
'i18n', 'CredentialTypes', 'OrgAdminLookup',
|
||||||
function($scope, $rootScope, $stateParams, ProjectsForm, Rest, Alert,
|
function($scope, $rootScope, $stateParams, ProjectsForm, Rest, Alert,
|
||||||
ProcessErrors, GenerateForm, Prompt, GetBasePath,
|
ProcessErrors, GenerateForm, Prompt, GetBasePath,
|
||||||
GetProjectPath, Authorization, GetChoices, Empty, Wait, ProjectUpdate,
|
GetProjectPath, Authorization, GetChoices, Empty, Wait, ProjectUpdate,
|
||||||
$state, CreateSelect2, ToggleNotification, i18n, CredentialTypes) {
|
$state, CreateSelect2, ToggleNotification, i18n, CredentialTypes,
|
||||||
|
OrgAdminLookup) {
|
||||||
|
|
||||||
var form = ProjectsForm(),
|
var form = ProjectsForm(),
|
||||||
defaultUrl = GetBasePath('projects') + $stateParams.project_id + '/',
|
defaultUrl = GetBasePath('projects') + $stateParams.project_id + '/',
|
||||||
@@ -141,6 +142,11 @@ export default ['$scope', '$rootScope', '$stateParams', 'ProjectsForm', 'Rest',
|
|||||||
$scope.scm_type_class = "btn-disabled";
|
$scope.scm_type_class = "btn-disabled";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OrgAdminLookup.checkForAdminAccess({organization: data.organization})
|
||||||
|
.then(function(canEditOrg){
|
||||||
|
$scope.canEditOrg = canEditOrg;
|
||||||
|
});
|
||||||
|
|
||||||
$scope.project_obj = data;
|
$scope.project_obj = data;
|
||||||
$scope.name = data.name;
|
$scope.name = data.name;
|
||||||
$scope.$emit('projectLoaded');
|
$scope.$emit('projectLoaded');
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
export default ['$scope', '$rootScope', '$stateParams', 'TeamForm', 'Rest',
|
export default ['$scope', '$rootScope', '$stateParams', 'TeamForm', 'Rest',
|
||||||
'ProcessErrors', 'GetBasePath', 'Wait', '$state',
|
'ProcessErrors', 'GetBasePath', 'Wait', '$state', 'OrgAdminLookup',
|
||||||
function($scope, $rootScope, $stateParams, TeamForm, Rest, ProcessErrors,
|
function($scope, $rootScope, $stateParams, TeamForm, Rest, ProcessErrors,
|
||||||
GetBasePath, Wait, $state) {
|
GetBasePath, Wait, $state, OrgAdminLookup) {
|
||||||
|
|
||||||
var form = TeamForm,
|
var form = TeamForm,
|
||||||
id = $stateParams.team_id,
|
id = $stateParams.team_id,
|
||||||
@@ -23,6 +23,11 @@ export default ['$scope', '$rootScope', '$stateParams', 'TeamForm', 'Rest',
|
|||||||
setScopeFields(data);
|
setScopeFields(data);
|
||||||
$scope.organization_name = data.summary_fields.organization.name;
|
$scope.organization_name = data.summary_fields.organization.name;
|
||||||
|
|
||||||
|
OrgAdminLookup.checkForAdminAccess({organization: data.organization})
|
||||||
|
.then(function(canEditOrg){
|
||||||
|
$scope.canEditOrg = canEditOrg;
|
||||||
|
});
|
||||||
|
|
||||||
$scope.team_obj = data;
|
$scope.team_obj = data;
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user