Implement metadata-driven frontend (remove hardcoded service logic)
Context
The frontend wizard components contained multiple hardcoded constants and conditional logic tied to specific service/trigger/action IDs:
-
AUTO_OPERATOR_TRIGGERS- list of trigger IDs that should auto-set the operator -
TRIGGER_MESSAGE_TEMPLATES- hardcoded default message templates per trigger -
CHANNEL_ACTION_IDS- hardcoded action IDs that need channel selection -
HIDDEN_CONFIG_FIELDS- hardcoded list of fields to hide in the UI - Various
if (triggerId === 'weather_...')conditions
This approach means adding a new service requires modifying multiple frontend files.
Implementation
Backend: Add UI metadata to service definitions
Each trigger/action definition now includes metadata properties:
-
format:'template','template-multiline','column-select','location'- controls which UI component renders -
hidden: true- hides the field from user input (auto-populated) -
defaultTemplate- pre-fills the action message template when this trigger is selected -
autoOperator- auto-sets the operator value and hides the operator selector -
channelType-'discord'or'slack'- shows the channel picker for this action -
supportsEnrichment- shows the data enrichment panel for this trigger -
requiresLocation- shows the location picker for this trigger
Frontend: Consume metadata dynamically
-
wizardStore.js: Remove all hardcoded constants; read metadata from trigger/action objects -
DynamicFormFields.jsx: Render components based onprop.formatandprop.hidden -
StepTriggers.jsx: Usetrigger.requiresLocationandtrigger.supportsEnrichmentinstead of ID checks -
StepActions.jsx: Useaction.channelTypeinstead of hardcoded action ID lists -
StepReview.jsx: UsegetSchemaHiddenFields(schema)utility for display filtering
Key Files
frontend/src/features/rules/stores/wizardStore.jsfrontend/src/features/rules/components/DynamicFormFields.jsxfrontend/src/features/rules/components/wizard/StepTriggers.jsxfrontend/src/features/rules/components/wizard/StepActions.jsxfrontend/src/features/rules/components/wizard/StepReview.jsx- All
backend/src/services/*/index.js(metadata additions) -
backend/src/services/weather/triggers.js(metadata additions)
Acceptance Criteria
- No hardcoded service/trigger/action IDs remain in frontend components
-
All removed constants (
AUTO_OPERATOR_TRIGGERS,TRIGGER_MESSAGE_TEMPLATES,CHANNEL_ACTION_IDS,HIDDEN_CONFIG_FIELDS) are fully replaced by metadata reads - Adding a new service with triggers/actions requires zero frontend code changes
- All existing rule creation wizard flows work identically to before
- All tests pass
Edited by Muhammad NOOR UL AIN