Merge pull request #4727 from jakemcdermott/fix-4726

show extra vars on workflow template schedules

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-09-13 14:33:44 +00:00 committed by GitHub
commit fe43bab174
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 12 deletions

View File

@ -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 {

View File

@ -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 {