feat(wizard): add Create button for JIRA cost custom field#787
Conversation
nhopeatall
left a comment
There was a problem hiding this comment.
Summary
Clean, well-structured feature that mirrors the existing Trello custom field creation pattern. The reducer, hook, UI, and orchestrator wiring are all correct. One gap worth addressing: the JIRA Create button lacks the duplicate-field guard that the Trello equivalent has.
Should Fix
-
web/src/components/projects/pm-wizard-jira-steps.tsx:277 — Missing duplicate-field guard. The Create button visibility condition only checks
!state.jiraCostFieldId(no field selected), but unlike the Trello equivalent (lines 308-315 ofpm-wizard-trello-steps.tsx), it does not check whether a "Cost" field already exists instate.jiraProjectDetails.fields. If a "Cost" field already exists but isn't selected yet, the button still appears, and clicking it creates a duplicate global custom field in JIRA.The Trello equivalent does this:
const existingCostField = state.trelloBoardDetails?.customFields.some( (f) => f.type === "number" && f.name.toLowerCase() === "cost", ); const showCreateCostButton = state.trelloBoardDetails && onCreateCostField && !state.trelloCostFieldId && !existingCostField;
The JIRA version should add a similar check, e.g.:
const existingCostField = state.jiraProjectDetails.fields.some( (f) => f.name.toLowerCase() === "cost" );
Since JIRA custom fields are global (as the PR's own info text correctly notes), creating duplicates is particularly problematic.
Check whether a "Cost" field already exists in jiraProjectDetails.fields before showing the Create button, mirroring the Trello equivalent guard. This prevents creating duplicate global JIRA custom fields when a Cost field already exists but hasn't been selected yet. 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-structured feature addition that follows the existing Trello custom field creation pattern exactly.
The implementation correctly:
- Adds reducer action
ADD_JIRA_PROJECT_CUSTOM_FIELDmatching theJiraProjectDetails.fieldsshape ({ id, name, custom }) - Creates
useJiraCustomFieldCreationhook following the same mutation pattern asuseTrelloCustomFieldCreation - Spreads
{ ...field, custom: true }inonSuccessto augment the API response ({ id, name }) with the requiredcustomboolean - Hides the Create button when a cost field already exists in the project OR when one is already selected
- Calls the hook unconditionally in
PMWizard(correct for Rules of Hooks) - Wires loading state through the orchestrator matching the existing Trello pattern
- Backend endpoint + tests already exist — this PR only adds the frontend wiring
All CI checks pass.
Summary
ADD_JIRA_PROJECT_CUSTOM_FIELDaction toWizardActiontype andwizardReducer— appends{ id, name, custom: true }tojiraProjectDetails.fieldsuseJiraCustomFieldCreationhook inpm-wizard-hooks.ts— callscreateJiraCustomFieldtRPC mutation, dispatchesADD_JIRA_PROJECT_CUSTOM_FIELD+SET_JIRA_COST_FIELDon success, shows clear error about admin permissions on failureJiraFieldMappingStep— visible only when project details are loaded and no cost field is selectedLoader2spinner during creation and is disabled while creatingPMWizardorchestratorCard: https://trello.com/c/jDPVbE8y/310-as-an-admin-i-want-a-create-button-next-to-the-jira-cost-field-dropdown-so-that-i-can-create-a-cost-custom-field-without-leaving
Test plan
🤖 Generated with Claude Code