From c14612cd5d590fb72b7b1e74358019df3181ad8c Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Thu, 22 Dec 2016 14:00:13 -0500 Subject: [PATCH] Fixed adhoc command flow --- awx/ui/client/src/inventories/main.js | 57 ++++++++++++++++++- .../inventories/manage/adhoc/adhoc.form.js | 1 - .../select-list-item.directive.js | 2 +- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/awx/ui/client/src/inventories/main.js b/awx/ui/client/src/inventories/main.js index aa2b450332..8505c9b80f 100644 --- a/awx/ui/client/src/inventories/main.js +++ b/awx/ui/client/src/inventories/main.js @@ -25,7 +25,7 @@ angular.module('inventory', [ // This means inventoryManage states will not be registered correctly on page refresh, unless they're registered at the same time as the inventories state tree let stateTree, inventories, addGroup, editGroup, addHost, editHost, - listSchedules, addSchedule, editSchedule, + listSchedules, addSchedule, editSchedule, adhocCredentialLookup, stateDefinitions = stateDefinitionsProvider.$get(), stateExtender = $stateExtenderProvider.$get(); @@ -195,6 +195,60 @@ angular.module('inventory', [ }, }); + adhocCredentialLookup = { + searchPrefix: 'credential', + name: 'inventoryManage.adhoc.credential', + url: '/credential', + data: { + formChildState: true + }, + params: { + credential_search: { + value: { + page_size: '5' + }, + squash: true, + dynamic: true + } + }, + ncyBreadcrumb: { + skip: true + }, + views: { + 'related': { + templateProvider: function(ListDefinition, generateList) { + let list_html = generateList.build({ + mode: 'lookup', + list: ListDefinition, + input_type: 'radio' + }); + return `${list_html}`; + + } + } + }, + resolve: { + ListDefinition: ['CredentialList', function(CredentialList) { + let list = _.cloneDeep(CredentialList); + list.lookupConfirmText = 'SELECT'; + return list; + }], + Dataset: ['ListDefinition', 'QuerySet', '$stateParams', 'GetBasePath', + (list, qs, $stateParams, GetBasePath) => { + let path = GetBasePath(list.name) || GetBasePath(list.basePath); + return qs.search(path, $stateParams[`${list.iterator}_search`]); + } + ] + }, + onExit: function($state) { + if ($state.transition) { + $('#form-modal').modal('hide'); + $('.modal-backdrop').remove(); + $('body').removeClass('modal-open'); + } + }, + }; + return Promise.all([ inventories, addGroup, @@ -210,6 +264,7 @@ angular.module('inventory', [ stateExtender.buildDefinition(copyMoveGroupRoute), stateExtender.buildDefinition(copyMoveHostRoute), stateExtender.buildDefinition(adHocRoute), + stateExtender.buildDefinition(adhocCredentialLookup) ]) }; diff --git a/awx/ui/client/src/inventories/manage/adhoc/adhoc.form.js b/awx/ui/client/src/inventories/manage/adhoc/adhoc.form.js index fbbbd7b6d4..c509da35d3 100644 --- a/awx/ui/client/src/inventories/manage/adhoc/adhoc.form.js +++ b/awx/ui/client/src/inventories/manage/adhoc/adhoc.form.js @@ -64,7 +64,6 @@ export default function() { basePath: 'credentials', sourceModel: 'credential', sourceField: 'name', - ngClick: 'lookUpCredential()', class: 'squeeze', awPopOver: '

Select the credential you want to use when ' + 'accessing the remote hosts to run the command. ' + diff --git a/awx/ui/client/src/shared/multi-select-list/select-list-item.directive.js b/awx/ui/client/src/shared/multi-select-list/select-list-item.directive.js index 068abb1fa7..4867c5e07c 100644 --- a/awx/ui/client/src/shared/multi-select-list/select-list-item.directive.js +++ b/awx/ui/client/src/shared/multi-select-list/select-list-item.directive.js @@ -30,7 +30,7 @@ export default item: '=item' }, require: '^multiSelectList', - template: '', + template: '', link: function(scope, element, attrs, multiSelectList) { scope.decoratedItem = multiSelectList.registerItem(scope.item);