diff --git a/awx/ui/client/src/inventories/hosts/list/host-list.controller.js b/awx/ui/client/src/inventories/hosts/list/host-list.controller.js index 4f0b6f0b6a..7f89b64e99 100644 --- a/awx/ui/client/src/inventories/hosts/list/host-list.controller.js +++ b/awx/ui/client/src/inventories/hosts/list/host-list.controller.js @@ -115,7 +115,20 @@ function HostsList($scope, HostsList, $rootScope, GetBasePath, }; $scope.smartInventory = function() { - $state.go('inventories.addSmartInventory'); + // Gather up search terms and pass them to the add smart inventory form + let stateParamsCopy = angular.copy($state.params.host_search); + let defaults = _.find($state.$current.path, (step) => { + if(step && step.params && step.params.hasOwnProperty(`host_search`)){ + return step.params.hasOwnProperty(`host_search`); + } + }).params[`host_search`].config.value; + + // Strip defaults out of the state params copy + angular.forEach(Object.keys(defaults), function(value) { + delete stateParamsCopy[value]; + }); + + $state.go('inventories.addSmartInventory', {hostfilter: JSON.stringify(stateParamsCopy)}); }; } diff --git a/awx/ui/client/src/inventories/inventory.list.js b/awx/ui/client/src/inventories/inventory.list.js index fb6bac2a68..557a1a8a9c 100644 --- a/awx/ui/client/src/inventories/inventory.list.js +++ b/awx/ui/client/src/inventories/inventory.list.js @@ -47,7 +47,7 @@ export default ['i18n', function(i18n) { modalColumnClass: 'col-md-11', awToolTip: "{{ inventory.description }}", awTipPlacement: "top" - linkTo: '/#/inventories/{{inventory.id}}' + linkTo: '/#/inventories/basic_inventory/{{inventory.id}}' }, organization: { label: i18n._('Organization'), diff --git a/awx/ui/client/src/inventories/main.js b/awx/ui/client/src/inventories/main.js index d7c93dfc22..0e3532bd2e 100644 --- a/awx/ui/client/src/inventories/main.js +++ b/awx/ui/client/src/inventories/main.js @@ -59,7 +59,7 @@ angular.module('inventory', [ let smartInventoryAdd = stateDefinitions.generateTree({ name: 'inventories.addSmartInventory', // top-most node in the generated tree (will replace this state definition) - url: '/smart_inventory/add', + url: '/smart_inventory/add?hostfilter', modes: ['add'], form: 'SmartInventoryForm', controllers: {