Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/various #23

Merged
merged 13 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/frontend/model/hops/createChildNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ export interface Type extends AnyHop {
type: 'createChildNode';
name: string;
primaryType?: string;
runOnExistingNode: boolean;
conflict: ConflictResolutionStrategy;
hops?: Hop[];
}

export const defaultConfig: Partial<Type> = {
conflict: 'ignore',
name: 'child-name',
runOnExistingNode: false,
};

export const title = 'Create Node';
Expand Down
17 changes: 14 additions & 3 deletions src/main/frontend/sections/editor/types/CreateChildNodeStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLDivElement, { parentHops: Hop[]; hop: Type }>(function CreateChildNodeStep(
{ parentHops, hop },
Expand All @@ -32,9 +33,18 @@ export const CreateChildNodeStep = forwardRef<HTMLDivElement, { parentHops: Hop[
<Conflict
label="If the target node exists"
forceLabel="Replace the target node"
ignoreLabel="Ignore conflict"
value={hop.conflict ?? 'ignore'}
onChange={conflict => (hop.conflict = conflict)}
/>
{hop.conflict == 'ignore' ? (
<Switch
label="Run on existing node"
value={hop.runOnExistingNode}
disabled={!hop.hops?.length}
onChange={runOnExistingNode => (hop.runOnExistingNode = runOnExistingNode)}
/>
) : undefined}
<Help title={title}>
<h5>Name of New Child Node</h5>
<p>The name of the child node to be created.</p>
Expand All @@ -52,10 +62,11 @@ export const CreateChildNodeStep = forwardRef<HTMLDivElement, { parentHops: Hop[
The primary type to set on the new node. If left empty, defaults to <code>nt:unstructured</code>
</p>
<h5>If the target node exists</h5>
<p>How to handle the case where the target node already exists.</p>
<h5>Run on existing node</h5>
<p>
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 and no new node could be created (only
applicable if “If the target node exists” is set to “Ignore conflict”).
</p>
</Help>
</StepEditor>
Expand Down
11 changes: 9 additions & 2 deletions src/main/frontend/widgets/Conflict.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Select
value={value}
label={label}
onChange={v => onChange(v)}
list={[
['ignore', 'Ignore conflict, abort the current action'],
['ignore', ignoreLabel],
['throw', 'Throw an exception, stop pipeline'],
['force', forceLabel],
]}
Expand Down
5 changes: 3 additions & 2 deletions src/main/frontend/widgets/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ export type Options = [value: string, label: string, icon?: CoralIcon][];

export const Switch: FC<{
label?: string;
disabled?: boolean;
value: boolean;
onChange(newValue: boolean): void;
}> = ({ label = 'Conflict Resolution', value, onChange }) => {
}> = ({ label = 'Conflict Resolution', disabled = false, value, onChange }) => {
const scriptContext = useContext(ScriptContext);

const switchRef = useRef<HTMLInputElement>(null);
Expand All @@ -34,7 +35,7 @@ export const Switch: FC<{
return (
<label>
<span>{label}: </span>
<coral-switch ref={switchRef} checked={value ? true : undefined} />
<coral-switch ref={switchRef} checked={value ? true : undefined} disabled={disabled ? true : undefined} />
</label>
);
};
Loading
Loading