Show all wf options when node is not a root node

* Edge type of root node is always "always"
* If node is not a root node, show all options: always, success, fail
* Remove edge conflict logic
This commit is contained in:
Marliana Lara
2018-10-04 23:01:20 -04:00
parent ad566cc651
commit a2f4e36e47
6 changed files with 268 additions and 416 deletions

View File

@@ -112,7 +112,6 @@ function TemplatesStrings (BaseString) {
RUN: t.s('RUN'), RUN: t.s('RUN'),
CHECK: t.s('CHECK'), CHECK: t.s('CHECK'),
SELECT: t.s('SELECT'), SELECT: t.s('SELECT'),
EDGE_CONFLICT: t.s('EDGE CONFLICT'),
DELETED: t.s('DELETED'), DELETED: t.s('DELETED'),
START: t.s('START'), START: t.s('START'),
DETAILS: t.s('DETAILS'), DETAILS: t.s('DETAILS'),

View File

@@ -102,13 +102,6 @@
width: 90px; width: 90px;
color: @default-interface-txt; color: @default-interface-txt;
} }
.WorkflowChart-conflictIcon {
color: @default-err;
}
.WorkflowChart-conflictText {
width: 90px;
color: @default-interface-txt;
}
.WorkflowChart-activeNode { .WorkflowChart-activeNode {
fill: @default-link; fill: @default-link;
} }

View File

@@ -327,16 +327,6 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
return (d.unifiedJobTemplate && d.unifiedJobTemplate.name) ? d.unifiedJobTemplate.name : ""; return (d.unifiedJobTemplate && d.unifiedJobTemplate.name) ? d.unifiedJobTemplate.name : "";
}).each(wrap); }).each(wrap);
thisNode.append("foreignObject")
.attr("x", 54)
.attr("y", 45)
.style("font-size","0.7em")
.attr("class", "WorkflowChart-conflictText")
.html(function () {
return `<span class=\"WorkflowChart-conflictIcon\">\uf06a</span><span> ${TemplatesStrings.get('workflow_maker.EDGE_CONFLICT')}</span>`;
})
.style("display", function(d) { return (d.edgeConflict && !d.placeholder) ? null : "none"; });
thisNode.append("foreignObject") thisNode.append("foreignObject")
.attr("x", 62) .attr("x", 62)
.attr("y", 22) .attr("y", 22)
@@ -831,9 +821,6 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
t.selectAll(".WorkflowChart-deletedText") t.selectAll(".WorkflowChart-deletedText")
.style("display", function(d){ return d.unifiedJobTemplate || d.placeholder ? "none" : null; }); .style("display", function(d){ return d.unifiedJobTemplate || d.placeholder ? "none" : null; });
t.selectAll(".WorkflowChart-conflictText")
.style("display", function(d) { return (d.edgeConflict && !d.placeholder) ? null : "none"; });
t.selectAll(".WorkflowChart-activeNode") t.selectAll(".WorkflowChart-activeNode")
.style("display", function(d) { return d.isActiveEdit ? null : "none"; }); .style("display", function(d) { return d.isActiveEdit ? null : "none"; });

View File

