From 2c3549331c631683bef1fe5b27ac60f8206bc557 Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 6 Feb 2019 10:26:51 -0500 Subject: [PATCH] Adds proper error handling to worklfow save related promises. Fixes bug watching for prompt changes after the node has been edited once. --- .../forms/workflow-node-form.controller.js | 1 + .../workflow-maker.controller.js | 32 ++++++++++++++++--- 2 files changed, 28 insertions(+), 5 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 067842abe2..82ad803ded 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 @@ -221,6 +221,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService $scope.promptModalMissingReqFields = false; } } + watchForPromptChanges(); $scope.nodeFormDataLoaded = true; } else if ( _.get($scope, 'nodeConfig.node.fullUnifiedJobTemplateObject.unified_job_type') === 'job_template' || diff --git a/awx/ui/client/src/templates/workflows/workflow-maker/workflow-maker.controller.js b/awx/ui/client/src/templates/workflows/workflow-maker/workflow-maker.controller.js index 2ffc6fc18a..6cbb176847 100644 --- a/awx/ui/client/src/templates/workflows/workflow-maker/workflow-maker.controller.js +++ b/awx/ui/client/src/templates/workflows/workflow-maker/workflow-maker.controller.js @@ -5,12 +5,12 @@ *************************************************/ export default ['$scope', 'TemplatesService', - 'ProcessErrors', 'CreateSelect2', '$q', 'JobTemplateModel', - 'Empty', 'PromptService', 'Rest', 'TemplatesStrings', 'WorkflowChartService', + 'ProcessErrors', '$q', + 'PromptService', 'TemplatesStrings', 'WorkflowChartService', 'Wait', '$state', function ($scope, TemplatesService, - ProcessErrors, CreateSelect2, $q, JobTemplate, - Empty, PromptService, Rest, TemplatesStrings, WorkflowChartService, + ProcessErrors, $q, + PromptService, TemplatesStrings, WorkflowChartService, Wait, $state ) { @@ -159,6 +159,11 @@ export default ['$scope', 'TemplatesService', }); }); } + }).catch(({ data, status }) => { + Wait('stop'); + ProcessErrors($scope, data, status, null, { + hdr: $scope.strings.get('error.HEADER') + }); })); } else if (nodeRef[workflowMakerNodeId].isEdited) { editPromises.push(TemplatesService.editWorkflowNode({ @@ -360,14 +365,26 @@ export default ['$scope', 'TemplatesService', .then(() => { Wait('stop'); $scope.closeDialog(); + }).catch(({ data, status }) => { + Wait('stop'); + ProcessErrors($scope, data, status, null, { + hdr: $scope.strings.get('error.HEADER') + }); }); }).catch(({ data, status }) => { Wait('stop'); - ProcessErrors($scope, data, status, null, {}); + ProcessErrors($scope, data, status, null, { + hdr: $scope.strings.get('error.HEADER') + }); }); + }).catch(({ data, status }) => { + Wait('stop'); + ProcessErrors($scope, data, status, null, { + hdr: $scope.strings.get('error.HEADER') + }); }); } else { @@ -381,6 +398,11 @@ export default ['$scope', 'TemplatesService', Wait('stop'); $scope.closeDialog(); $state.transitionTo('templates'); + }).catch(({ data, status }) => { + Wait('stop'); + ProcessErrors($scope, data, status, null, { + hdr: $scope.strings.get('error.HEADER') + }); }); } };