feat(ui-v2): Add trigger form templates#177
Conversation
…ool-status, work-queue-status, and custom triggers - Create DeploymentStatusTriggerFields component with status select - Create WorkPoolStatusTriggerFields component with status select - Create WorkQueueStatusTriggerFields component with status select - Create CustomTriggerFields component with textarea for expected events - Update TriggerStep to use new components instead of placeholders - Export all new components from index.ts All components follow the same pattern as FlowRunStateTriggerFields with: - PostureSelect for Reactive/Proactive toggle - Threshold input field - Conditional Within field (shown only for Proactive posture) Co-Authored-By: alex.s@prefect.io <ajstreed1@gmail.com>
…mponents Update tests to check for actual component rendering instead of placeholder text now that the trigger form templates are implemented. Co-Authored-By: alex.s@prefect.io <ajstreed1@gmail.com>
Review Summary by Qodo
WalkthroughsDescription• Implement trigger form templates for deployment-status, work-pool-status, work-queue-status, and custom triggers • Replace placeholder text with functional form components using PostureSelect, status dropdowns, and threshold inputs • Update trigger-step tests to verify actual component rendering instead of placeholder text • Disable TypeScript strict mode in tsconfig for compatibility Diagramflowchart LR
TriggerStep["TriggerStep Component"]
DeploymentStatus["DeploymentStatusTriggerFields"]
WorkPoolStatus["WorkPoolStatusTriggerFields"]
WorkQueueStatus["WorkQueueStatusTriggerFields"]
CustomTrigger["CustomTriggerFields"]
TriggerStep -- "deployment-status" --> DeploymentStatus
TriggerStep -- "work-pool-status" --> WorkPoolStatus
TriggerStep -- "work-queue-status" --> WorkQueueStatus
TriggerStep -- "custom" --> CustomTrigger
File Changes1. ui-v2/src/components/automations/automations-wizard/trigger-step/custom-trigger-fields.tsx
|
Code Review by Qodo
1. Missing trigger-field component tests
|
| export const CustomTriggerFields = () => { | ||
| const form = useFormContext<AutomationWizardSchema>(); | ||
| const posture = useWatch<AutomationWizardSchema>({ name: "trigger.posture" }); |
There was a problem hiding this comment.
1. Missing trigger-field component tests 📘 Rule violation ⛯ Reliability
New React component files were added without corresponding co-located *.test.tsx files in the same directory. This violates the requirement that each component file has an adjacent test file, reducing test discoverability and enforcement.
Agent Prompt
## Issue description
New React component files were added under `ui-v2/` without co-located `*.test.tsx` files, violating the rule that each `component.tsx` must have an adjacent `component.test.tsx`.
## Issue Context
This PR adds multiple new trigger-field components in `ui-v2/src/components/automations/automations-wizard/trigger-step/`.
## Fix Focus Areas
- ui-v2/src/components/automations/automations-wizard/trigger-step/custom-trigger-fields.tsx[14-93]
- ui-v2/src/components/automations/automations-wizard/trigger-step/deployment-status-trigger-fields.tsx[25-112]
- ui-v2/src/components/automations/automations-wizard/trigger-step/work-pool-status-trigger-fields.tsx[26-109]
- ui-v2/src/components/automations/automations-wizard/trigger-step/work-queue-status-trigger-fields.tsx[26-109]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| "noEmit": true, | ||
| "jsx": "react-jsx", | ||
| "strict": true, | ||
| "strict": false, |
There was a problem hiding this comment.
2. Typescript strict disabled 📘 Rule violation ✓ Correctness
ui-v2/tsconfig.app.json sets strict to false, weakening compile-time type safety. This violates the requirement that TypeScript strict mode is enabled for validation.
Agent Prompt
## Issue description
TypeScript strict mode is disabled (`"strict": false`) in `ui-v2/tsconfig.app.json`, violating the requirement for strict type checking.
## Issue Context
The compliance rule requires `strict` mode enabled to catch type errors at compile time.
## Fix Focus Areas
- ui-v2/tsconfig.app.json[16-22]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| <PostureSelect /> | ||
| <FormField | ||
| control={form.control} | ||
| name="trigger.expect" | ||
| render={({ field }) => { |
There was a problem hiding this comment.
3. Proactive status saved wrong 🐞 Bug ✓ Correctness
WorkPoolStatusTriggerFields and WorkQueueStatusTriggerFields always bind the Status select to "trigger.expect", so choosing Proactive posture still saves values as Reactive semantics instead of using "trigger.after". This produces a trigger configuration that does not match the selected posture and can cause automations to behave incorrectly.
Agent Prompt
### Issue description
Work pool/queue status trigger templates currently always write the selected status into `trigger.expect`, even when posture is `Proactive`. Elsewhere in the wizard, `Proactive` posture uses `trigger.after`.
### Issue Context
This mismatch means the stored trigger payload does not reflect the selected posture semantics.
### Fix Focus Areas
- ui-v2/src/components/automations/automations-wizard/trigger-step/work-pool-status-trigger-fields.tsx[26-46]
- ui-v2/src/components/automations/automations-wizard/trigger-step/work-queue-status-trigger-fields.tsx[26-46]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| <Textarea | ||
| placeholder="prefect.flow-run.Completed" | ||
| value={textValue} | ||
| onChange={(e) => { | ||
| const lines = e.target.value.split("\n"); | ||
| field.onChange(lines.length > 0 ? lines : undefined); | ||
| }} |
There was a problem hiding this comment.
4. Custom events can't clear 🐞 Bug ✓ Correctness
CustomTriggerFields uses split("\n") and then checks lines.length > 0, which is always true, so
clearing the textarea stores [""] instead of clearing the field. This prevents users from removing
expected events and can silently create a non-matching empty-string event entry.
Agent Prompt
### Issue description
Clearing the custom expected-events textarea currently saves `[""]` and never clears the form field because `split("\n")` always returns at least one element.
### Issue Context
This can create an empty-string event in the trigger configuration and prevents users from clearing the field.
### Fix Focus Areas
- ui-v2/src/components/automations/automations-wizard/trigger-step/custom-trigger-fields.tsx[34-40]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| <Input | ||
| type="number" | ||
| min={1} | ||
| {...field} | ||
| onChange={(e) => field.onChange(parseInt(e.target.value))} | ||
| /> |
There was a problem hiding this comment.
5. Threshold parseint truncates 🐞 Bug ✓ Correctness
WorkPoolStatusTriggerFields parses the threshold number input with parseInt, which truncates decimals and returns NaN for empty input. This is inconsistent with other trigger templates and can save an unintended threshold value or an invalid number.
Agent Prompt
### Issue description
Threshold parsing differs for work-pool-status (`parseInt`) vs other templates (`Number`), which can truncate values and produce NaN.
### Issue Context
Inconsistent parsing increases the chance of template-specific bugs.
### Fix Focus Areas
- ui-v2/src/components/automations/automations-wizard/trigger-step/work-pool-status-trigger-fields.tsx[74-79]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Benchmark PR from agentic-review-benchmarks#10