@@ -4,13 +4,13 @@
* All Rights Reserved * All Rights Reserved
*************************************************/ *************************************************/
export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService', export default ['$scope', 'WorkflowService', 'TemplatesService',
'$state', 'ProcessErrors', 'CreateSelect2', '$q', 'JobTemplateModel', 'ProcessErrors', 'CreateSelect2', '$q', 'JobTemplateModel',
'Empty', 'PromptService', 'Rest', 'TemplatesStrings', '$timeout', 'Empty', 'PromptService', 'Rest', 'TemplatesStrings', '$timeout',
'i18n', 'i18n',
function($scope, WorkflowService, GetBasePath, TemplatesService, function ($scope, WorkflowService, TemplatesService,
$state, ProcessErrors, CreateSelect2, $q, JobTemplate, ProcessErrors, CreateSelect2, $q, JobTemplate,
Empty, PromptService, Rest, TemplatesStrings, $timeout, i18n) { Empty, PromptService, Rest, TemplatesStrings, $timeout, i18n) {
let promptWatcher, surveyQuestionWatcher, credentialsWatcher; let promptWatcher, surveyQuestionWatcher, credentialsWatcher;
@@ -31,24 +31,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
value: "check" value: "check"
}]; }];
$scope.edgeFlags = { $scope.edgeTypeOptions = createEdgeTypeOptions();
conflict: false
};
$scope.edgeTypeOptions = [
{
label: $scope.strings.get('workflow_maker.ALWAYS'),
value: 'always'
},
{
label: $scope.strings.get('workflow_maker.ON_SUCCESS'),
value: 'success'
},
{
label: $scope.strings.get('workflow_maker.ON_FAILURE'),
value: 'failure'
}
];
let editRequests = []; let editRequests = [];
let associateRequests = []; let associateRequests = [];
@@ -59,6 +42,22 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.toggleKey = () => $scope.showKey = !$scope.showKey; $scope.toggleKey = () => $scope.showKey = !$scope.showKey;
$scope.keyClassList = `{ 'Key-menuIcon--active': showKey }`; $scope.keyClassList = `{ 'Key-menuIcon--active': showKey }`;
function createEdgeTypeOptions() {
return ([{
label: $scope.strings.get('workflow_maker.ALWAYS'),
value: 'always'
},
{
label: $scope.strings.get('workflow_maker.ON_SUCCESS'),
value: 'success'
},
{
label: $scope.strings.get('workflow_maker.ON_FAILURE'),
value: 'failure'
}
]);
}
function resetNodeForm() { function resetNodeForm() {
$scope.workflowMakerFormConfig.nodeMode = "idle"; $scope.workflowMakerFormConfig.nodeMode = "idle";
delete $scope.selectedTemplate; delete $scope.selectedTemplate;
@@ -74,7 +73,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
// params.parentId // params.parentId
// params.node // params.node
let buildSendableNodeData = function() { let buildSendableNodeData = function () {
// Create the node // Create the node
let sendableNodeData = { let sendableNodeData = {
unified_job_template: params.node.unifiedJobTemplate.id, unified_job_template: params.node.unifiedJobTemplate.id,
@@ -122,7 +121,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
return sendableNodeData; return sendableNodeData;
}; };
let continueRecursing = function(parentId) { let continueRecursing = function (parentId) {
$scope.totalIteratedNodes++; $scope.totalIteratedNodes++;
if ($scope.totalIteratedNodes === $scope.treeData.data.totalNodes) { if ($scope.totalIteratedNodes === $scope.treeData.data.totalNodes) {
@@ -130,7 +129,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
completionCallback(); completionCallback();
} else { } else {
if (params.node.children && params.node.children.length > 0) { if (params.node.children && params.node.children.length > 0) {
_.forEach(params.node.children, function(child) { _.forEach(params.node.children, function (child) {
if (child.edgeType === "success") { if (child.edgeType === "success") {
recursiveNodeUpdates({ recursiveNodeUpdates({
parentId: parentId, parentId: parentId,
@@ -155,49 +154,49 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
if (params.node.isNew) { if (params.node.isNew) {
TemplatesService.addWorkflowNode({ TemplatesService.addWorkflowNode({
url: $scope.treeData.workflow_job_template_obj.related.workflow_nodes, url: $scope.treeData.workflow_job_template_obj.related.workflow_nodes,
data: buildSendableNodeData() data: buildSendableNodeData()
}) })
.then(function(data) { .then(function (data) {
if (!params.node.isRoot) { if (!params.node.isRoot) {
associateRequests.push({ associateRequests.push({
parentId: params.parentId, parentId: params.parentId,
nodeId: data.data.id, nodeId: data.data.id,
edge: params.node.edgeType edge: params.node.edgeType
});
}
if (_.get(params, 'node.promptData.launchConf.ask_credential_on_launch')) {
// This finds the credentials that were selected in the prompt but don't occur
// in the template defaults
let credentialsToPost = params.node.promptData.prompts.credentials.value.filter(function (credFromPrompt) {
let defaultCreds = params.node.promptData.launchConf.defaults.credentials ? params.node.promptData.launchConf.defaults.credentials : [];
return !defaultCreds.some(function (defaultCred) {
return credFromPrompt.id === defaultCred.id;
});
});
credentialsToPost.forEach((credentialToPost) => {
credentialRequests.push({
id: data.data.id,
data: {
id: credentialToPost.id
}
});
});
}
params.node.isNew = false;
continueRecursing(data.data.id);
}, function (error) {
ProcessErrors($scope, error.data, error.status, null, {
hdr: 'Error!',
msg: 'Failed to add workflow node. ' +
'POST returned status: ' +
error.status
}); });
}
if (_.get(params, 'node.promptData.launchConf.ask_credential_on_launch')){
// This finds the credentials that were selected in the prompt but don't occur
// in the template defaults
let credentialsToPost = params.node.promptData.prompts.credentials.value.filter(function(credFromPrompt) {
let defaultCreds = params.node.promptData.launchConf.defaults.credentials ? params.node.promptData.launchConf.defaults.credentials : [];
return !defaultCreds.some(function(defaultCred) {
return credFromPrompt.id === defaultCred.id;
});
});
credentialsToPost.forEach((credentialToPost) => {
credentialRequests.push({
id: data.data.id,
data: {
id: credentialToPost.id
}
});
});
}
params.node.isNew = false;
continueRecursing(data.data.id);
}, function(error) {
ProcessErrors($scope, error.data, error.status, null, {
hdr: 'Error!',
msg: 'Failed to add workflow node. ' +
'POST returned status: ' +
error.status
}); });
});
} else { } else {
if (params.node.edited || !params.node.originalParentId || (params.node.originalParentId && params.parentId !== params.node.originalParentId)) { if (params.node.edited || !params.node.originalParentId || (params.node.originalParentId && params.parentId !== params.node.originalParentId)) {
@@ -208,56 +207,56 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
data: buildSendableNodeData() data: buildSendableNodeData()
}); });
if (_.get(params, 'node.promptData.launchConf.ask_credential_on_launch')){ if (_.get(params, 'node.promptData.launchConf.ask_credential_on_launch')) {
let credentialsNotInPriorCredentials = params.node.promptData.prompts.credentials.value.filter(function(credFromPrompt) { let credentialsNotInPriorCredentials = params.node.promptData.prompts.credentials.value.filter(function (credFromPrompt) {
let defaultCreds = params.node.promptData.launchConf.defaults.credentials ? params.node.promptData.launchConf.defaults.credentials : []; let defaultCreds = params.node.promptData.launchConf.defaults.credentials ? params.node.promptData.launchConf.defaults.credentials : [];
return !defaultCreds.some(function(defaultCred) { return !defaultCreds.some(function (defaultCred) {
return credFromPrompt.id === defaultCred.id; return credFromPrompt.id === defaultCred.id;
}); });
}); });
let credentialsToAdd = credentialsNotInPriorCredentials.filter(function(credNotInPrior) { let credentialsToAdd = credentialsNotInPriorCredentials.filter(function (credNotInPrior) {
let previousOverrides = params.node.promptData.prompts.credentials.previousOverrides ? params.node.promptData.prompts.credentials.previousOverrides : []; let previousOverrides = params.node.promptData.prompts.credentials.previousOverrides ? params.node.promptData.prompts.credentials.previousOverrides : [];
return !previousOverrides.some(function(priorCred) { return !previousOverrides.some(function (priorCred) {
return credNotInPrior.id === priorCred.id; return credNotInPrior.id === priorCred.id;
}); });
}); });
let credentialsToRemove = []; let credentialsToRemove = [];
if (_.has(params, 'node.promptData.prompts.credentials.previousOverrides')) { if (_.has(params, 'node.promptData.prompts.credentials.previousOverrides')) {
credentialsToRemove = params.node.promptData.prompts.credentials.previousOverrides.filter(function(priorCred) { credentialsToRemove = params.node.promptData.prompts.credentials.previousOverrides.filter(function (priorCred) {
return !credentialsNotInPriorCredentials.some(function(credNotInPrior) { return !credentialsNotInPriorCredentials.some(function (credNotInPrior) {
return priorCred.id === credNotInPrior.id; return priorCred.id === credNotInPrior.id;
}); });
}); });
} }
credentialsToAdd.forEach((credentialToAdd) => { credentialsToAdd.forEach((credentialToAdd) => {
credentialRequests.push({ credentialRequests.push({
id: params.node.nodeId, id: params.node.nodeId,
data: { data: {
id: credentialToAdd.id id: credentialToAdd.id
} }
}); });
}); });
credentialsToRemove.forEach((credentialToRemove) => { credentialsToRemove.forEach((credentialToRemove) => {
credentialRequests.push({ credentialRequests.push({
id: params.node.nodeId, id: params.node.nodeId,
data: { data: {
id: credentialToRemove.id, id: credentialToRemove.id,
disassociate: true disassociate: true
} }
}); });
}); });
} }
} }
if (params.node.originalParentId && (params.parentId !== params.node.originalParentId || params.node.originalEdge !== params.node.edgeType)) { if (params.node.originalParentId && (params.parentId !== params.node.originalParentId || params.node.originalEdge !== params.node.edgeType)) {
let parentIsDeleted = false; let parentIsDeleted = false;
_.forEach($scope.treeData.data.deletedNodes, function(deletedNode) { _.forEach($scope.treeData.data.deletedNodes, function (deletedNode) {
if (deletedNode === params.node.originalParentId) { if (deletedNode === params.node.originalParentId) {
parentIsDeleted = true; parentIsDeleted = true;
} }
@@ -297,44 +296,15 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
} }
} }
let updateEdgeDropdownOptions = (optionsToInclude) => { let updateEdgeDropdownOptions = (edgeTypeValue) => {
// Not passing optionsToInclude will include all by default // Not passing an edgeTypeValue will include all by default
if (!optionsToInclude) {
$scope.edgeTypeOptions = [
{
label: i18n._('Always'),
value: 'always'
},
{
label: i18n._('On Success'),
value: 'success'
},
{
label: i18n._('On Failure'),
value: 'failure'
}
];
} else {
$scope.edgeTypeOptions = [];
optionsToInclude.forEach((optionToInclude) => { if (edgeTypeValue) {
if (optionToInclude === "always") { $scope.edgeTypeOptions = _.filter(createEdgeTypeOptions(), {
$scope.edgeTypeOptions.push({ 'value': edgeTypeValue
label: $scope.strings.get('workflow_maker.ALWAYS'),
value: 'always'
});
} else if (optionToInclude === "success") {
$scope.edgeTypeOptions.push({
label: $scope.strings.get('workflow_maker.ON_SUCCESS'),
value: 'success'
});
} else if (optionToInclude === "failure") {
$scope.edgeTypeOptions.push({
label: $scope.strings.get('workflow_maker.ON_FAILURE'),
value: 'failure'
});
}
}); });
} else {
$scope.edgeTypeOptions = createEdgeTypeOptions();
} }
CreateSelect2({ CreateSelect2({
@@ -347,9 +317,9 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
let credentialRequiresPassword = false; let credentialRequiresPassword = false;
$scope.promptData.prompts.credentials.value.forEach((credential) => { $scope.promptData.prompts.credentials.value.forEach((credential) => {
if ((credential.passwords_needed && if ((credential.passwords_needed &&
credential.passwords_needed.length > 0) || credential.passwords_needed.length > 0) ||
(_.has(credential, 'inputs.vault_password') && (_.has(credential, 'inputs.vault_password') &&
credential.inputs.vault_password === "ASK") credential.inputs.vault_password === "ASK")
) { ) {
credentialRequiresPassword = true; credentialRequiresPassword = true;
} }
@@ -364,7 +334,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
'missingSurveyValue' 'missingSurveyValue'
]; ];
promptWatcher = $scope.$watchGroup(promptDataToWatch, function() { promptWatcher = $scope.$watchGroup(promptDataToWatch, function () {
let missingPromptValue = false; let missingPromptValue = false;
if ($scope.missingSurveyValue) { if ($scope.missingSurveyValue) {
missingPromptValue = true; missingPromptValue = true;
@@ -381,20 +351,20 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
} }
}; };
$scope.closeWorkflowMaker = function() { $scope.closeWorkflowMaker = function () {
// Revert the data to the master which was created when the dialog was opened // Revert the data to the master which was created when the dialog was opened
$scope.treeData.data = angular.copy($scope.treeDataMaster); $scope.treeData.data = angular.copy($scope.treeDataMaster);
$scope.closeDialog(); $scope.closeDialog();
}; };
$scope.saveWorkflowMaker = function() { $scope.saveWorkflowMaker = function () {
$scope.totalIteratedNodes = 0; $scope.totalIteratedNodes = 0;
if ($scope.treeData && $scope.treeData.data && $scope.treeData.data.children && $scope.treeData.data.children.length > 0) { if ($scope.treeData && $scope.treeData.data && $scope.treeData.data.children && $scope.treeData.data.children.length > 0) {
let completionCallback = function() { let completionCallback = function () {
let disassociatePromises = disassociateRequests.map(function(request) { let disassociatePromises = disassociateRequests.map(function (request) {
return TemplatesService.disassociateWorkflowNode({ return TemplatesService.disassociateWorkflowNode({
parentId: request.parentId, parentId: request.parentId,
nodeId: request.nodeId, nodeId: request.nodeId,
@@ -402,67 +372,73 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
}); });
}); });
let editNodePromises = editRequests.map(function(request) { let editNodePromises = editRequests.map(function (request) {
return TemplatesService.editWorkflowNode({ return TemplatesService.editWorkflowNode({
id: request.id, id: request.id,
data: request.data data: request.data
}); });
}); });
let deletePromises = $scope.treeData.data.deletedNodes.map(function(nodeId) { let deletePromises = $scope.treeData.data.deletedNodes.map(function (nodeId) {
return TemplatesService.deleteWorkflowJobTemplateNode(nodeId); return TemplatesService.deleteWorkflowJobTemplateNode(nodeId);
}); });
$q.all(disassociatePromises.concat(editNodePromises, deletePromises)) $q.all(disassociatePromises.concat(editNodePromises, deletePromises))
.then(function() { .then(function () {
let credentialPromises = credentialRequests.map(function(request) { let credentialPromises = credentialRequests.map(function (request) {
return TemplatesService.postWorkflowNodeCredential({ return TemplatesService.postWorkflowNodeCredential({
id: request.id, id: request.id,
data: request.data data: request.data
});
}); });
});
let associatePromises = associateRequests.map(function(request) { let associatePromises = associateRequests.map(function (request) {
return TemplatesService.associateWorkflowNode({ return TemplatesService.associateWorkflowNode({
parentId: request.parentId, parentId: request.parentId,
nodeId: request.nodeId, nodeId: request.nodeId,
edge: request.edge edge: request.edge
});
}); });
});
$q.all(associatePromises.concat(credentialPromises)) $q.all(associatePromises.concat(credentialPromises))
.then(function() { .then(function () {
$scope.closeDialog(); $scope.closeDialog();
}).catch(({data, status}) => { }).catch(({
data,
status
}) => {
ProcessErrors($scope, data, status, null, {});
});
}).catch(({
data,
status
}) => {
ProcessErrors($scope, data, status, null, {}); ProcessErrors($scope, data, status, null, {});
}); });
}).catch(({data, status}) => {
ProcessErrors($scope, data, status, null, {});
});
}; };
_.forEach($scope.treeData.data.children, function(child) { _.forEach($scope.treeData.data.children, function (child) {
recursiveNodeUpdates({ recursiveNodeUpdates({
node: child node: child
}, completionCallback); }, completionCallback);
}); });
} else { } else {
let deletePromises = $scope.treeData.data.deletedNodes.map(function(nodeId) { let deletePromises = $scope.treeData.data.deletedNodes.map(function (nodeId) {
return TemplatesService.deleteWorkflowJobTemplateNode(nodeId); return TemplatesService.deleteWorkflowJobTemplateNode(nodeId);
}); });
$q.all(deletePromises) $q.all(deletePromises)
.then(function() { .then(function () {
$scope.closeDialog(); $scope.closeDialog();
}); });
} }
}; };
/* ADD NODE FUNCTIONS */ /* ADD NODE FUNCTIONS */
$scope.startAddNode = function(parent, betweenTwoNodes) { $scope.startAddNode = function (parent, betweenTwoNodes) {
if ($scope.placeholderNode || $scope.nodeBeingEdited) { if ($scope.placeholderNode || $scope.nodeBeingEdited) {
$scope.cancelNodeForm(); $scope.cancelNodeForm();
@@ -481,41 +457,29 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.treeData.nextIndex++; $scope.treeData.nextIndex++;
let siblingConnectionTypes = WorkflowService.getSiblingConnectionTypes({
tree: $scope.treeData.data,
parentId: betweenTwoNodes ? parent.source.id : parent.id,
childId: $scope.placeholderNode.id
});
// Set the default to success // Set the default to success
let edgeType = {label: $scope.strings.get('workflow_maker.ON_SUCCESS'), value: "success"}; let edgeType = {
label: $scope.strings.get('workflow_maker.ON_SUCCESS'),
value: "success"
};
if (parent && ((betweenTwoNodes && parent.source.isStartNode) || (!betweenTwoNodes && parent.isStartNode))) { if (parent && ((betweenTwoNodes && parent.source.isStartNode) || (!betweenTwoNodes && parent.isStartNode))) {
// We don't want to give the user the option to select // This node will always be executed
// a type as this node will always be executed updateEdgeDropdownOptions('always');
updateEdgeDropdownOptions(["always"]); edgeType = {
edgeType = {label: $scope.strings.get('workflow_maker.ALWAYS'), value: "always"}; label: $scope.strings.get('workflow_maker.ALWAYS'),
value: "always"
};
} else { } else {
if (_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) { updateEdgeDropdownOptions();
updateEdgeDropdownOptions(["success", "failure"]);
edgeType = {label: $scope.strings.get('workflow_maker.ON_SUCCESS'), value: "success"};
} else if (_.includes(siblingConnectionTypes, "always")) {
updateEdgeDropdownOptions(["always"]);
edgeType = {label: $scope.strings.get('workflow_maker.ALWAYS'), value: "always"};
} else {
updateEdgeDropdownOptions();
}
} }
// Reset the edgeConflict flag
resetEdgeConflict();
$scope.edgeType = edgeType; $scope.edgeType = edgeType;
$scope.$broadcast("refreshWorkflowChart"); $scope.$broadcast("refreshWorkflowChart");
}; };
$scope.confirmNodeForm = function() { $scope.confirmNodeForm = function () {
if ($scope.workflowMakerFormConfig.nodeMode === "add") { if ($scope.workflowMakerFormConfig.nodeMode === "add") {
if ($scope.selectedTemplate && $scope.edgeType && $scope.edgeType.value) { if ($scope.selectedTemplate && $scope.edgeType && $scope.edgeType.value) {
@@ -565,13 +529,10 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.promptData = null; $scope.promptData = null;
// Reset the edgeConflict flag
resetEdgeConflict();
$scope.$broadcast("refreshWorkflowChart"); $scope.$broadcast("refreshWorkflowChart");
}; };
$scope.cancelNodeForm = function() { $scope.cancelNodeForm = function () {
if ($scope.workflowMakerFormConfig.nodeMode === "add") { if ($scope.workflowMakerFormConfig.nodeMode === "add") {
// Remove the placeholder node from the tree // Remove the placeholder node from the tree
WorkflowService.removeNodeFromTree({ WorkflowService.removeNodeFromTree({
@@ -598,9 +559,6 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.selectedTemplateInvalid = false; $scope.selectedTemplateInvalid = false;
$scope.showPromptButton = false; $scope.showPromptButton = false;
// Reset the edgeConflict flag
resetEdgeConflict();
// Reset the form // Reset the form
resetNodeForm(); resetNodeForm();
@@ -609,7 +567,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
/* EDIT NODE FUNCTIONS */ /* EDIT NODE FUNCTIONS */
$scope.startEditNode = function(nodeToEdit) { $scope.startEditNode = function (nodeToEdit) {
if (!$scope.nodeBeingEdited || ($scope.nodeBeingEdited && $scope.nodeBeingEdited.id !== nodeToEdit.id)) { if (!$scope.nodeBeingEdited || ($scope.nodeBeingEdited && $scope.nodeBeingEdited.id !== nodeToEdit.id)) {
if ($scope.placeholderNode || $scope.nodeBeingEdited) { if ($scope.placeholderNode || $scope.nodeBeingEdited) {
@@ -636,7 +594,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.nodeBeingEdited.isActiveEdit = true; $scope.nodeBeingEdited.isActiveEdit = true;
let finishConfiguringEdit = function() { let finishConfiguringEdit = function () {
let jobTemplate = new JobTemplate(); let jobTemplate = new JobTemplate();
@@ -656,8 +614,8 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
!launchConf.credential_needed_to_start && !launchConf.credential_needed_to_start &&
!launchConf.ask_variables_on_launch && !launchConf.ask_variables_on_launch &&
launchConf.variables_needed_to_start.length === 0) { launchConf.variables_needed_to_start.length === 0) {
$scope.showPromptButton = false; $scope.showPromptButton = false;
$scope.promptModalMissingReqFields = false; $scope.promptModalMissingReqFields = false;
} else { } else {
$scope.showPromptButton = true; $scope.showPromptButton = true;
@@ -729,7 +687,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
let credentialRequiresPassword = false; let credentialRequiresPassword = false;
prompts.credentials.value.forEach((credential) => { prompts.credentials.value.forEach((credential) => {
if(credential.inputs) { if (credential.inputs) {
if ((credential.inputs.password && credential.inputs.password === "ASK") || if ((credential.inputs.password && credential.inputs.password === "ASK") ||
(credential.inputs.become_password && credential.inputs.become_password === "ASK") || (credential.inputs.become_password && credential.inputs.become_password === "ASK") ||
(credential.inputs.ssh_key_unlock && credential.inputs.ssh_key_unlock === "ASK") || (credential.inputs.ssh_key_unlock && credential.inputs.ssh_key_unlock === "ASK") ||
@@ -756,8 +714,8 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
!launchConf.credential_needed_to_start && !launchConf.credential_needed_to_start &&
!launchConf.ask_variables_on_launch && !launchConf.ask_variables_on_launch &&
launchConf.variables_needed_to_start.length === 0) { launchConf.variables_needed_to_start.length === 0) {
$scope.showPromptButton = false; $scope.showPromptButton = false;
$scope.promptModalMissingReqFields = false; $scope.promptModalMissingReqFields = false;
} else { } else {
$scope.showPromptButton = true; $scope.showPromptButton = true;
@@ -816,7 +774,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
watchForPromptChanges(); watchForPromptChanges();
} }
} }
}); });
} }
if (_.get($scope, 'nodeBeingEdited.unifiedJobTemplate')) { if (_.get($scope, 'nodeBeingEdited.unifiedJobTemplate')) {
@@ -855,32 +813,30 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.workflowMakerFormConfig.activeTab = "jobs"; $scope.workflowMakerFormConfig.activeTab = "jobs";
} }
let siblingConnectionTypes = WorkflowService.getSiblingConnectionTypes({ let edgeDropdownOptions = null;
tree: $scope.treeData.data,
parentId: parent.id,
childId: nodeToEdit.id
});
let edgeDropdownOptions = null; // Select RUN dropdown option
switch ($scope.nodeBeingEdited.edgeType) {
switch($scope.nodeBeingEdited.edgeType) {
case "always": case "always":
$scope.edgeType = {label: i18n._("Always"), value: "always"}; $scope.edgeType = {
if (siblingConnectionTypes.length === 1 && _.includes(siblingConnectionTypes, "always") || $scope.nodeBeingEdited.isRoot) { label: $scope.strings.get('workflow_maker.ALWAYS'),
edgeDropdownOptions = ["always"]; value: "always"
};
if ($scope.nodeBeingEdited.isRoot) {
edgeDropdownOptions = 'always';
} }
break; break;
case "success": case "success":
$scope.edgeType = {label: i18n._("On Success"), value: "success"}; $scope.edgeType = {
if (siblingConnectionTypes.length !== 0 && (!_.includes(siblingConnectionTypes, "always"))) { label: $scope.strings.get('workflow_maker.ON_SUCCESS'),
edgeDropdownOptions = ["success", "failure"]; value: "success"
} };
break; break;
case "failure": case "failure":
$scope.edgeType = {label: i18n._("On Failure"), value: "failure"}; $scope.edgeType = {
if (siblingConnectionTypes.length !== 0 && (!_.includes(siblingConnectionTypes, "always"))) { label: $scope.strings.get('workflow_maker.ON_FAILURE'),
edgeDropdownOptions = ["success", "failure"]; value: "failure"
} };
break; break;
} }
@@ -897,10 +853,10 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
// unified job template so we're going to pull down the whole object // unified job template so we're going to pull down the whole object
TemplatesService.getUnifiedJobTemplate($scope.nodeBeingEdited.unifiedJobTemplate.id) TemplatesService.getUnifiedJobTemplate($scope.nodeBeingEdited.unifiedJobTemplate.id)
.then(function(data) { .then(function (data) {
$scope.nodeBeingEdited.unifiedJobTemplate = _.clone(data.data.results[0]); $scope.nodeBeingEdited.unifiedJobTemplate = _.clone(data.data.results[0]);
finishConfiguringEdit(); finishConfiguringEdit();
}, function(error) { }, function (error) {
ProcessErrors($scope, error.data, error.status, null, { ProcessErrors($scope, error.data, error.status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to get unified job template. GET returned ' + msg: 'Failed to get unified job template. GET returned ' +
@@ -922,16 +878,16 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.deleteOverlayVisible = false; $scope.deleteOverlayVisible = false;
} }
$scope.startDeleteNode = function(nodeToDelete) { $scope.startDeleteNode = function (nodeToDelete) {
$scope.nodeToBeDeleted = nodeToDelete; $scope.nodeToBeDeleted = nodeToDelete;
$scope.deleteOverlayVisible = true; $scope.deleteOverlayVisible = true;
}; };
$scope.cancelDeleteNode = function() { $scope.cancelDeleteNode = function () {
resetDeleteNode(); resetDeleteNode();
}; };
$scope.confirmDeleteNode = function() { $scope.confirmDeleteNode = function () {
if ($scope.nodeToBeDeleted) { if ($scope.nodeToBeDeleted) {
// TODO: turn this into a promise so that we can handle errors // TODO: turn this into a promise so that we can handle errors
@@ -949,95 +905,56 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
resetNodeForm(); resetNodeForm();
} }
// Reset the edgeConflict flag
resetEdgeConflict();
resetDeleteNode(); resetDeleteNode();
$scope.$broadcast("refreshWorkflowChart"); $scope.$broadcast("refreshWorkflowChart");
if ($scope.placeholderNode) { if ($scope.placeholderNode) {
let edgeType = {label: "On Success", value: "success"}; let edgeType = {
label: $scope.strings.get('workflow_maker.ON_SUCCESS'),
value: "success"
};
if ($scope.placeholderNode.isRoot) { if ($scope.placeholderNode.isRoot) {
updateEdgeDropdownOptions(["always"]); updateEdgeDropdownOptions('always');
edgeType = {label: "Always", value: "always"}; edgeType = {
} else { label: $scope.strings.get('workflow_maker.ALWAYS'),
// we need to update the possible edges based on any new siblings value: "always"
let siblingConnectionTypes = WorkflowService.getSiblingConnectionTypes({ };
tree: $scope.treeData.data,
parentId: $scope.placeholderNode.parent.id,
childId: $scope.placeholderNode.id
});
if (
(_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) &&
!_.includes(siblingConnectionTypes, "always")
) {
updateEdgeDropdownOptions(["success", "failure"]);
} else if (
_.includes(siblingConnectionTypes, "always") &&
!_.includes(siblingConnectionTypes, "success") &&
!_.includes(siblingConnectionTypes, "failure")
) {
updateEdgeDropdownOptions(["always"]);
edgeType = {label: "Always", value: "always"};
} else {
updateEdgeDropdownOptions();
}
}
$scope.edgeType = edgeType;
} else if ($scope.nodeBeingEdited) {
let siblingConnectionTypes = WorkflowService.getSiblingConnectionTypes({
tree: $scope.treeData.data,
parentId: $scope.nodeBeingEdited.parent.id,
childId: $scope.nodeBeingEdited.id
});
if (_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) {
updateEdgeDropdownOptions(["success", "failure"]);
} else if (_.includes(siblingConnectionTypes, "always") && $scope.nodeBeingEdited.edgeType === "always") {
updateEdgeDropdownOptions(["always"]);
} else { } else {
updateEdgeDropdownOptions(); updateEdgeDropdownOptions();
} }
switch($scope.nodeBeingEdited.edgeType) { $scope.edgeType = edgeType;
case "always": } else if ($scope.nodeBeingEdited) {
$scope.edgeType = {label: i18n._("Always"), value: "always"};
if ( switch ($scope.nodeBeingEdited.edgeType) {
_.includes(siblingConnectionTypes, "always") && case "always":
!_.includes(siblingConnectionTypes, "success") && $scope.edgeType = {
!_.includes(siblingConnectionTypes, "failure") label: $scope.strings.get('workflow_maker.ALWAYS'),
) { value: "always"
updateEdgeDropdownOptions(["always"]); };
} else { if ($scope.nodeBeingEdited.isRoot) {
updateEdgeDropdownOptions(); updateEdgeDropdownOptions('always');
} } else {
break; updateEdgeDropdownOptions();
case "success": }
$scope.edgeType = {label: i18n._("On Success"), value: "success"}; break;
if ( case "success":
(_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) && $scope.edgeType = {
!_.includes(siblingConnectionTypes, "always") label: $scope.strings.get('workflow_maker.ON_SUCCESS'),
) { value: "success"
updateEdgeDropdownOptions(["success", "failure"]); };
} else { updateEdgeDropdownOptions();
updateEdgeDropdownOptions(); break;
} case "failure":
break; $scope.edgeType = {
case "failure": label: $scope.strings.get('workflow_maker.ON_FAILURE'),
$scope.edgeType = {label: i18n._("On Failure"), value: "failure"}; value: "failure"
if ( };
(_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) && updateEdgeDropdownOptions();
!_.includes(siblingConnectionTypes, "always") break;
) { }
updateEdgeDropdownOptions(["success", "failure"]);
} else {
updateEdgeDropdownOptions();
}
break;
}
} }
$scope.treeData.data.totalNodes--; $scope.treeData.data.totalNodes--;
@@ -1045,13 +962,13 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
}; };
$scope.toggleFormTab = function(tab) { $scope.toggleFormTab = function (tab) {
if ($scope.workflowMakerFormConfig.activeTab !== tab) { if ($scope.workflowMakerFormConfig.activeTab !== tab) {
$scope.workflowMakerFormConfig.activeTab = tab; $scope.workflowMakerFormConfig.activeTab = tab;
} }
}; };
$scope.templateManuallySelected = function(selectedTemplate) { $scope.templateManuallySelected = function (selectedTemplate) {
if (promptWatcher) { if (promptWatcher) {
promptWatcher(); promptWatcher();
@@ -1100,8 +1017,8 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
!launchConf.credential_needed_to_start && !launchConf.credential_needed_to_start &&
!launchConf.ask_variables_on_launch && !launchConf.ask_variables_on_launch &&
launchConf.variables_needed_to_start.length === 0) { launchConf.variables_needed_to_start.length === 0) {
$scope.showPromptButton = false; $scope.showPromptButton = false;
$scope.promptModalMissingReqFields = false; $scope.promptModalMissingReqFields = false;
} else { } else {
$scope.showPromptButton = true; $scope.showPromptButton = true;
@@ -1168,56 +1085,47 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
} }
}; };
function resetEdgeConflict(){ $scope.toggleManualControls = function () {
$scope.edgeFlags.conflict = false;
WorkflowService.checkForEdgeConflicts({
treeData: $scope.treeData.data,
edgeFlags: $scope.edgeFlags
});
}
$scope.toggleManualControls = function() {
$scope.showManualControls = !$scope.showManualControls; $scope.showManualControls = !$scope.showManualControls;
}; };
$scope.panChart = function(direction) { $scope.panChart = function (direction) {
$scope.$broadcast('panWorkflowChart', { $scope.$broadcast('panWorkflowChart', {
direction: direction direction: direction
}); });
}; };
$scope.zoomChart = function(zoom) { $scope.zoomChart = function (zoom) {
$scope.$broadcast('zoomWorkflowChart', { $scope.$broadcast('zoomWorkflowChart', {
zoom: zoom zoom: zoom
}); });
}; };
$scope.resetChart = function() { $scope.resetChart = function () {
$scope.$broadcast('resetWorkflowChart'); $scope.$broadcast('resetWorkflowChart');
}; };
$scope.workflowZoomed = function(zoom) { $scope.workflowZoomed = function (zoom) {
$scope.$broadcast('workflowZoomed', { $scope.$broadcast('workflowZoomed', {
zoom: zoom zoom: zoom
}); });
}; };
$scope.zoomToFitChart = function() { $scope.zoomToFitChart = function () {
$scope.$broadcast('zoomToFitChart'); $scope.$broadcast('zoomToFitChart');
}; };
$scope.openPromptModal = function() { $scope.openPromptModal = function () {
$scope.promptData.triggerModalOpen = true; $scope.promptData.triggerModalOpen = true;
}; };
let allNodes = []; let allNodes = [];
let page = 1; let page = 1;
let buildTreeFromNodes = function(){ let buildTreeFromNodes = function () {
WorkflowService.buildTree({ WorkflowService.buildTree({
workflowNodes: allNodes workflowNodes: allNodes
}).then(function(data){ }).then(function (data) {
$scope.treeData = data; $scope.treeData = data;
// TODO: I think that the workflow chart directive (and eventually d3) is meddling with // TODO: I think that the workflow chart directive (and eventually d3) is meddling with
@@ -1234,33 +1142,32 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
}); });
}; };
let getNodes = function(){ let getNodes = function () {
// Get the workflow nodes // Get the workflow nodes
TemplatesService.getWorkflowJobTemplateNodes($scope.workflowJobTemplateObj.id, page) TemplatesService.getWorkflowJobTemplateNodes($scope.workflowJobTemplateObj.id, page)
.then(function(data){ .then(function (data) {
for(var i=0; i<data.data.results.length; i++) { for (var i = 0; i < data.data.results.length; i++) {
allNodes.push(data.data.results[i]); allNodes.push(data.data.results[i]);
} }
if (data.data.next) { if (data.data.next) {
// Get the next page // Get the next page
page++; page++;
getNodes(); getNodes();
} else { } else {
// This is the last page // This is the last page
buildTreeFromNodes(); buildTreeFromNodes();
} }
}, function(error){ }, function (error) {
ProcessErrors($scope, error.data, error.status, null, { ProcessErrors($scope, error.data, error.status, null, {
hdr: 'Error!', hdr: 'Error!',
msg: 'Failed to get workflow job template nodes. GET returned ' + msg: 'Failed to get workflow job template nodes. GET returned ' +
'status: ' + error.status 'status: ' + error.status
});
}); });
});
}; };
getNodes(); getNodes();
updateEdgeDropdownOptions(); updateEdgeDropdownOptions();
} }
]; ];

View File

@@ -139,7 +139,7 @@
</div> </div>
<div class="WorkflowMaker-buttonHolder"> <div class="WorkflowMaker-buttonHolder">
<button type="button" class="btn btn-sm WorkflowMaker-cancelButton" ng-click="closeWorkflowMaker()"> {{:: strings.get('CLOSE') }}</button> <button type="button" class="btn btn-sm WorkflowMaker-cancelButton" ng-click="closeWorkflowMaker()"> {{:: strings.get('CLOSE') }}</button>
<button type="button" class="btn btn-sm WorkflowMaker-saveButton" ng-click="saveWorkflowMaker()" ng-show="workflowJobTemplateObj.summary_fields.user_capabilities.edit || canAddWorkflowJobTemplate" ng-disabled="edgeFlags.conflict || workflowMakerFormConfig.nodeMode === 'add'"> {{:: strings.get('SAVE') }}</button> <button type="button" class="btn btn-sm WorkflowMaker-saveButton" ng-click="saveWorkflowMaker()" ng-show="workflowJobTemplateObj.summary_fields.user_capabilities.edit || canAddWorkflowJobTemplate" ng-disabled="workflowMakerFormConfig.nodeMode === 'add'"> {{:: strings.get('SAVE') }}</button>
</div> </div>
<prompt prompt-data="promptData" action-text="{{:: strings.get('prompt.CONFIRM')}}" prevent-creds-with-passwords="preventCredsWithPasswords" read-only-prompts="!(workflowJobTemplateObj.summary_fields.user_capabilities.edit || canAddWorkflowJobTemplate)"></prompt> <prompt prompt-data="promptData" action-text="{{:: strings.get('prompt.CONFIRM')}}" prevent-creds-with-passwords="preventCredsWithPasswords" read-only-prompts="!(workflowJobTemplateObj.summary_fields.user_capabilities.edit || canAddWorkflowJobTemplate)"></prompt>
</div> </div>

View File

@@ -290,39 +290,5 @@ export default ['$q', function($q){
} }
}, },
checkForEdgeConflicts: function(params) {
//params.treeData
//params.edgeFlags
let hasAlways = false;
let hasSuccessFailure = false;
let _this = this;
_.forEach(params.treeData.children, function(child) {
// Flip the flag to false for now - we'll set it to true later on
// if we detect a conflict
child.edgeConflict = false;
if(child.edgeType === 'always') {
hasAlways = true;
}
else if(child.edgeType === 'success' || child.edgeType === 'failure') {
hasSuccessFailure = true;
}
_this.checkForEdgeConflicts({
treeData: child,
edgeFlags: params.edgeFlags
});
});
if(hasAlways && hasSuccessFailure) {
// We have a conflict
_.forEach(params.treeData.children, function(child) {
child.edgeConflict = true;
});
params.edgeFlags.conflict = true;
}
}
}; };
}]; }];