diff --git a/apps/dashboard/package.json b/apps/dashboard/package.json index e9d6007..8cb541a 100644 --- a/apps/dashboard/package.json +++ b/apps/dashboard/package.json @@ -70,11 +70,14 @@ "devDependencies": { "@playwright/test": "^1.49.0", "@tailwindcss/vite": "^4.1.7", + "@testing-library/react": "^16.3.2", + "@testing-library/user-event": "^14.6.1", "@types/react": "^19.1.6", "@types/react-dom": "^19.1.6", "@vitejs/plugin-react": "^4.5.2", "@vitest/coverage-v8": "^4.0.18", "concurrently": "^9.1.2", + "jsdom": "^29.1.1", "tailwindcss": "^4.1.7", "tsx": "^4.21.0", "typescript": "catalog:", diff --git a/apps/dashboard/src/client/features/automation/components/ActionFields.tsx b/apps/dashboard/src/client/features/automation/components/ActionFields.tsx index 334a287..baecac5 100644 --- a/apps/dashboard/src/client/features/automation/components/ActionFields.tsx +++ b/apps/dashboard/src/client/features/automation/components/ActionFields.tsx @@ -10,14 +10,27 @@ import { SelectTrigger, SelectValue, } from "../../../shared/ui/select"; +import { VariableEditor } from "../../../shared/ui/variable-field"; +import type { VariableDescriptor } from "../../../shared/ui/variable-field"; import type { ActionFieldDescriptor, Channel, Role } from "../../../shared/lib/schemas"; +const VARIABLE_FIELD_KEYS = new Set([ + "message", + "embed.title", + "embed.description", + "embed.footer", + "webhook.bodyTemplate", + "nickname", + "threadName", +]); + interface ActionFieldsProps { fields: ActionFieldDescriptor[]; values: Record; onChange: (key: string, value: unknown) => void; channels: Channel[]; roles: Role[]; + variables: VariableDescriptor[]; } function getNestedValue(obj: Record, path: string): unknown { @@ -36,6 +49,7 @@ export function ActionFields({ onChange, channels, roles, + variables, }: ActionFieldsProps) { const { t } = useTranslation("common"); return ( @@ -106,26 +120,52 @@ export function ActionFields({ )} {field.type === "text" && ( - onChange(field.key, e.target.value)} - placeholder={field.placeholder} - maxLength={field.maxLength} - /> + VARIABLE_FIELD_KEYS.has(field.key) ? ( + onChange(field.key, v)} + variables={variables} + multiline={false} + aria-required={field.required} + placeholder={field.placeholder} + maxLength={field.maxLength} + /> + ) : ( + onChange(field.key, e.target.value)} + placeholder={field.placeholder} + maxLength={field.maxLength} + /> + ) )} {field.type === "textarea" && ( -