Skip to content

feat(wizard): add Create button for JIRA cost custom field#787

Merged
aaight merged 2 commits intodevfrom
feature/jira-cost-field-create-button
Mar 13, 2026
Merged

feat(wizard): add Create button for JIRA cost custom field#787
aaight merged 2 commits intodevfrom
feature/jira-cost-field-create-button

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 13, 2026

Summary

  • Adds ADD_JIRA_PROJECT_CUSTOM_FIELD action to WizardAction type and wizardReducer — appends { id, name, custom: true } to jiraProjectDetails.fields
  • Adds useJiraCustomFieldCreation hook in pm-wizard-hooks.ts — calls createJiraCustomField tRPC mutation, dispatches ADD_JIRA_PROJECT_CUSTOM_FIELD + SET_JIRA_COST_FIELD on success, shows clear error about admin permissions on failure
  • Adds Plus "Create" button next to the cost field label in JiraFieldMappingStep — visible only when project details are loaded and no cost field is selected
  • Button shows Loader2 spinner during creation and is disabled while creating
  • Adds admin permission note below the label explaining JIRA custom fields are global
  • Wires handler and loading state through PMWizard orchestrator

Card: 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

  • Navigate to PM wizard for a JIRA project
  • Verify the "Create" button appears next to "Custom Field: Cost" when project details are loaded and no cost field is selected
  • Click "Create" — button should show spinner and become disabled during creation
  • On success, the new "Cost" field should appear in the dropdown and be auto-selected
  • On failure (non-admin user), should see error message mentioning admin permissions
  • All existing tests pass

🤖 Generated with Claude Code

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 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 of pm-wizard-trello-steps.tsx), it does not check whether a "Cost" field already exists in state.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>
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-structured feature addition that follows the existing Trello custom field creation pattern exactly.

The implementation correctly:

  • Adds reducer action ADD_JIRA_PROJECT_CUSTOM_FIELD matching the JiraProjectDetails.fields shape ({ id, name, custom })
  • Creates useJiraCustomFieldCreation hook following the same mutation pattern as useTrelloCustomFieldCreation
  • Spreads { ...field, custom: true } in onSuccess to augment the API response ({ id, name }) with the required custom boolean
  • 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.

@aaight aaight merged commit c11e44f 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