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'),
CHECK: t.s('CHECK'),
SELECT: t.s('SELECT'),
EDGE_CONFLICT: t.s('EDGE CONFLICT'),
DELETED: t.s('DELETED'),
START: t.s('START'),
DETAILS: t.s('DETAILS'),

View File

@@ -102,13 +102,6 @@
width: 90px;
color: @default-interface-txt;
}
.WorkflowChart-conflictIcon {
color: @default-err;
}
.WorkflowChart-conflictText {
width: 90px;
color: @default-interface-txt;
}
.WorkflowChart-activeNode {
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 : "";
}).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")
.attr("x", 62)
.attr("y", 22)
@@ -831,9 +821,6 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
t.selectAll(".WorkflowChart-deletedText")
.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")
.style("display", function(d) { return d.isActiveEdit ? null : "none"; });

View File

@@ -4,12 +4,12 @@
* All Rights Reserved
*************************************************/
export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
'$state', 'ProcessErrors', 'CreateSelect2', '$q', 'JobTemplateModel',
export default ['$scope', 'WorkflowService', 'TemplatesService',
'ProcessErrors', 'CreateSelect2', '$q', 'JobTemplateModel',
'Empty', 'PromptService', 'Rest', 'TemplatesStrings', '$timeout',
'i18n',
function($scope, WorkflowService, GetBasePath, TemplatesService,
$state, ProcessErrors, CreateSelect2, $q, JobTemplate,
function ($scope, WorkflowService, TemplatesService,
ProcessErrors, CreateSelect2, $q, JobTemplate,
Empty, PromptService, Rest, TemplatesStrings, $timeout, i18n) {
let promptWatcher, surveyQuestionWatcher, credentialsWatcher;
@@ -31,12 +31,19 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
value: "check"
}];
$scope.edgeFlags = {
conflict: false
};
$scope.edgeTypeOptions = createEdgeTypeOptions();
$scope.edgeTypeOptions = [
{
let editRequests = [];
let associateRequests = [];
let disassociateRequests = [];
let credentialRequests = [];
$scope.showKey = false;
$scope.toggleKey = () => $scope.showKey = !$scope.showKey;
$scope.keyClassList = `{ 'Key-menuIcon--active': showKey }`;
function createEdgeTypeOptions() {
return ([{
label: $scope.strings.get('workflow_maker.ALWAYS'),
value: 'always'
},
@@ -48,16 +55,8 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
label: $scope.strings.get('workflow_maker.ON_FAILURE'),
value: 'failure'
}
];
let editRequests = [];
let associateRequests = [];
let disassociateRequests = [];
let credentialRequests = [];
$scope.showKey = false;
$scope.toggleKey = () => $scope.showKey = !$scope.showKey;
$scope.keyClassList = `{ 'Key-menuIcon--active': showKey }`;
]);
}
function resetNodeForm() {
$scope.workflowMakerFormConfig.nodeMode = "idle";
@@ -297,44 +296,15 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
}
}
let updateEdgeDropdownOptions = (optionsToInclude) => {
// Not passing optionsToInclude 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 = [];
let updateEdgeDropdownOptions = (edgeTypeValue) => {
// Not passing an edgeTypeValue will include all by default
optionsToInclude.forEach((optionToInclude) => {
if (optionToInclude === "always") {
$scope.edgeTypeOptions.push({
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'
});
}
if (edgeTypeValue) {
$scope.edgeTypeOptions = _.filter(createEdgeTypeOptions(), {
'value': edgeTypeValue
});
} else {
$scope.edgeTypeOptions = createEdgeTypeOptions();
}
CreateSelect2({
@@ -434,10 +404,16 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$q.all(associatePromises.concat(credentialPromises))
.then(function () {
$scope.closeDialog();
}).catch(({data, status}) => {
}).catch(({
data,
status
}) => {
ProcessErrors($scope, data, status, null, {});
});
}).catch(({data, status}) => {
}).catch(({
data,
status
}) => {
ProcessErrors($scope, data, status, null, {});
});
};
@@ -481,34 +457,22 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$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
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))) {
// We don't want to give the user the option to select
// a type as this node will always be executed
updateEdgeDropdownOptions(["always"]);
edgeType = {label: $scope.strings.get('workflow_maker.ALWAYS'), value: "always"};
} else {
if (_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) {
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"};
// This node will always be executed
updateEdgeDropdownOptions('always');
edgeType = {
label: $scope.strings.get('workflow_maker.ALWAYS'),
value: "always"
};
} else {
updateEdgeDropdownOptions();
}
}
// Reset the edgeConflict flag
resetEdgeConflict();
$scope.edgeType = edgeType;
$scope.$broadcast("refreshWorkflowChart");
@@ -565,9 +529,6 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.promptData = null;
// Reset the edgeConflict flag
resetEdgeConflict();
$scope.$broadcast("refreshWorkflowChart");
};
@@ -598,9 +559,6 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.selectedTemplateInvalid = false;
$scope.showPromptButton = false;
// Reset the edgeConflict flag
resetEdgeConflict();
// Reset the form
resetNodeForm();
@@ -855,32 +813,30 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.workflowMakerFormConfig.activeTab = "jobs";
}
let siblingConnectionTypes = WorkflowService.getSiblingConnectionTypes({
tree: $scope.treeData.data,
parentId: parent.id,
childId: nodeToEdit.id
});
let edgeDropdownOptions = null;
// Select RUN dropdown option
switch ($scope.nodeBeingEdited.edgeType) {
case "always":
$scope.edgeType = {label: i18n._("Always"), value: "always"};
if (siblingConnectionTypes.length === 1 && _.includes(siblingConnectionTypes, "always") || $scope.nodeBeingEdited.isRoot) {
edgeDropdownOptions = ["always"];
$scope.edgeType = {
label: $scope.strings.get('workflow_maker.ALWAYS'),
value: "always"
};
if ($scope.nodeBeingEdited.isRoot) {
edgeDropdownOptions = 'always';
}
break;
case "success":
$scope.edgeType = {label: i18n._("On Success"), value: "success"};
if (siblingConnectionTypes.length !== 0 && (!_.includes(siblingConnectionTypes, "always"))) {
edgeDropdownOptions = ["success", "failure"];
}
$scope.edgeType = {
label: $scope.strings.get('workflow_maker.ON_SUCCESS'),
value: "success"
};
break;
case "failure":
$scope.edgeType = {label: i18n._("On Failure"), value: "failure"};
if (siblingConnectionTypes.length !== 0 && (!_.includes(siblingConnectionTypes, "always"))) {
edgeDropdownOptions = ["success", "failure"];
}
$scope.edgeType = {
label: $scope.strings.get('workflow_maker.ON_FAILURE'),
value: "failure"
};
break;
}
@@ -949,93 +905,54 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
resetNodeForm();
}
// Reset the edgeConflict flag
resetEdgeConflict();
resetDeleteNode();
$scope.$broadcast("refreshWorkflowChart");
if ($scope.placeholderNode) {
let edgeType = {label: "On Success", value: "success"};
if ($scope.placeholderNode.isRoot) {
updateEdgeDropdownOptions(["always"]);
edgeType = {label: "Always", value: "always"};
} else {
// we need to update the possible edges based on any new siblings
let siblingConnectionTypes = WorkflowService.getSiblingConnectionTypes({
tree: $scope.treeData.data,
parentId: $scope.placeholderNode.parent.id,
childId: $scope.placeholderNode.id
});
let edgeType = {
label: $scope.strings.get('workflow_maker.ON_SUCCESS'),
value: "success"
};
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"};
if ($scope.placeholderNode.isRoot) {
updateEdgeDropdownOptions('always');
edgeType = {
label: $scope.strings.get('workflow_maker.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 {
updateEdgeDropdownOptions();
}
switch ($scope.nodeBeingEdited.edgeType) {
case "always":
$scope.edgeType = {label: i18n._("Always"), value: "always"};
if (
_.includes(siblingConnectionTypes, "always") &&
!_.includes(siblingConnectionTypes, "success") &&
!_.includes(siblingConnectionTypes, "failure")
) {
updateEdgeDropdownOptions(["always"]);
$scope.edgeType = {
label: $scope.strings.get('workflow_maker.ALWAYS'),
value: "always"
};
if ($scope.nodeBeingEdited.isRoot) {
updateEdgeDropdownOptions('always');
} else {
updateEdgeDropdownOptions();
}
break;
case "success":
$scope.edgeType = {label: i18n._("On Success"), value: "success"};
if (
(_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) &&
!_.includes(siblingConnectionTypes, "always")
) {
updateEdgeDropdownOptions(["success", "failure"]);
} else {
$scope.edgeType = {
label: $scope.strings.get('workflow_maker.ON_SUCCESS'),
value: "success"
};
updateEdgeDropdownOptions();
}
break;
case "failure":
$scope.edgeType = {label: i18n._("On Failure"), value: "failure"};
if (
(_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) &&
!_.includes(siblingConnectionTypes, "always")
) {
updateEdgeDropdownOptions(["success", "failure"]);
} else {
$scope.edgeType = {
label: $scope.strings.get('workflow_maker.ON_FAILURE'),
value: "failure"
};
updateEdgeDropdownOptions();
}
break;
}
}
@@ -1168,15 +1085,6 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
}
};
function resetEdgeConflict(){
$scope.edgeFlags.conflict = false;
WorkflowService.checkForEdgeConflicts({
treeData: $scope.treeData.data,
edgeFlags: $scope.edgeFlags
});
}
$scope.toggleManualControls = function () {
$scope.showManualControls = !$scope.showManualControls;
};
@@ -1261,6 +1169,5 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
getNodes();
updateEdgeDropdownOptions();
}
];

View File

@@ -139,7 +139,7 @@
</div>
<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-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>
<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>

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;
}
}
};
}];