From 311860e0278640b0bb4f1b1660ef0f30b4fd6687 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Thu, 12 Sep 2019 12:32:07 -0400 Subject: [PATCH] show extra vars on workflow template schedules When the workflow job template prompts for extra vars, we show the extra vars input field on the scheduler. --- .../src/scheduler/schedulerAdd.controller.js | 15 ++++++++ .../src/scheduler/schedulerEdit.controller.js | 35 ++++++++++++------- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/awx/ui/client/src/scheduler/schedulerAdd.controller.js b/awx/ui/client/src/scheduler/schedulerAdd.controller.js index 7205e9f779..b3da96058d 100644 --- a/awx/ui/client/src/scheduler/schedulerAdd.controller.js +++ b/awx/ui/client/src/scheduler/schedulerAdd.controller.js @@ -235,6 +235,7 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait', } }); } else if ($state.current.name === 'templates.editWorkflowJobTemplate.schedules.add'){ + $scope.parseType = 'yaml'; let workflowJobTemplate = new WorkflowJobTemplate(); $q.all([workflowJobTemplate.optionsLaunch(ParentObject.id), workflowJobTemplate.getLaunch(ParentObject.id)]) @@ -247,6 +248,20 @@ export default ['$filter', '$state', '$stateParams', '$http', 'Wait', }); }; + if (launchConf.ask_variables_on_launch) { + $scope.noVars = false; + $scope.extraVars = ParentObject.extra_vars === '' ? '---' : ParentObject.extra_vars; + + ParseTypeChange({ + scope: $scope, + variable: 'extraVars', + parse_variable: 'parseType', + field_id: 'SchedulerForm-extraVars' + }); + } else { + $scope.noVars = true; + } + if (!shouldShowPromptButton(launchConf)) { $scope.showPromptButton = false; } else { diff --git a/awx/ui/client/src/scheduler/schedulerEdit.controller.js b/awx/ui/client/src/scheduler/schedulerEdit.controller.js index 5d38201079..57714dc671 100644 --- a/awx/ui/client/src/scheduler/schedulerEdit.controller.js +++ b/awx/ui/client/src/scheduler/schedulerEdit.controller.js @@ -260,21 +260,20 @@ function($filter, $state, $stateParams, Wait, $scope, moment, $scope.schedulerPurgeDays = Number(schedule.extra_data.days); } + const codeMirrorExtraVars = () => { + ParseTypeChange({ + scope: $scope, + variable: 'extraVars', + parse_variable: 'parseType', + field_id: 'SchedulerForm-extraVars' + }); + }; + if ($state.current.name === 'templates.editJobTemplate.schedules.edit' || $scope.parentObject.type === 'job_template'){ let jobTemplate = new JobTemplate(); - const codeMirrorExtraVars = () => { - ParseTypeChange({ - scope: $scope, - variable: 'extraVars', - parse_variable: 'parseType', - field_id: 'SchedulerForm-extraVars' - }); - }; - Rest.setUrl(scheduleResolve.related.credentials); - $q.all([jobTemplate.optionsLaunch(ParentObject.id), jobTemplate.getLaunch(ParentObject.id), Rest.get()]) .then((responses) => { let launchOptions = responses[0].data, @@ -343,9 +342,12 @@ function($filter, $state, $stateParams, Wait, $scope, moment, prompts.credentials.value = defaultCredsWithoutOverrides.concat(scheduleCredentials); // the extra vars codemirror is ONLY shown if the - // schedule is for a JT and the JT has // ask_variables_on_launch = true - $scope.noVars = !launchConf.ask_variables_on_launch; + if (launchConf.ask_variables_on_launch) { + $scope.noVars = false; + } else { + $scope.noVars = true; + } if (!shouldShowPromptButton(launchConf)) { $scope.showPromptButton = false; @@ -432,6 +434,15 @@ function($filter, $state, $stateParams, Wait, $scope, moment, currentValues: scheduleResolve }); + // the extra vars codemirror is ONLY shown if the + // ask_variables_on_launch = true + if (launchConf.ask_variables_on_launch) { + $scope.noVars = false; + codeMirrorExtraVars(); + } else { + $scope.noVars = true; + } + if (!shouldShowPromptButton(launchConf)) { $scope.showPromptButton = false; } else {