Skip to content

Commit

Permalink
Merge pull request #4644 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…4626-to-release-4.4

[release-4.4] Bug 1810494: Fix to not allow attempts to move connector to existing targets
  • Loading branch information
openshift-merge-robot committed Mar 5, 2020
2 parents d370315 + 4e47bff commit 244ee04
Showing 1 changed file with 9 additions and 3 deletions.
Expand Up @@ -25,6 +25,7 @@ const moveConnection = (edge: Edge, availableTargets: Node[]) => {
callback: () => {
moveConnectionModal({ edge, availableTargets });
},
isDisabled: availableTargets.length <= 1,
accessReview: asAccessReview(resourceModel, resourceObj, 'delete'),
};
};
Expand All @@ -43,12 +44,19 @@ const deleteConnection = (edge: Edge) => {

export const edgeActions = (edge: Edge, nodes: Node[]): KebabOption[] => {
const actions: KebabOption[] = [];
const currentTargets = edge
.getSource()
.getSourceEdges()
.map((e) => e.getTarget().getId());

const availableTargets = nodes
.filter((n) => {
if (n.getId() === edge.getSource().getId()) {
return false;
}
if (n.getId() !== edge.getTarget().getId() && currentTargets.includes(n.getId())) {
return false;
}
if (n.getType() === TYPE_EVENT_SOURCE) {
return false;
}
Expand All @@ -69,9 +77,7 @@ export const edgeActions = (edge: Edge, nodes: Node[]): KebabOption[] => {
})
.sort((n1, n2) => n1.getLabel().localeCompare(n2.getLabel()));

if (availableTargets.length > 1) {
actions.push(moveConnection(edge, availableTargets));
}
actions.push(moveConnection(edge, availableTargets));

switch (edge.getType()) {
case TYPE_CONNECTS_TO:
Expand Down

0 comments on commit 244ee04

Please sign in to comment.