Skip to content

Fixed member import tier mapping#27612

Merged
jonatansberg merged 1 commit intomainfrom
fix/member-import-tier-mapping
Apr 29, 2026
Merged

Fixed member import tier mapping#27612
jonatansberg merged 1 commit intomainfrom
fix/member-import-tier-mapping

Conversation

@jonatansberg
Copy link
Copy Markdown
Member

@jonatansberg jonatansberg commented Apr 29, 2026

Summary

Restores the feature-flagged tier mapping behavior in the React member import flow.

Root Cause

The legacy Ember import UI added the Tier / import_tier mapping option when importMemberTier was enabled. The recently ported React member import flow used a static field mapping list and static supported type list, so customers with the flag enabled could no longer select or auto-detect tier columns.

Changes

  • Read config.labs.importMemberTier in the React member import modal.
  • Add feature-aware mapping helpers for available field mappings and supported auto-detected CSV headers.
  • Pass the computed mapping list into the mapping step dropdown.
  • Add regression coverage for import_tier detection and the mapped Tier UI state.

Validation

  • pnpm --filter @tryghost/posts exec vitest run test/unit/views/members/import-members
  • pnpm --filter @tryghost/posts build
  • pnpm --filter @tryghost/posts lint:code

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

Walkthrough

This pull request introduces configurable support for member tier import functionality. The import modal now calls useBrowseConfig() to retrieve feature configuration and computes an importMemberTier flag. Field mappings are dynamically generated through a new getFieldMappings function that conditionally includes tier support. The CSV field detection logic is updated to accept configuration options that control whether the import_tier field is recognized. The MappingStep component is refactored to accept computed field mappings as a prop instead of relying on a constant, and numeric counts in the UI are formatted using formatNumber. Tests are expanded to verify tier detection and mapping behavior when the feature flag is enabled.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: restoring feature-flagged tier mapping behavior in the member import flow, which aligns with all file changes and the PR objectives.
Description check ✅ Passed The description provides clear context about the root cause, specific changes made, and validation steps, and is directly related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/member-import-tier-mapping

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Restored the feature-flagged tier mapping option in the React member import flow so sites with importMemberTier enabled can map CSV tier columns again.
@jonatansberg jonatansberg force-pushed the fix/member-import-tier-mapping branch from 832235b to a485e9d Compare April 29, 2026 08:27
@jonatansberg jonatansberg marked this pull request as ready for review April 29, 2026 08:33
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
apps/posts/test/unit/views/members/import-members/mapping.test.ts (1)

58-62: Optional: add a disabled-flag assertion for symmetry

A small companion test asserting Tier is absent when importMemberTier is false would harden regression coverage in both directions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/posts/test/unit/views/members/import-members/mapping.test.ts` around
lines 58 - 62, Add a companion test in mapping.test.ts that calls
getFieldMappings({importMemberTier: false}) and asserts that the result does not
contain {label: 'Tier', value: 'import_tier'} (use toEqual/contains negation
like not.toContainEqual) so the behaviour is covered for the disabled flag;
locate the existing test that uses getFieldMappings({importMemberTier: true})
and mirror its structure/name (e.g., "does not add tier as an available field
mapping when disabled") to keep symmetry and clarity.
apps/posts/src/views/members/components/bulk-action-modals/import-members/components/mapping-step.tsx (1)

23-23: Consider reusing a shared field-mapping type

fieldMappings: {label: string; value: string}[] is duplicated locally. Exporting and reusing a shared type from the mapping module would reduce drift risk.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/posts/src/views/members/components/bulk-action-modals/import-members/components/mapping-step.tsx`
at line 23, Replace the local inline type for fieldMappings with a shared
exported type: export a FieldMapping (or FieldMappingOption) type from the
existing mapping module (the module that already defines mapping logic/types)
and import that type into mapping-step.tsx, then change the prop/type
declaration fieldMappings: {label: string; value: string}[] to fieldMappings:
FieldMapping[] (or the chosen name) so both files reuse the same exported type
and avoid duplication.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@apps/posts/src/views/members/components/bulk-action-modals/import-members/components/mapping-step.tsx`:
- Line 23: Replace the local inline type for fieldMappings with a shared
exported type: export a FieldMapping (or FieldMappingOption) type from the
existing mapping module (the module that already defines mapping logic/types)
and import that type into mapping-step.tsx, then change the prop/type
declaration fieldMappings: {label: string; value: string}[] to fieldMappings:
FieldMapping[] (or the chosen name) so both files reuse the same exported type
and avoid duplication.

In `@apps/posts/test/unit/views/members/import-members/mapping.test.ts`:
- Around line 58-62: Add a companion test in mapping.test.ts that calls
getFieldMappings({importMemberTier: false}) and asserts that the result does not
contain {label: 'Tier', value: 'import_tier'} (use toEqual/contains negation
like not.toContainEqual) so the behaviour is covered for the disabled flag;
locate the existing test that uses getFieldMappings({importMemberTier: true})
and mirror its structure/name (e.g., "does not add tier as an available field
mapping when disabled") to keep symmetry and clarity.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4edac582-bb73-482c-a7e1-18182c61048f

📥 Commits

Reviewing files that changed from the base of the PR and between 8bf6861 and a485e9d.

📒 Files selected for processing (5)
  • apps/posts/src/views/members/components/bulk-action-modals/import-members-modal.tsx
  • apps/posts/src/views/members/components/bulk-action-modals/import-members/components/mapping-step.tsx
  • apps/posts/src/views/members/components/bulk-action-modals/import-members/mapping.ts
  • apps/posts/test/unit/views/members/import-members/mapping.test.ts
  • apps/posts/test/unit/views/members/import-members/modal.test.tsx

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a485e9d654

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
};
}, [state.file]);
}, [importMemberTier, state.file]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid resetting mapping when feature flag data arrives

Including importMemberTier in the file-read effect dependency causes the CSV to be re-parsed whenever useBrowseConfig() resolves or refetches, which dispatches PARSE_SUCCESS and overwrites any manual field selections the user has already made in the mapping step. This is reproducible when a user drops a file before the config request completes (or if config refetches), and the mapping UI unexpectedly resets mid-flow.

Useful? React with 👍 / 👎.

@jonatansberg jonatansberg merged commit 6d3634e into main Apr 29, 2026
40 checks passed
@jonatansberg jonatansberg deleted the fix/member-import-tier-mapping branch April 29, 2026 09:03
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