diff --git a/desktop/src/features/workflows/ui/WorkflowConditionBuilder.tsx b/desktop/src/features/workflows/ui/WorkflowConditionBuilder.tsx index 8d20c26e05..aba54ecb8c 100644 --- a/desktop/src/features/workflows/ui/WorkflowConditionBuilder.tsx +++ b/desktop/src/features/workflows/ui/WorkflowConditionBuilder.tsx @@ -84,7 +84,7 @@ export function WorkflowConditionBuilder({ channels, disabled, idPrefix, - matchAllHint = "Leave empty to match every event.", + matchAllLabel = "All events", onChange, triggerType, value, @@ -92,7 +92,7 @@ export function WorkflowConditionBuilder({ channels: Channel[]; disabled?: boolean; idPrefix: string; - matchAllHint?: string; + matchAllLabel?: string; onChange: (value: string) => void; triggerType: TriggerType; value: string; @@ -164,23 +164,26 @@ export function WorkflowConditionBuilder({ ) .join(", "); const fieldOptions = [ + { label: matchAllLabel, value: "" }, ...fields, { label: "Custom", value: CUSTOM_CONDITION_FIELD }, ]; return (
-
- - Condition (optional) - +
+ Condition
{fieldOptions.map((field) => { + const isMatchAll = field.value === ""; const isCustom = field.value === CUSTOM_CONDITION_FIELD; const isSelected = editor.field === field.value; return (
); } diff --git a/desktop/src/features/workflows/ui/WorkflowFormBuilder.tsx b/desktop/src/features/workflows/ui/WorkflowFormBuilder.tsx index 5bbf98bade..83c8861a36 100644 --- a/desktop/src/features/workflows/ui/WorkflowFormBuilder.tsx +++ b/desktop/src/features/workflows/ui/WorkflowFormBuilder.tsx @@ -67,7 +67,9 @@ function TriggerConfigFields({ channels={channels} disabled={disabled} idPrefix="wf-trigger-filter" - matchAllHint="Leave empty to trigger on every message." + matchAllLabel={ + trigger.on === "message_posted" ? "All messages" : "All diffs" + } onChange={(filter) => onUpdate({ ...trigger, filter })} triggerType={trigger.on} value={trigger.filter ?? ""} diff --git a/desktop/src/features/workflows/ui/WorkflowScheduleFields.tsx b/desktop/src/features/workflows/ui/WorkflowScheduleFields.tsx index 8bb0db807f..d52612f339 100644 --- a/desktop/src/features/workflows/ui/WorkflowScheduleFields.tsx +++ b/desktop/src/features/workflows/ui/WorkflowScheduleFields.tsx @@ -78,20 +78,9 @@ export function WorkflowScheduleFields({ return (
-
-
-

- Repeats -

-
-
+
+ Repeats +
{SCHEDULE_FREQUENCIES.map((frequency) => { const id = `wf-trigger-frequency-${frequency}`; return ( @@ -139,7 +128,7 @@ export function WorkflowScheduleFields({ ); })}
-
+
{schedule.frequency === "weekly" ? (
diff --git a/desktop/src/features/workflows/ui/WorkflowStepCard.tsx b/desktop/src/features/workflows/ui/WorkflowStepCard.tsx index 3e900be4d6..54584e0020 100644 --- a/desktop/src/features/workflows/ui/WorkflowStepCard.tsx +++ b/desktop/src/features/workflows/ui/WorkflowStepCard.tsx @@ -386,7 +386,7 @@ export function WorkflowStepCard({ channels={channels} disabled={disabled} idPrefix={`${prefix}-condition`} - matchAllHint="Leave empty to run this step every time the workflow starts." + matchAllLabel="Every run" onChange={(condition) => onUpdate({ ...step, condition })} triggerType={triggerType} value={step.condition ?? ""} diff --git a/desktop/tests/e2e/workflows.spec.ts b/desktop/tests/e2e/workflows.spec.ts index c92ae7d31c..158d431a8b 100644 --- a/desktop/tests/e2e/workflows.spec.ts +++ b/desktop/tests/e2e/workflows.spec.ts @@ -130,7 +130,7 @@ async function createWorkflow( } if (options?.stepCondition) { await dialog - .getByRole("group", { name: "Condition (optional)" }) + .getByRole("group", { name: "Condition" }) .getByRole("button", { name: "Custom" }) .click(); await dialog.getByLabel("Custom expression").fill(options.stepCondition); @@ -275,11 +275,15 @@ test("builds a valid trigger condition from plain-language choices", async ({ await dialog.getByRole("button", { name: /^Trigger:/ }).click(); const inspector = dialog.getByTestId("workflow-node-inspector"); - const conditionFields = inspector.getByRole("group", { - name: "Condition (optional)", - }); + const conditionFields = inspector.getByRole("group", { name: "Condition" }); const conditionOptions = conditionFields.getByRole("button"); - await expect(conditionOptions).toHaveCount(5); + await expect(conditionOptions).toHaveCount(6); + const allMessages = conditionFields.getByRole("button", { + name: "All messages", + }); + await expect(allMessages).toHaveAttribute("aria-pressed", "true"); + await allMessages.click(); + await expect(allMessages).toHaveAttribute("aria-pressed", "true"); await expect( conditionFields.getByRole("button", { name: "Message text" }), ).toHaveAttribute("aria-pressed", "false"); @@ -288,6 +292,7 @@ test("builds a valid trigger condition from plain-language choices", async ({ } await conditionFields.getByRole("button", { name: "Message text" }).click(); + await expect(allMessages).toHaveAttribute("aria-pressed", "false"); await inspector.getByLabel("Text to match").fill('deploy "buzz"'); await dialog.getByRole("tab", { name: "YAML" }).click(); await expect(dialog.getByLabel("Workflow YAML")).toHaveValue( @@ -297,7 +302,7 @@ test("builds a valid trigger condition from plain-language choices", async ({ await dialog.getByRole("tab", { name: "Form" }).click(); await dialog.getByRole("button", { name: /^Trigger:/ }).click(); const roundTrippedFields = inspector.getByRole("group", { - name: "Condition (optional)", + name: "Condition", }); await expect( roundTrippedFields.getByRole("button", { name: "Message text" }), @@ -311,6 +316,11 @@ test("builds a valid trigger condition from plain-language choices", async ({ ); await expect(inspector.getByText(/Use an evalexpr expression/)).toBeVisible(); await customCondition.click(); + await expect(customCondition).toHaveAttribute("aria-pressed", "true"); + await expect(inspector.getByLabel("Custom expression")).toBeVisible(); + await roundTrippedFields + .getByRole("button", { name: "All messages" }) + .click(); await expect(customCondition).toHaveAttribute("aria-pressed", "false"); await expect(inspector.getByLabel("Custom expression")).not.toBeVisible(); });