Skip to content

feat(pm-wizard): add Trello custom field creation UI with Create button#784

Merged
aaight merged 2 commits intodevfrom
feature/trello-custom-field-creation
Mar 13, 2026
Merged

feat(pm-wizard): add Trello custom field creation UI with Create button#784
aaight merged 2 commits intodevfrom
feature/trello-custom-field-creation

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 13, 2026

Summary

Implements UI for creating Trello custom fields directly in the PM wizard, allowing admins to create the cost field without leaving the wizard.

Changes

  1. State Management (pm-wizard-state.ts):

    • Added ADD_TRELLO_BOARD_CUSTOM_FIELD action to WizardAction type
    • Implemented reducer handler that appends custom field to trelloBoardDetails.customFields
  2. Hook (pm-wizard-hooks.ts):

    • Created useTrelloCustomFieldCreation hook following the useTrelloLabelCreation pattern
    • Calls trpcClient.integrationsDiscovery.createTrelloCustomField mutation
    • Dispatches ADD_TRELLO_BOARD_CUSTOM_FIELD and SET_TRELLO_COST_FIELD on success
    • Shows clear error message for 403 (missing Custom Fields power-up)
  3. UI Component (pm-wizard-trello-steps.tsx):

    • Added Create Plus button next to the cost field FieldMappingRow
    • Button displays Loader2 spinner during creation
    • Button is disabled while creating
    • New field auto-selects in dropdown on successful creation
  4. Orchestrator (pm-wizard.tsx):

    • Imported useTrelloCustomFieldCreation hook
    • Added creatingCostField state
    • Created handleCreateCostField handler
    • Passed props to TrelloFieldMappingStep
  5. Tests (pm-wizard-state.test.ts):

    • Added 4 comprehensive test cases for ADD_TRELLO_BOARD_CUSTOM_FIELD action:
      • Appends field to existing custom fields
      • No-op when trelloBoardDetails is null
      • Preserves existing fields

Testing

  • All 4618 unit tests passing
  • Lint and type checking: ✅ PASS
  • Pre-commit hooks: ✅ PASS

Dependencies

  • Backend endpoint (createTrelloCustomField) already implemented
  • Trello client support already implemented

Acceptance Criteria

  • ✅ ADD_TRELLO_BOARD_CUSTOM_FIELD action added to WizardAction type
  • ✅ useTrelloCustomFieldCreation hook implemented
  • ✅ Plus button appears next to cost field
  • ✅ Button shows spinner and is disabled while creating
  • ✅ New field auto-selects on success
  • ✅ Error feedback on failure (403 for missing power-up)

Link: https://trello.com/c/69b4447e17b24afddf656879

- Add ADD_TRELLO_BOARD_CUSTOM_FIELD action to WizardAction type
- Handle ADD_TRELLO_BOARD_CUSTOM_FIELD in wizardReducer to append custom field
- Create useTrelloCustomFieldCreation hook following useTrelloLabelCreation pattern
- Hook calls createTrelloCustomField tRPC endpoint and dispatches actions on success
- Add Create button next to cost field in TrelloFieldMappingStep
- Button shows Loader2 spinner during creation and is disabled while creating
- New field auto-selects in dropdown on successful creation
- Display clear 403 error about Custom Fields power-up requirement on failure
- Add comprehensive test cases for ADD_TRELLO_BOARD_CUSTOM_FIELD action
- All tests passing (4618 tests)

Closes #309
Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Clean, well-structured PR that follows existing patterns (useTrelloLabelCreation). One should-fix UX issue with the Create button visibility.

Should Fix

  • web/src/components/projects/pm-wizard-trello-steps.tsx:307 — The "Create" button for the cost field is always visible when state.trelloBoardDetails && onCreateCostField, with no guard against a cost field already being selected or already existing. Compare with the label creation pattern at line 249:
const showCreateButton = !isMapped && !alreadyExists && onCreateLabel && defaultInfo;

After successfully creating a Cost field (which auto-selects it via SET_TRELLO_COST_FIELD), the Create button remains visible, allowing users to create duplicate "Cost" custom fields on their Trello board. For consistency with the label pattern and to prevent duplicates, consider hiding the button when a cost field is already selected:

{state.trelloBoardDetails && onCreateCostField && !state.trelloCostFieldId && (

Or additionally check if a "Cost" number field already exists in customFields, similar to how labels check existingLabelNames.

Everything else looks good — the reducer, hook, state management, tests, and orchestrator integration all follow existing patterns correctly.

…cted or exists

Guard the Create button with checks for an already-selected cost field
(trelloCostFieldId) and an already-existing Cost number custom field in
customFields, matching the label creation pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

LGTM — Clean, well-patterned implementation of Trello custom field creation UI that follows the established useTrelloLabelCreation pattern exactly.

What I verified:

  • Type safety: The ADD_TRELLO_BOARD_CUSTOM_FIELD action type matches the backend return shape ({ id: string; name: string; type: string }) from trelloClient.createBoardCustomField.
  • Reducer correctness: Null guard on trelloBoardDetails, immutable spread, appends to customFields array — mirrors the ADD_TRELLO_BOARD_LABEL pattern.
  • Button visibility logic: Correctly hides when trelloCostFieldId is already set or when a matching "Cost" number field already exists in the board's custom fields. Auto-hides after successful creation via the SET_TRELLO_COST_FIELD dispatch.
  • Hook placement: Called unconditionally at top level in PMWizard, satisfying rules of hooks.
  • Error handling: 403 detection for missing Custom Fields power-up is specific and actionable.
  • Loading/disabled states: Button shows spinner and is disabled during creation, preventing double-clicks.
  • CI: All 5 checks passing.

Minor note: PR description says "4 comprehensive test cases" but there are 3 — not a code issue.

@aaight aaight merged commit ad5a81f into dev Mar 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants