From 8bb8aa8240ee169e7f84f0233ae3131b95f7a9f5 Mon Sep 17 00:00:00 2001 From: Raphael Schweikert Date: Wed, 30 Oct 2024 17:07:01 +0100 Subject: [PATCH 01/13] feat(runner): add option to control running descendant steps on existing nodes --- .../frontend/model/hops/createChildNode.ts | 2 + .../editor/types/CreateChildNodeStep.tsx | 16 ++- src/main/frontend/widgets/Conflict.tsx | 11 +- .../aem/tools/impl/hops/CopyNode.java | 3 +- .../aem/tools/impl/hops/CreateChildNode.java | 16 ++- .../aem/tools/impl/hops/MoveNode.java | 12 +- .../tools/impl/hops/CreateChildNodeTest.java | 117 ++++++++++++++++++ .../aem/tools/jcrhopper/ScriptTest.java | 4 +- .../aem/tools/testsupport/AemUtil.java | 17 +++ 9 files changed, 183 insertions(+), 15 deletions(-) create mode 100644 src/test/java/com/swisscom/aem/tools/impl/hops/CreateChildNodeTest.java create mode 100644 src/test/java/com/swisscom/aem/tools/testsupport/AemUtil.java diff --git a/src/main/frontend/model/hops/createChildNode.ts b/src/main/frontend/model/hops/createChildNode.ts index 12a0509..21476a1 100644 --- a/src/main/frontend/model/hops/createChildNode.ts +++ b/src/main/frontend/model/hops/createChildNode.ts @@ -4,6 +4,7 @@ export interface Type extends AnyHop { type: 'createChildNode'; name: string; primaryType?: string; + runOnExistingNode: boolean; conflict: ConflictResolutionStrategy; hops?: Hop[]; } @@ -11,6 +12,7 @@ export interface Type extends AnyHop { export const defaultConfig: Partial = { conflict: 'ignore', name: 'child-name', + runOnExistingNode: false, }; export const title = 'Create Node'; diff --git a/src/main/frontend/sections/editor/types/CreateChildNodeStep.tsx b/src/main/frontend/sections/editor/types/CreateChildNodeStep.tsx index e49c8f1..e3ba1b0 100644 --- a/src/main/frontend/sections/editor/types/CreateChildNodeStep.tsx +++ b/src/main/frontend/sections/editor/types/CreateChildNodeStep.tsx @@ -8,6 +8,7 @@ import { Help } from '../../../widgets/Help'; import { Input } from '../../../widgets/Input'; import { Pipeline } from '../Pipeline'; import { Conflict } from '../../../widgets/Conflict'; +import { Switch } from '../../../widgets/Switch'; export const CreateChildNodeStep = forwardRef(function CreateChildNodeStep( { parentHops, hop }, @@ -32,9 +33,17 @@ export const CreateChildNodeStep = forwardRef (hop.conflict = conflict)} /> + {hop.conflict == 'ignore' ? ( + (hop.runOnExistingNode = runOnExistingNode)} + /> + ) : undefined}
Name of New Child Node

The name of the child node to be created.

@@ -52,10 +61,11 @@ export const CreateChildNodeStep = forwardRefnt:unstructured

If the target node exists
+

How to handle the case where the target node already exists.

+
Run on existing node

- How to handle the case where the target node already exists. Note that choosing “Ignore conflict” will use the - existing node to run descendent pipeline steps on. To stop the descendent pipeline from running in this case, - choose “Throw an exception” and place this step inside a “Catch Pipeline Errors” step. + Whether to run the descendant hops if the target node already existed (only applicable if “If the target node + exists” is set to “Ignore conflict”).

diff --git a/src/main/frontend/widgets/Conflict.tsx b/src/main/frontend/widgets/Conflict.tsx index 9b15c12..9bc53fb 100644 --- a/src/main/frontend/widgets/Conflict.tsx +++ b/src/main/frontend/widgets/Conflict.tsx @@ -9,16 +9,23 @@ export type Options = [value: string, label: string, icon?: CoralIcon][]; export const Conflict: FC<{ label?: string; forceLabel?: string; + ignoreLabel?: string; value: ConflictResolutionStrategy; onChange(newValue: ConflictResolutionStrategy): void; -}> = ({ label = 'Conflict Resolution', forceLabel = 'Force the given action', value, onChange }) => { +}> = ({ + label = 'Conflict Resolution', + forceLabel = 'Force the given action', + ignoreLabel = 'Ignore conflict, abort the current action', + value, + onChange, +}) => { return (