mirror of
https://github.com/ansible/awx.git
synced 2026-01-22 06:58:06 -03:30
Show instance groups tab if user is an Org Admin
This commit is contained in:
parent
e4ffdeb0b5
commit
b9427ecf6d
@ -1,6 +1,6 @@
|
||||
const templateUrl = require('~components/layout/layout.partial.html');
|
||||
|
||||
function AtLayoutController ($scope, strings, $transitions) {
|
||||
function AtLayoutController ($scope, $http, strings, ProcessErrors, $transitions) {
|
||||
const vm = this || {};
|
||||
|
||||
$transitions.onSuccess({}, (transition) => {
|
||||
@ -9,10 +9,14 @@ function AtLayoutController ($scope, strings, $transitions) {
|
||||
|
||||
$scope.$watch('$root.current_user', (val) => {
|
||||
vm.isLoggedIn = val && val.username;
|
||||
if (val) {
|
||||
if (!_.isEmpty(val)) {
|
||||
vm.isSuperUser = $scope.$root.user_is_superuser || $scope.$root.user_is_system_auditor;
|
||||
vm.currentUsername = val.username;
|
||||
vm.currentUserId = val.id;
|
||||
|
||||
if (!vm.isSuperUser) {
|
||||
checkOrgAdmin();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -32,9 +36,27 @@ function AtLayoutController ($scope, strings, $transitions) {
|
||||
return strings.get(string);
|
||||
}
|
||||
};
|
||||
|
||||
function checkOrgAdmin () {
|
||||
const usersPath = `/api/v2/users/${vm.currentUserId}/admin_of_organizations/`;
|
||||
$http.get(usersPath)
|
||||
.then(({ data }) => {
|
||||
if (data.count > 0) {
|
||||
vm.isOrgAdmin = true;
|
||||
} else {
|
||||
vm.isOrgAdmin = false;
|
||||
}
|
||||
})
|
||||
.catch(({ data, status }) => {
|
||||
ProcessErrors(null, data, status, null, {
|
||||
hdr: strings.get('error.HEADER'),
|
||||
msg: strings.get('error.CALL', { path: usersPath, action: 'GET', status })
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
AtLayoutController.$inject = ['$scope', 'ComponentsStrings', '$transitions'];
|
||||
AtLayoutController.$inject = ['$scope', '$http', 'ComponentsStrings', 'ProcessErrors', '$transitions'];
|
||||
|
||||
function atLayout () {
|
||||
return {
|
||||
|
||||
@ -85,7 +85,7 @@
|
||||
system-admin-only="true">
|
||||
</at-side-nav-item>
|
||||
<at-side-nav-item icon-class="fa-server" route="instanceGroups" name="INSTANCE_GROUPS"
|
||||
system-admin-only="true">
|
||||
ng-show="$parent.layoutVm.isSuperUser || $parent.layoutVm.isOrgAdmin">
|
||||
</at-side-nav-item>
|
||||
<at-side-nav-item icon-class="fa-cubes" route="applications" name="APPLICATIONS"
|
||||
system-admin-only="true">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user