workflow node prompt fixup

* use workflow model and endpoint when node is workflow
* always include template type in prompt data
* skip missing inventory checks when node is workflow
* skip checks for required credential fields when node is workflow
This commit is contained in:
Jake McDermott
2018-11-23 17:08:21 -05:00
committed by mabashian
parent 3762ba7b24
commit 7b4521f980

View File

@@ -7,11 +7,11 @@
export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService', 'Rest', '$q', export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService', 'Rest', '$q',
'TemplatesStrings', 'CreateSelect2', 'Empty', 'generateList', 'QuerySet', 'TemplatesStrings', 'CreateSelect2', 'Empty', 'generateList', 'QuerySet',
'GetBasePath', 'TemplateList', 'ProjectList', 'InventorySourcesList', 'ProcessErrors', 'GetBasePath', 'TemplateList', 'ProjectList', 'InventorySourcesList', 'ProcessErrors',
'i18n', 'ParseTypeChange', 'i18n', 'ParseTypeChange', 'WorkflowJobTemplateModel',
function($scope, TemplatesService, JobTemplate, PromptService, Rest, $q, function($scope, TemplatesService, JobTemplate, PromptService, Rest, $q,
TemplatesStrings, CreateSelect2, Empty, generateList, qs, TemplatesStrings, CreateSelect2, Empty, generateList, qs,
GetBasePath, TemplateList, ProjectList, InventorySourcesList, ProcessErrors, GetBasePath, TemplateList, ProjectList, InventorySourcesList, ProcessErrors,
i18n, ParseTypeChange i18n, ParseTypeChange, WorkflowJobTemplate
) { ) {
let promptWatcher, credentialsWatcher, surveyQuestionWatcher, listPromises = []; let promptWatcher, credentialsWatcher, surveyQuestionWatcher, listPromises = [];
@@ -79,6 +79,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
credentialRequiresPassword = true; credentialRequiresPassword = true;
} }
}); });
$scope.credentialRequiresPassword = credentialRequiresPassword; $scope.credentialRequiresPassword = credentialRequiresPassword;
}; };
@@ -138,28 +139,28 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
$scope.nodeFormDataLoaded = true; $scope.nodeFormDataLoaded = true;
}; };
const getEditNodeHelpMessage = (selectedTemplate) => { const getEditNodeHelpMessage = (selectedTemplate, workflowJobTemplateObj) => {
if (selectedTemplate) { if (selectedTemplate) {
if (selectedTemplate.type === "workflow_job_template") { if (selectedTemplate.type === "workflow_job_template") {
if ($scope.workflowJobTemplateObj.inventory) { if (workflowJobTemplateObj.inventory) {
if (selectedTemplate.ask_inventory_on_launch) { if (selectedTemplate.ask_inventory_on_launch) {
return $scope.strings.get('workflow_maker.INVENTORY_WILL_OVERRIDE'); return $scope.strings.get('workflow_maker.INVENTORY_WILL_OVERRIDE');
} }
} }
if ($scope.workflowJobTemplateObj.ask_inventory_on_launch) { if (workflowJobTemplateObj.ask_inventory_on_launch) {
if (selectedTemplate.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_OVERRIDE');
} }
} }
} }
if (selectedTemplate.type === "job_template") { if (selectedTemplate.type === "job_template") {
if ($scope.workflowJobTemplateObj.inventory) { if (workflowJobTemplateObj.inventory) {
if (selectedTemplate.ask_inventory_on_launch) { if (selectedTemplate.ask_inventory_on_launch) {
return $scope.strings.get('workflow_maker.INVENTORY_WILL_OVERRIDE'); return $scope.strings.get('workflow_maker.INVENTORY_WILL_OVERRIDE');
} }
return $scope.strings.get('workflow_maker.INVENTORY_WILL_NOT_OVERRIDE'); return $scope.strings.get('workflow_maker.INVENTORY_WILL_NOT_OVERRIDE');
} }
if ($scope.workflowJobTemplateObj.ask_inventory_on_launch) { if (workflowJobTemplateObj.ask_inventory_on_launch) {
if (selectedTemplate.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_OVERRIDE');
} }
@@ -172,11 +173,13 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
}; };
const finishConfiguringEdit = () => { const finishConfiguringEdit = () => {
const ujt = _.get($scope, 'nodeConfig.node.fullUnifiedJobTemplateObject');
const templateType = _.get(ujt, 'type');
$scope.editNodeHelpMessage = getEditNodeHelpMessage($scope.nodeConfig.node.fullUnifiedJobTemplateObject); $scope.editNodeHelpMessage = getEditNodeHelpMessage(ujt, $scope.workflowJobTemplateObj);
if (!$scope.readOnly) { if (!$scope.readOnly) {
let jobTemplate = new JobTemplate(); let jobTemplate = templateType === "workflow_job_template" ? new WorkflowJobTemplate() : new JobTemplate();
if (_.get($scope, 'nodeConfig.node.promptData') && !_.isEmpty($scope.nodeConfig.node.promptData)) { if (_.get($scope, 'nodeConfig.node.promptData') && !_.isEmpty($scope.nodeConfig.node.promptData)) {
$scope.promptData = _.cloneDeep($scope.nodeConfig.node.promptData); $scope.promptData = _.cloneDeep($scope.nodeConfig.node.promptData);
@@ -199,7 +202,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
} else { } else {
$scope.showPromptButton = true; $scope.showPromptButton = true;
if (launchConf.ask_inventory_on_launch && !_.has(launchConf, 'defaults.inventory') && !_.has($scope, 'nodeConfig.node.originalNodeObject.summary_fields.inventory')) { if (templateType !== "workflow_job_template" && launchConf.ask_inventory_on_launch && !_.has(launchConf, 'defaults.inventory') && !_.has($scope, 'nodeConfig.node.originalNodeObject.summary_fields.inventory')) {
$scope.promptModalMissingReqFields = true; $scope.promptModalMissingReqFields = true;
} else { } else {
$scope.promptModalMissingReqFields = false; $scope.promptModalMissingReqFields = false;
@@ -326,6 +329,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
launchOptions: launchOptions, launchOptions: launchOptions,
prompts: prompts, prompts: prompts,
surveyQuestions: surveyQuestionRes.data.spec, surveyQuestions: surveyQuestionRes.data.spec,
templateType: $scope.nodeConfig.node.fullUnifiedJobTemplateObject.type,
template: $scope.nodeConfig.node.fullUnifiedJobTemplateObject.id template: $scope.nodeConfig.node.fullUnifiedJobTemplateObject.id
}; };
@@ -350,6 +354,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
launchConf: launchConf, launchConf: launchConf,
launchOptions: launchOptions, launchOptions: launchOptions,
prompts: prompts, prompts: prompts,
templateType: $scope.nodeConfig.node.fullUnifiedJobTemplateObject.type,
template: $scope.nodeConfig.node.fullUnifiedJobTemplateObject.id template: $scope.nodeConfig.node.fullUnifiedJobTemplateObject.id
}; };
@@ -442,27 +447,30 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
} }
$scope.promptData = null; $scope.promptData = null;
$scope.editNodeHelpMessage = getEditNodeHelpMessage(selectedTemplate); $scope.editNodeHelpMessage = getEditNodeHelpMessage(selectedTemplate, $scope.workflowJobTemplateObj);
if (selectedTemplate.type === "job_template") { if (selectedTemplate.type === "job_template" || selectedTemplate.type === "workflow_job_template") {
let jobTemplate = new JobTemplate(); let jobTemplate = selectedTemplate.type === "workflow_job_template" ? new WorkflowJobTemplate() : new JobTemplate();
$q.all([jobTemplate.optionsLaunch(selectedTemplate.id), jobTemplate.getLaunch(selectedTemplate.id)]) $q.all([jobTemplate.optionsLaunch(selectedTemplate.id), jobTemplate.getLaunch(selectedTemplate.id)])
.then((responses) => { .then((responses) => {
let launchConf = responses[1].data; let launchConf = responses[1].data;
if ((!selectedTemplate.inventory && !launchConf.ask_inventory_on_launch) || !selectedTemplate.project) { let credentialRequiresPassword = false;
$scope.selectedTemplateInvalid = true; let selectedTemplateInvalid = false;
} else {
$scope.selectedTemplateInvalid = false; if (selectedTemplate.type !== "workflow_job_template") {
} if ((!selectedTemplate.inventory && !launchConf.ask_inventory_on_launch) || !selectedTemplate.project) {
selectedTemplateInvalid = true;
if (launchConf.passwords_needed_to_start && launchConf.passwords_needed_to_start.length > 0) { }
$scope.credentialRequiresPassword = true;
} else { if (launchConf.passwords_needed_to_start && launchConf.passwords_needed_to_start.length > 0) {
$scope.credentialRequiresPassword = false; credentialRequiresPassword = true;
}
} }
$scope.credentialRequiresPassword = credentialRequiresPassword;
$scope.selectedTemplateInvalid = selectedTemplateInvalid;
$scope.selectedTemplate = angular.copy(selectedTemplate); $scope.selectedTemplate = angular.copy(selectedTemplate);
if (!launchConf.survey_enabled && if (!launchConf.survey_enabled &&
@@ -481,11 +489,12 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
$scope.promptModalMissingReqFields = false; $scope.promptModalMissingReqFields = false;
} else { } else {
$scope.showPromptButton = true; $scope.showPromptButton = true;
$scope.promptModalMissingReqFields = false;
if (launchConf.ask_inventory_on_launch && !_.has(launchConf, 'defaults.inventory')) { if (selectedTemplate.type !== "workflow_job_template") {
$scope.promptModalMissingReqFields = true; if (launchConf.ask_inventory_on_launch && !_.has(launchConf, 'defaults.inventory')) {
} else { $scope.promptModalMissingReqFields = true;
$scope.promptModalMissingReqFields = false; }
} }
if (launchConf.survey_enabled) { if (launchConf.survey_enabled) {
@@ -504,6 +513,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
launchOptions: responses[0].data, launchOptions: responses[0].data,
surveyQuestions: processed.surveyQuestions, surveyQuestions: processed.surveyQuestions,
template: selectedTemplate.id, template: selectedTemplate.id,
templateType: selectedTemplate.type,
prompts: PromptService.processPromptValues({ prompts: PromptService.processPromptValues({
launchConf: responses[1].data, launchConf: responses[1].data,
launchOptions: responses[0].data launchOptions: responses[0].data
@@ -527,6 +537,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
launchConf: responses[1].data, launchConf: responses[1].data,
launchOptions: responses[0].data, launchOptions: responses[0].data,
template: selectedTemplate.id, template: selectedTemplate.id,
templateType: selectedTemplate.type,
prompts: PromptService.processPromptValues({ prompts: PromptService.processPromptValues({
launchConf: responses[1].data, launchConf: responses[1].data,
launchOptions: responses[0].data launchOptions: responses[0].data