๐จ Add SelectWithOther component for publication language settings
- Implement SelectWithOther component with dropdown + custom text input support
- Add comprehensive BCP 47 locale validation with grandfathered tags support
- Add searchable dropdown with 70+ predefined language options
- Move locale data to i18n package with TypeScript definitions
- Add comprehensive test coverage for component and validation logic
- Improve UX with validation messages and smooth dropdown/input transitions
- Fix duplicate variable calculation as identified in code review
This is a clean new branch based on the feedback from https://github.com/TryGhost/Ghost/pull/24290
[!NOTE] Adds a SelectWithOther component and updates Publication Language to a searchable select with custom entry, powered by i18n LOCALE_DATA and BCP 47 validation, with tests and build config updates.
- Settings (General > Publication Language):
- Replace
TextFieldwithSelectWithOtherfor locale selection; supports search and custom values.- Load options from
@tryghost/i18nLOCALE_DATA; default toen.- Add validation via
validateLocale(BCP 47 incl. grandfathered tags).- Add acceptance tests covering predefined/custom locales, validation, and mode switching.
- Design System:
- Add
global/form/SelectWithOthercomponent with toggle between select and text input, validation, and stories.- Export
SelectWithOtherand types fromsrc/index.ts.- i18n Package:
- Expose
LOCALE_DATA(code/label pairs) alongsideSUPPORTED_LOCALES; addindex.d.tstypings and updatepackage.jsontypes path.- Validation Utilities:
- New
apps/admin-x-settings/src/utils/localeValidation.tswith comprehensive BCP 47 checks; add unit tests.- Build/Config:
- Include
ghost/i18nin VitecommonjsOptions/optimizeDepsin Admin and Settings.- Dockerfile: copy
ghost/i18ninto relevant build stages.- Add
@tryghost/i18ndependency toadmin-x-settings.Written by Cursor Bugbot for commit af9942d49503c4ed572837210baf39cf67831197. This will update automatically on new commits. Configure here.
[!NOTE]
Other AI code review bot(s) detected
CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.
Walkthrough
Adds a new SelectWithOther React component and Storybook stories to the admin design system and re-exports them from the design-system index. Replaces the PublicationLanguage TextField with SelectWithOther and builds locale options from i18n.LOCALE_DATA. Introduces a validateLocale utility with unit tests and updates acceptance tests for publication language to cover predefined and custom locales. Adds TypeScript declarations and LOCALE_DATA export to ghost/i18n, updates its package types/files, adds an @tryghost/i18n dependency, and adjusts Vite and Docker build configs to include i18n assets.
Estimated code review effort
๐ฏ 4 (Complex) | โฑ๏ธ ~60 minutes
- Mixed changes across UI component library, application settings, validation logic, tests, build configuration, and package metadata.
- Areas needing extra attention:
- apps/admin-x-settings/src/utils/localeValidation.ts (detailed BCP 47-like parsing and heuristics).
- Unit tests: apps/admin-x-settings/test/unit/utils/localeValidation.test.ts (coverage and edge cases).
- SelectWithOther component and stories: apps/admin-x-design-system/src/global/form/SelectWithOther.tsx and .stories.tsx (state transitions, validation, accessibility).
- PublicationLanguage integration and acceptance tests: apps/admin-x-settings/src/components/settings/general/PublicationLanguage.tsx and apps/admin-x-settings/test/acceptance/general/publicationLanguage.test.ts.
- ghost/i18n exports and type declarations (ghost/i18n/lib/i18n.js, ghost/i18n/index.d.ts, ghost/i18n/package.json) and build config updates (vite.config.*, Dockerfile).
Possibly related PRs
- TryGhost/Ghost#25375 โ touches admin settings integration and Vite build/commonjs options; likely related to the Vite/build config and settings-area changes.
Suggested reviewers
- kevinansfield
- rob-ghost
- peterzimon
Pre-merge checks and finishing touches
โ 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%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
โ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | โ Passed | The PR title clearly and concisely describes the main change: adding a SelectWithOther component for publication language settings, which is the primary focus of the changeset. |
| Description check | โ Passed | The PR description is detailed and directly related to the changeset, covering the SelectWithOther component implementation, locale validation, i18n integration, tests, and configuration updates. |
โจ Finishing touches
- [ ] ๐ Generate docstrings
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
๐ Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
๐ฅ Commits
Reviewing files that changed from the base of the PR and between 376014e4cff28b805215819c28b82f51fe1acb86 and af9942d49503c4ed572837210baf39cf67831197.
๐ Files selected for processing (1)
-
apps/admin/vite.config.ts(1 hunks)
๐ง Files skipped from review as they are similar to previous changes (1)
- apps/admin/vite.config.ts
โฐ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: Legacy tests (Node 22.13.1, mysql8)
- GitHub Check: Acceptance tests (Node 22.13.1, mysql8)
- GitHub Check: Legacy tests (Node 22.13.1, sqlite3)
- GitHub Check: Acceptance tests (Node 22.13.1, sqlite3)
- GitHub Check: Ghost-CLI tests
- GitHub Check: Unit tests (Node 22.13.1)
- GitHub Check: Admin-X Settings tests
- GitHub Check: Lint
- GitHub Check: Cursor Bugbot
- GitHub Check: Build & Push
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
@betschki unfortunately this branch still has conflicts, I would help get it cleaned up but the permissions on your fork means I can't push anything. Once the branch is in a mergeable state I'm happy to get these changes in ๐
@kevinansfield thank you for all your help! This should now be mergeable :)