mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
commit
0de88d6566
@ -4,7 +4,7 @@ function atSideNavItemLink (scope, element, attrs, ctrl) {
|
||||
[scope.navVm, scope.layoutVm] = ctrl;
|
||||
}
|
||||
|
||||
function AtSideNavItemController ($state, $scope, strings) {
|
||||
function AtSideNavItemController ($scope, strings) {
|
||||
const vm = this || {};
|
||||
|
||||
$scope.$watch('layoutVm.currentState', current => {
|
||||
@ -21,10 +21,6 @@ function AtSideNavItemController ($state, $scope, strings) {
|
||||
}
|
||||
});
|
||||
|
||||
vm.go = () => {
|
||||
$state.go($scope.route, {}, { reload: true });
|
||||
};
|
||||
|
||||
vm.tooltip = {
|
||||
popover: {
|
||||
text: strings.get(`layout.${$scope.name}`),
|
||||
@ -36,7 +32,7 @@ function AtSideNavItemController ($state, $scope, strings) {
|
||||
};
|
||||
}
|
||||
|
||||
AtSideNavItemController.$inject = ['$state', '$scope', 'ComponentsStrings'];
|
||||
AtSideNavItemController.$inject = ['$scope', 'ComponentsStrings'];
|
||||
|
||||
function atSideNavItem () {
|
||||
return {
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div class="at-Layout-sideNavItem" ng-click="vm.go()" ng-class="{'is-active': vm.isRoute}"
|
||||
<a class="at-Layout-sideNavItem" ui-sref="{{ route }}" ng-class="{'is-active': vm.isRoute}"
|
||||
ng-show="(!systemAdminOnly || layoutVm.isSuperUser) && layoutVm.isLoggedIn &&
|
||||
!layoutVm.licenseIsMissing">
|
||||
<at-popover state="vm.tooltip" ng-if="!navVm.isExpanded"></at-popover>
|
||||
@ -7,4 +7,4 @@
|
||||
<span class="at-Layout-sideNavItemName" ng-show="navVm.isExpanded">
|
||||
{{ layoutVm.getString(name) }}
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
|
@ -25,10 +25,8 @@ angular.module('credentialTypes', [
|
||||
function($stateProvider, stateDefinitionsProvider) {
|
||||
let stateDefinitions = stateDefinitionsProvider.$get();
|
||||
|
||||
$stateProvider.state({
|
||||
name: 'credentialTypes.**',
|
||||
url: '/credential_type',
|
||||
lazyLoad: () => stateDefinitions.generateTree({
|
||||
function generateStateTree() {
|
||||
let credentialTypesTree = stateDefinitions.generateTree({
|
||||
parent: 'credentialTypes',
|
||||
modes: ['add', 'edit'],
|
||||
list: 'CredentialTypesList',
|
||||
@ -45,7 +43,22 @@ angular.module('credentialTypes', [
|
||||
ncyBreadcrumb: {
|
||||
label: N_('CREDENTIAL TYPES')
|
||||
}
|
||||
})
|
||||
});
|
||||
return Promise.all([
|
||||
credentialTypesTree
|
||||
]).then((generated) => {
|
||||
return {
|
||||
states: _.reduce(generated, (result, definition) => {
|
||||
return result.concat(definition.states);
|
||||
}, [])
|
||||
};
|
||||
});
|
||||
}
|
||||
let stateTree = {
|
||||
name: 'credentialTypes.**',
|
||||
url: '/credential_types',
|
||||
lazyLoad: () => generateStateTree()
|
||||
};
|
||||
$stateProvider.state(stateTree);
|
||||
}
|
||||
]);
|
||||
|
@ -25,10 +25,8 @@ angular.module('inventoryScripts', [
|
||||
function($stateProvider, stateDefinitionsProvider) {
|
||||
let stateDefinitions = stateDefinitionsProvider.$get();
|
||||
|
||||
$stateProvider.state({
|
||||
name: 'inventoryScripts.**',
|
||||
url: '/inventory_script',
|
||||
lazyLoad: () => stateDefinitions.generateTree({
|
||||
function generateStateTree() {
|
||||
let inventoryScriptTree = stateDefinitions.generateTree({
|
||||
parent: 'inventoryScripts',
|
||||
modes: ['add', 'edit'],
|
||||
list: 'InventoryScriptsList',
|
||||
@ -66,7 +64,23 @@ angular.module('inventoryScripts', [
|
||||
ncyBreadcrumb: {
|
||||
label: N_('INVENTORY SCRIPTS')
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
return Promise.all([
|
||||
inventoryScriptTree
|
||||
]).then((generated) => {
|
||||
return {
|
||||
states: _.reduce(generated, (result, definition) => {
|
||||
return result.concat(definition.states);
|
||||
}, [])
|
||||
};
|
||||
});
|
||||
}
|
||||
let stateTree = {
|
||||
name: 'inventoryScripts.**',
|
||||
url: '/inventory_scripts',
|
||||
lazyLoad: () => generateStateTree()
|
||||
};
|
||||
$stateProvider.state(stateTree);
|
||||
}
|
||||
]);
|
||||
|
@ -44,13 +44,6 @@ describe('Components | Side Nav Item', () => {
|
||||
expect(SideNavItemCtrl.isRoute).toBe(false);
|
||||
});
|
||||
|
||||
it('go() should call $state.go()', angular.mock.inject((_$state_) => {
|
||||
spyOn(_$state_, 'go');
|
||||
SideNavItemCtrl.go();
|
||||
expect(_$state_.go).toHaveBeenCalled();
|
||||
expect(_$state_.go).toHaveBeenCalledWith('dashboard', jasmine.any(Object), jasmine.any(Object));
|
||||
}));
|
||||
|
||||
it('should load name, icon, and route from scope', () => {
|
||||
expect(SideNavItem.isolateScope().name).toBeDefined();
|
||||
expect(SideNavItem.isolateScope().iconClass).toBeDefined();
|
||||
|
Loading…
Reference in New Issue
Block a user