mirror of
https://github.com/ansible/awx.git
synced 2026-03-08 05:01:09 -02:30
remove permissions subview code from applications ui crud
This commit is contained in:
@@ -23,7 +23,6 @@ function AddApplicationsController (models, $state, strings) {
|
|||||||
|
|
||||||
vm.tab = {
|
vm.tab = {
|
||||||
details: { _active: true },
|
details: { _active: true },
|
||||||
permissions: { _disabled: true },
|
|
||||||
users: { _disabled: true }
|
users: { _disabled: true }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,10 @@
|
|||||||
|
|
||||||
<at-tab-group>
|
<at-tab-group>
|
||||||
<at-tab state="vm.tab.details">{{:: vm.strings.get('tab.DETAILS') }}</at-tab>
|
<at-tab state="vm.tab.details">{{:: vm.strings.get('tab.DETAILS') }}</at-tab>
|
||||||
<at-tab state="vm.tab.permissions">{{:: vm.strings.get('tab.PERMISSIONS') }}</at-tab>
|
|
||||||
<at-tab state="vm.tab.users">{{:: vm.strings.get('tab.USERS') }}</at-tab>
|
<at-tab state="vm.tab.users">{{:: vm.strings.get('tab.USERS') }}</at-tab>
|
||||||
</at-tab-group>
|
</at-tab-group>
|
||||||
|
|
||||||
<at-panel-body ng-if="!($state.current.name.includes('permissions') || $state.current.name.includes('users'))">
|
<at-panel-body ng-if="!$state.current.name.includes('users')">
|
||||||
<at-form state="vm.form" autocomplete="off">
|
<at-form state="vm.form" autocomplete="off">
|
||||||
<at-input-text col="4" tab="1" state="vm.form.name"></at-input-text>
|
<at-input-text col="4" tab="1" state="vm.form.name"></at-input-text>
|
||||||
<at-input-text col="4" tab="2" state="vm.form.description"></at-input-text>
|
<at-input-text col="4" tab="2" state="vm.form.description"></at-input-text>
|
||||||
@@ -24,13 +23,7 @@
|
|||||||
</at-form>
|
</at-form>
|
||||||
</at-panel-body>
|
</at-panel-body>
|
||||||
|
|
||||||
<at-panel-body ng-if="$state.current.name.includes('permissions')">
|
|
||||||
<div ui-view="related"></div>
|
|
||||||
</at-panel-body>
|
|
||||||
|
|
||||||
<at-panel-body ng-if="$state.current.name.includes('users')">
|
<at-panel-body ng-if="$state.current.name.includes('users')">
|
||||||
<div ui-view="userList"></div>
|
<div ui-view="userList"></div>
|
||||||
</at-panel-body>
|
</at-panel-body>
|
||||||
</at-panel>
|
</at-panel>
|
||||||
|
|
||||||
<div ng-if="$state.current.name.includes('permissions.add')" ui-view="modal"></div>
|
|
||||||
|
|||||||
@@ -8,13 +8,11 @@ function ApplicationsStrings (BaseString) {
|
|||||||
LIST_BREADCRUMB_LABEL: t.s('APPLICATIONS'),
|
LIST_BREADCRUMB_LABEL: t.s('APPLICATIONS'),
|
||||||
ADD_BREADCRUMB_LABEL: t.s('CREATE APPLICATION'),
|
ADD_BREADCRUMB_LABEL: t.s('CREATE APPLICATION'),
|
||||||
EDIT_BREADCRUMB_LABEL: t.s('EDIT APPLICATION'),
|
EDIT_BREADCRUMB_LABEL: t.s('EDIT APPLICATION'),
|
||||||
USER_LIST_BREADCRUMB_LABEL: t.s('USERS'),
|
USER_LIST_BREADCRUMB_LABEL: t.s('USERS')
|
||||||
PERMISSIONS_BREADCRUMB_LABEL: t.s('PERMISSIONS')
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.tab = {
|
ns.tab = {
|
||||||
DETAILS: t.s('Details'),
|
DETAILS: t.s('Details'),
|
||||||
PERMISSIONS: t.s('Permissions'),
|
|
||||||
USERS: t.s('Users')
|
USERS: t.s('Users')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -29,10 +29,6 @@ function EditApplicationsController (models, $state, strings, $scope) {
|
|||||||
_go: 'applications.edit',
|
_go: 'applications.edit',
|
||||||
_params: { application_id: application.get('id') }
|
_params: { application_id: application.get('id') }
|
||||||
},
|
},
|
||||||
permissions: {
|
|
||||||
_go: 'applications.edit.permissions',
|
|
||||||
_params: { application_id: application.get('id') }
|
|
||||||
},
|
|
||||||
users: {
|
users: {
|
||||||
_go: 'applications.edit.users',
|
_go: 'applications.edit.users',
|
||||||
_params: { application_id: application.get('id') }
|
_params: { application_id: application.get('id') }
|
||||||
@@ -42,22 +38,13 @@ function EditApplicationsController (models, $state, strings, $scope) {
|
|||||||
$scope.$watch('$state.current.name', (value) => {
|
$scope.$watch('$state.current.name', (value) => {
|
||||||
if (/applications.edit.users/.test(value)) {
|
if (/applications.edit.users/.test(value)) {
|
||||||
vm.tab.details._active = false;
|
vm.tab.details._active = false;
|
||||||
vm.tab.permissions._active = false;
|
|
||||||
vm.tab.users._active = true;
|
vm.tab.users._active = true;
|
||||||
} else if (/applications.edit($|\.organization$)/.test(value)) {
|
|
||||||
vm.tab.details._active = true;
|
|
||||||
vm.tab.permissions._active = false;
|
|
||||||
vm.tab.users._active = false;
|
|
||||||
} else {
|
} else {
|
||||||
vm.tab.details._active = false;
|
vm.tab.details._active = true;
|
||||||
vm.tab.permissions._active = true;
|
|
||||||
vm.tab.users._active = false;
|
vm.tab.users._active = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Only exists for permissions compatibility
|
|
||||||
$scope.application_obj = application.get();
|
|
||||||
|
|
||||||
if (isEditable) {
|
if (isEditable) {
|
||||||
vm.form = application.createFormSchema('put', { omit });
|
vm.form = application.createFormSchema('put', { omit });
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -256,170 +256,6 @@ function ApplicationsRun ($stateExtender, strings) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$stateExtender.addState({
|
|
||||||
name: 'applications.edit.permissions',
|
|
||||||
route: '/permissions?{permission_search:queryset}',
|
|
||||||
ncyBreadcrumb: {
|
|
||||||
label: strings.get('state.PERMISSIONS_BREADCRUMB_LABEL'),
|
|
||||||
parent: 'applications.edit'
|
|
||||||
},
|
|
||||||
params: {
|
|
||||||
permission_search: {
|
|
||||||
dynamic: true,
|
|
||||||
squash: '',
|
|
||||||
value: {
|
|
||||||
page_size: '20',
|
|
||||||
order_by: 'username'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
Dataset: ['QuerySet', '$stateParams', (qs, $stateParams) => {
|
|
||||||
const id = $stateParams.application_id;
|
|
||||||
// TODO: no access_list endpoint given by api
|
|
||||||
const path = `api/v2/applications/${id}/access_list/`;
|
|
||||||
|
|
||||||
return qs.search(path, $stateParams.permission_search);
|
|
||||||
}],
|
|
||||||
ListDefinition: () => ({
|
|
||||||
name: 'permissions',
|
|
||||||
disabled: 'organization === undefined',
|
|
||||||
ngClick: 'organization === undefined || $state.go(\'applications.edit.permissions\')',
|
|
||||||
awToolTip: '{{permissionsTooltip}}',
|
|
||||||
dataTipWatch: 'permissionsTooltip',
|
|
||||||
awToolTipTabEnabledInEditMode: true,
|
|
||||||
dataPlacement: 'right',
|
|
||||||
basePath: 'api/v2/applications/{{$stateParams.id}}/access_list/',
|
|
||||||
search: {
|
|
||||||
order_by: 'username'
|
|
||||||
},
|
|
||||||
type: 'collection',
|
|
||||||
title: N_('Permissions'),
|
|
||||||
iterator: 'permission',
|
|
||||||
index: false,
|
|
||||||
open: false,
|
|
||||||
actions: {
|
|
||||||
add: {
|
|
||||||
ngClick: '$state.go(\'.add\')',
|
|
||||||
label: 'Add',
|
|
||||||
awToolTip: N_('Add a permission'),
|
|
||||||
actionClass: 'btn List-buttonSubmit',
|
|
||||||
buttonContent: `+ ${N_('ADD')}`,
|
|
||||||
ngShow: '(application_obj.summary_fields.user_capabilities.edit || canAdd)'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fields: {
|
|
||||||
username: {
|
|
||||||
key: true,
|
|
||||||
label: N_('User'),
|
|
||||||
linkBase: 'users',
|
|
||||||
class: 'col-lg-3 col-md-3 col-sm-3 col-xs-4'
|
|
||||||
},
|
|
||||||
role: {
|
|
||||||
label: N_('Role'),
|
|
||||||
type: 'role',
|
|
||||||
nosort: true,
|
|
||||||
class: 'col-lg-4 col-md-4 col-sm-4 col-xs-4'
|
|
||||||
},
|
|
||||||
team_roles: {
|
|
||||||
label: N_('Team Roles'),
|
|
||||||
type: 'team_roles',
|
|
||||||
nosort: true,
|
|
||||||
class: 'col-lg-5 col-md-5 col-sm-5 col-xs-4'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$stateExtender.addState({
|
|
||||||
name: 'applications.edit.permissions.add',
|
|
||||||
url: '/add-permissions',
|
|
||||||
resolve: {
|
|
||||||
usersDataset: [
|
|
||||||
'addPermissionsUsersList',
|
|
||||||
'QuerySet',
|
|
||||||
'$stateParams',
|
|
||||||
'GetBasePath',
|
|
||||||
'resourceData',
|
|
||||||
(list, qs, $stateParams, GetBasePath, resourceData) => {
|
|
||||||
let path;
|
|
||||||
|
|
||||||
if (resourceData.data.organization) {
|
|
||||||
path = `${GetBasePath('organizations')}${resourceData.data.organization}/users`;
|
|
||||||
} else {
|
|
||||||
path = list.basePath || GetBasePath(list.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return qs.search(path, $stateParams.user_search);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
teamsDataset: [
|
|
||||||
'addPermissionsTeamsList',
|
|
||||||
'QuerySet',
|
|
||||||
'$stateParams',
|
|
||||||
'GetBasePath',
|
|
||||||
'resourceData',
|
|
||||||
(list, qs, $stateParams, GetBasePath, resourceData) => {
|
|
||||||
const path = GetBasePath(list.basePath) || GetBasePath(list.name);
|
|
||||||
const org = resourceData.data.organization;
|
|
||||||
|
|
||||||
if (!org) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$stateParams[`${list.iterator}_search`].organization = org;
|
|
||||||
|
|
||||||
return qs.search(path, $stateParams.team_search);
|
|
||||||
}
|
|
||||||
],
|
|
||||||
resourceData: ['ApplicationModel', '$stateParams', (Application, $stateParams) =>
|
|
||||||
new Application('get', $stateParams.application_id)
|
|
||||||
.then(application => ({ data: application.get() }))
|
|
||||||
]
|
|
||||||
},
|
|
||||||
params: {
|
|
||||||
user_search: {
|
|
||||||
value: {
|
|
||||||
order_by: 'username',
|
|
||||||
page_size: 5,
|
|
||||||
is_superuser: false
|
|
||||||
},
|
|
||||||
dynamic: true
|
|
||||||
},
|
|
||||||
team_search: {
|
|
||||||
value: {
|
|
||||||
order_by: 'name',
|
|
||||||
page_size: 5
|
|
||||||
},
|
|
||||||
dynamic: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ncyBreadcrumb: {
|
|
||||||
skip: true
|
|
||||||
},
|
|
||||||
views: {
|
|
||||||
'modal@applications.edit': {
|
|
||||||
template: `
|
|
||||||
<add-rbac-resource
|
|
||||||
users-dataset='$resolve.usersDataset'
|
|
||||||
teams-dataset='$resolve.teamsDataset'
|
|
||||||
selected='allSelected'
|
|
||||||
resource-data='$resolve.resourceData'
|
|
||||||
without-team-permissions='{{$resolve.resourceData.data.organization ? null : true}}'
|
|
||||||
title='{{$resolve.resourceData.data.organization ? "Add Users / Teams" : "Add Users"}}'>
|
|
||||||
</add-rbac-resource>`
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onExit: $state => {
|
|
||||||
if ($state.transition) {
|
|
||||||
$('#add-permissions-modal').modal('hide');
|
|
||||||
$('.modal-backdrop').remove();
|
|
||||||
$('body').removeClass('modal-open');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$stateExtender.addState({
|
$stateExtender.addState({
|
||||||
name: 'applications.edit.users',
|
name: 'applications.edit.users',
|
||||||
route: '/users',
|
route: '/users',
|
||||||
|
|||||||
Reference in New Issue
Block a user