feat(pm-wizard): add Trello custom field creation UI with Create button#784
feat(pm-wizard): add Trello custom field creation UI with Create button#784
Conversation
- 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
nhopeatall
left a comment
There was a problem hiding this comment.
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>
nhopeatall
left a comment
There was a problem hiding this comment.
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_FIELDaction type matches the backend return shape ({ id: string; name: string; type: string }) fromtrelloClient.createBoardCustomField. - Reducer correctness: Null guard on
trelloBoardDetails, immutable spread, appends tocustomFieldsarray — mirrors theADD_TRELLO_BOARD_LABELpattern. - Button visibility logic: Correctly hides when
trelloCostFieldIdis already set or when a matching "Cost" number field already exists in the board's custom fields. Auto-hides after successful creation via theSET_TRELLO_COST_FIELDdispatch. - 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.
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
State Management (pm-wizard-state.ts):
Hook (pm-wizard-hooks.ts):
UI Component (pm-wizard-trello-steps.tsx):
Orchestrator (pm-wizard.tsx):
Tests (pm-wizard-state.test.ts):
Testing
Dependencies
Acceptance Criteria
Link: https://trello.com/c/69b4447e17b24afddf656879