Skip to content

Commit

Permalink
feat(editor): disable the existing node switch if there aren’t any ho…
Browse files Browse the repository at this point in the history
…ps to run
  • Loading branch information
sabberworm committed Oct 30, 2024
1 parent 26b763d commit e15c9af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const CreateChildNodeStep = forwardRef<HTMLDivElement, { parentHops: Hop[
<Switch
label="Run on existing node"
value={hop.runOnExistingNode}
disabled={!hop.hops?.length}
onChange={runOnExistingNode => (hop.runOnExistingNode = runOnExistingNode)}
/>
) : undefined}
Expand All @@ -64,8 +65,8 @@ export const CreateChildNodeStep = forwardRef<HTMLDivElement, { parentHops: Hop[
<p>How to handle the case where the target node already exists.</p>
<h5>Run on existing node</h5>
<p>
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”).
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
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>
);
};

0 comments on commit e15c9af

Please sign in to comment.