Skip to content

Commit

Permalink
add completion criteria to navigation block as well (#1385)
Browse files Browse the repository at this point in the history
  • Loading branch information
wintonzheng authored Dec 13, 2024
1 parent 2d1a53f commit e61f663
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ function LoginNode({ id, data }: NodeProps<LoginNode>) {
cacheActions: data.cacheActions,
totpVerificationUrl: data.totpVerificationUrl,
totpIdentifier: data.totpIdentifier,
completeCriterion: data.completeCriterion,
terminateCriterion: data.terminateCriterion,
});
const deleteNodeCallback = useDeleteNodeCallback();

Expand Down Expand Up @@ -155,6 +157,20 @@ function LoginNode({ id, data }: NodeProps<LoginNode>) {
</AccordionTrigger>
<AccordionContent className="pl-6 pr-1 pt-1">
<div className="space-y-4">
<div className="space-y-2">
<Label className="text-xs text-slate-300">
Complete if...
</Label>
<WorkflowBlockInputTextarea
nodeId={id}
onChange={(value) => {
handleChange("completeCriterion", value);
}}
value={inputs.completeCriterion}
className="nopan text-xs"
/>
</div>
<Separator />
<div className="flex items-center justify-between">
<div className="flex gap-2">
<Label className="text-xs font-normal text-slate-300">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export type LoginNodeData = NodeBaseData & {
totpVerificationUrl: string | null;
totpIdentifier: string | null;
cacheActions: boolean;
completeCriterion: string;
terminateCriterion: string;
};

export type LoginNode = Node<LoginNodeData, "login">;
Expand All @@ -29,6 +31,8 @@ export const loginNodeDefaultData: LoginNodeData = {
totpIdentifier: null,
continueOnFailure: false,
cacheActions: false,
completeCriterion: "",
terminateCriterion: "",
} as const;

export function isLoginNode(node: Node): node is LoginNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ function NavigationNode({ id, data }: NodeProps<NavigationNode>) {
downloadSuffix: data.downloadSuffix,
totpVerificationUrl: data.totpVerificationUrl,
totpIdentifier: data.totpIdentifier,
completeCriterion: data.completeCriterion,
terminateCriterion: data.terminateCriterion,
});
const deleteNodeCallback = useDeleteNodeCallback();

Expand Down Expand Up @@ -142,6 +144,20 @@ function NavigationNode({ id, data }: NodeProps<NavigationNode>) {
</AccordionTrigger>
<AccordionContent className="pl-6 pr-1 pt-1">
<div className="space-y-4">
<div className="space-y-2">
<Label className="text-xs text-slate-300">
Complete if...
</Label>
<WorkflowBlockInputTextarea
nodeId={id}
onChange={(value) => {
handleChange("completeCriterion", value);
}}
value={inputs.completeCriterion}
className="nopan text-xs"
/>
</div>
<Separator />
<div className="flex items-center justify-between">
<div className="flex gap-2">
<Label className="text-xs font-normal text-slate-300">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export type NavigationNodeData = NodeBaseData & {
url: string;
navigationGoal: string;
errorCodeMapping: string;
completeCriterion: string;
terminateCriterion: string;
maxRetries: number | null;
maxStepsOverride: number | null;
allowDownloads: boolean;
Expand All @@ -21,6 +23,8 @@ export const navigationNodeDefaultData: NavigationNodeData = {
label: "",
url: "",
navigationGoal: "",
completeCriterion: "",
terminateCriterion: "",
errorCodeMapping: "null",
maxRetries: null,
maxStepsOverride: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ function convertToNode(
totpVerificationUrl: block.totp_verification_url ?? null,
cacheActions: block.cache_actions,
maxStepsOverride: block.max_steps_per_run ?? null,
completeCriterion: block.complete_criterion ?? "",
terminateCriterion: block.terminate_criterion ?? "",
},
};
}
Expand Down Expand Up @@ -283,6 +285,8 @@ function convertToNode(
totpVerificationUrl: block.totp_verification_url ?? null,
cacheActions: block.cache_actions,
maxStepsOverride: block.max_steps_per_run ?? null,
completeCriterion: block.complete_criterion ?? "",
terminateCriterion: block.terminate_criterion ?? "",
},
};
}
Expand Down Expand Up @@ -879,6 +883,8 @@ function getWorkflowBlock(node: WorkflowBlockNode): BlockYAML {
totp_identifier: node.data.totpIdentifier,
totp_verification_url: node.data.totpVerificationUrl,
cache_actions: node.data.cacheActions,
complete_criterion: node.data.completeCriterion,
terminate_criterion: node.data.terminateCriterion,
};
}
case "extraction": {
Expand Down Expand Up @@ -916,6 +922,8 @@ function getWorkflowBlock(node: WorkflowBlockNode): BlockYAML {
totp_identifier: node.data.totpIdentifier,
totp_verification_url: node.data.totpVerificationUrl,
cache_actions: node.data.cacheActions,
complete_criterion: node.data.completeCriterion,
terminate_criterion: node.data.terminateCriterion,
};
}
case "wait": {
Expand Down Expand Up @@ -1491,6 +1499,8 @@ function convertBlocksToBlockYAML(
totp_identifier: block.totp_identifier,
totp_verification_url: block.totp_verification_url,
cache_actions: block.cache_actions,
complete_criterion: block.complete_criterion,
terminate_criterion: block.terminate_criterion,
};
return blockYaml;
}
Expand Down Expand Up @@ -1523,6 +1533,8 @@ function convertBlocksToBlockYAML(
totp_identifier: block.totp_identifier,
totp_verification_url: block.totp_verification_url,
cache_actions: block.cache_actions,
complete_criterion: block.complete_criterion,
terminate_criterion: block.terminate_criterion,
};
return blockYaml;
}
Expand Down
4 changes: 4 additions & 0 deletions skyvern-frontend/src/routes/workflows/types/workflowTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ export type NavigationBlock = WorkflowBlockBase & {
totp_verification_url?: string | null;
totp_identifier?: string | null;
cache_actions: boolean;
complete_criterion: string | null;
terminate_criterion: string | null;
};

export type ExtractionBlock = WorkflowBlockBase & {
Expand All @@ -281,6 +283,8 @@ export type LoginBlock = WorkflowBlockBase & {
totp_verification_url?: string | null;
totp_identifier?: string | null;
cache_actions: boolean;
complete_criterion: string | null;
terminate_criterion: string | null;
};

export type WaitBlock = WorkflowBlockBase & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ export type NavigationBlockYAML = BlockYAMLBase & {
totp_verification_url?: string | null;
totp_identifier?: string | null;
cache_actions: boolean;
complete_criterion: string | null;
terminate_criterion: string | null;
};

export type ExtractionBlockYAML = BlockYAMLBase & {
Expand All @@ -193,6 +195,8 @@ export type LoginBlockYAML = BlockYAMLBase & {
totp_verification_url?: string | null;
totp_identifier?: string | null;
cache_actions: boolean;
complete_criterion: string | null;
terminate_criterion: string | null;
};

export type WaitBlockYAML = BlockYAMLBase & {
Expand Down

0 comments on commit e61f663

Please sign in to comment.