From 1477bbae30441da6b35bb5997588e956ff3c9283 Mon Sep 17 00:00:00 2001 From: mabashian Date: Tue, 20 Nov 2018 14:54:30 -0500 Subject: [PATCH] Fixed error Cannot read property 'type' of undefined in console when selecting a project or inventory node --- .../forms/workflow-node-form.controller.js | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/awx/ui/client/src/templates/workflows/workflow-maker/forms/workflow-node-form.controller.js b/awx/ui/client/src/templates/workflows/workflow-maker/forms/workflow-node-form.controller.js index 3615c227d3..281003d232 100644 --- a/awx/ui/client/src/templates/workflows/workflow-maker/forms/workflow-node-form.controller.js +++ b/awx/ui/client/src/templates/workflows/workflow-maker/forms/workflow-node-form.controller.js @@ -139,32 +139,35 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService }; const getEditNodeHelpMessage = (selectedTemplate) => { - if (selectedTemplate.type === "workflow_job_template") { - if ($scope.workflowJobTemplateObj.inventory) { - if (selectedTemplate.ask_inventory_on_launch) { - return $scope.strings.get('workflow_maker.INVENTORY_WILL_OVERRIDE'); + if (selectedTemplate) { + if (selectedTemplate.type === "workflow_job_template") { + if ($scope.workflowJobTemplateObj.inventory) { + if (selectedTemplate.ask_inventory_on_launch) { + return $scope.strings.get('workflow_maker.INVENTORY_WILL_OVERRIDE'); + } + } + if ($scope.workflowJobTemplateObj.ask_inventory_on_launch) { + if (selectedTemplate.ask_inventory_on_launch) { + return $scope.strings.get('workflow_maker.INVENTORY_PROMPT_WILL_OVERRIDE'); + } } } - if ($scope.workflowJobTemplateObj.ask_inventory_on_launch) { - if (selectedTemplate.ask_inventory_on_launch) { - return $scope.strings.get('workflow_maker.INVENTORY_PROMPT_WILL_OVERRIDE'); + if (selectedTemplate.type === "job_template") { + if ($scope.workflowJobTemplateObj.inventory) { + if (selectedTemplate.ask_inventory_on_launch) { + return $scope.strings.get('workflow_maker.INVENTORY_WILL_OVERRIDE'); + } + return $scope.strings.get('workflow_maker.INVENTORY_WILL_NOT_OVERRIDE'); + } + if ($scope.workflowJobTemplateObj.ask_inventory_on_launch) { + if (selectedTemplate.ask_inventory_on_launch) { + return $scope.strings.get('workflow_maker.INVENTORY_PROMPT_WILL_OVERRIDE'); + } + return $scope.strings.get('workflow_maker.INVENTORY_PROMPT_WILL_NOT_OVERRIDE'); } } } - if (selectedTemplate.type === "job_template") { - if ($scope.workflowJobTemplateObj.inventory) { - if (selectedTemplate.ask_inventory_on_launch) { - return $scope.strings.get('workflow_maker.INVENTORY_WILL_OVERRIDE'); - } - return $scope.strings.get('workflow_maker.INVENTORY_WILL_NOT_OVERRIDE'); - } - if ($scope.workflowJobTemplateObj.ask_inventory_on_launch) { - if (selectedTemplate.ask_inventory_on_launch) { - return $scope.strings.get('workflow_maker.INVENTORY_PROMPT_WILL_OVERRIDE'); - } - return $scope.strings.get('workflow_maker.INVENTORY_PROMPT_WILL_NOT_OVERRIDE'); - } - } + return null; }; @@ -601,7 +604,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService .then(() => { if ($scope.nodeConfig.mode === "edit") { // Make sure that we have the full unified job template object - if (!$scope.nodeConfig.node.fullUnifiedJobTemplateObject && _.get($scope, 'nodeConfig.node.originalNodeObject.summary_fields.unified_job_template.unified_job_type') === 'job') { + if (!$scope.nodeConfig.node.fullUnifiedJobTemplateObject) { // This is a node that we got back from the api with an incomplete // unified job template so we're going to pull down the whole object TemplatesService.getUnifiedJobTemplate($scope.nodeConfig.node.originalNodeObject.summary_fields.unified_job_template.id) @@ -671,7 +674,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService }); $scope.$watchGroup(['wf_maker_templates', 'wf_maker_projects', 'wf_maker_inventory_sources', 'activeTab'], () => { - const unifiedJobTemplateId = _.get($scope, 'nodeConfig.node.fullUnifiedJobTemplateObject.id') || _.get($scope, 'nodeConfig.node.unifiedJobTemplate.id') || null; + const unifiedJobTemplateId = _.get($scope, 'selectedTemplate.id') || null; switch($scope.activeTab) { case 'jobs': $scope.wf_maker_templates.forEach((row, i) => {