diff --git a/awx/ui/client/src/inventories-hosts/inventories/main.js b/awx/ui/client/src/inventories-hosts/inventories/main.js index 4c2e576aba..c22d0ab5c5 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/main.js +++ b/awx/ui/client/src/inventories-hosts/inventories/main.js @@ -33,7 +33,8 @@ import inventoryHosts from './related/hosts/related-host.route'; import smartInventoryHosts from './smart-inventory/smart-inventory-hosts.route'; import inventoriesList from './inventories.route'; import inventoryHostsAdd from './related/hosts/add/host-add.route'; -import inventoryHostsEdit from './related/hosts/edit/host-edit.route'; +import inventoryHostsEdit from './related/hosts/edit/standard-host-edit.route'; +import smartInventoryHostsEdit from './related/hosts/edit/smart-host-edit.route'; import ansibleFactsRoute from '../shared/ansible-facts/ansible-facts.route'; import insightsRoute from './insights/insights.route'; import inventorySourcesCredentialRoute from './related/sources/lookup/sources-lookup-credential.route'; @@ -322,6 +323,7 @@ angular.module('inventory', [ stateExtender.buildDefinition(smartInventoryHosts), stateExtender.buildDefinition(inventoryHostsAdd), stateExtender.buildDefinition(inventoryHostsEdit), + stateExtender.buildDefinition(smartInventoryHostsEdit), stateExtender.buildDefinition(hostNestedGroupsRoute), stateExtender.buildDefinition(inventorySourceListRoute), stateExtender.buildDefinition(inventorySourceAddRoute), diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/edit/smart-host-edit.route.js b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/edit/smart-host-edit.route.js new file mode 100644 index 0000000000..033e6054ca --- /dev/null +++ b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/edit/smart-host-edit.route.js @@ -0,0 +1,29 @@ +export default { + name: "inventories.editSmartInventory.hosts.edit", + url: "/edit/:host_id", + ncyBreadcrumb: { + parent: "inventories.editSmartInventory.hosts", + label: "{{breadcrumb.host_name}}" + }, + views: { + 'hostForm@inventories': { + templateProvider: function(GenerateForm, RelatedHostsFormDefinition) { + let form = _.cloneDeep(RelatedHostsFormDefinition); + form.stateTree = 'inventories.editSmartInventory.hosts'; + delete form.related; + return GenerateForm.buildHTML(form, { + mode: 'edit', + related: false + }); + }, + controller: 'RelatedHostEditController' + } + }, + resolve: { + host: ['$stateParams', 'InventoriesService', function($stateParams, InventoriesService) { + return InventoriesService.getHost($stateParams.smartinventory_id, $stateParams.host_id).then(function(res) { + return res.data.results[0]; + }); + }] + } +}; diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/edit/host-edit.route.js b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/edit/standard-host-edit.route.js similarity index 100% rename from awx/ui/client/src/inventories-hosts/inventories/related/hosts/edit/host-edit.route.js rename to awx/ui/client/src/inventories-hosts/inventories/related/hosts/edit/standard-host-edit.route.js diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js index 81e0de24ed..c19110b627 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/list/host-list.controller.js @@ -89,7 +89,7 @@ export default ['$scope', 'ListDefinition', '$rootScope', 'GetBasePath', $state.go('inventories.edit.hosts.add'); }; $scope.editHost = function(host){ - $state.go('inventories.edit.hosts.edit', {inventory_id: host.inventory_id, host_id: host.id}); + $state.go('.edit', {inventory_id: host.inventory_id, host_id: host.id}); }; $scope.goToInsights = function(host){ $state.go('inventories.edit.hosts.edit.insights', {inventory_id: host.inventory_id, host_id:host.id}); diff --git a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related-host.form.js b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related-host.form.js index 1f11a8fc28..047d7ce456 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related-host.form.js +++ b/awx/ui/client/src/inventories-hosts/inventories/related/hosts/related-host.form.js @@ -37,7 +37,7 @@ function(i18n) { " set by the inventory sync process.") + "

", dataTitle: i18n._('Host Enabled'), - ngDisabled: 'host.has_inventory_sources' + ngDisabled: '!host.summary_fields.user_capabilities.edit || host.has_inventory_sources' } }, fields: { @@ -78,7 +78,8 @@ function(i18n) { '

' + i18n.sprintf(i18n._('View YAML examples at %s'), 'docs.ansible.com') + '

', dataTitle: i18n._('Host Variables'), dataPlacement: 'right', - dataContainer: 'body' + dataContainer: 'body', + ngDisabled: '!(host.summary_fields.user_capabilities.edit || canAdd)' } }, diff --git a/awx/ui/client/src/inventories-hosts/shared/inventories.service.js b/awx/ui/client/src/inventories-hosts/shared/inventories.service.js index ed02ce4cf1..9ca46ba998 100644 --- a/awx/ui/client/src/inventories-hosts/shared/inventories.service.js +++ b/awx/ui/client/src/inventories-hosts/shared/inventories.service.js @@ -69,6 +69,13 @@ return Rest.get() .success(this.success.bind(this)) .error(this.error.bind(this)); + }, + getHost: function(inventoryId, hostId) { + this.url = GetBasePath('inventory') + inventoryId + '/hosts?id=' + hostId; + Rest.setUrl(this.url); + return Rest.get() + .success(this.success.bind(this)) + .error(this.error.bind(this)); } }; }]; diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index c5f067a782..bb0c140b58 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -533,9 +533,13 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += (field.ngDisabled) ? ', "ScheduleToggle--disabled": ' + field.ngDisabled : ''; html += "\}' aw-tool-tip='" + field.awToolTip + "' data-placement='" + field.dataPlacement + "' data-tip-watch='" + field.dataTipWatch + "'>"; + html += "' "; + html += (field.ngDisabled) ? `ng-disabled="${field.ngDisabled}" ` : ""; + html += " class='ScheduleToggle-switch' ng-click='" + field.ngClick + "'>" + i18n._("OFF") + ""; } return html; },