fix(admin): scope Trash tab to the active locale - #2807
Conversation
The trash listing ignored the locale picker and showed entries from every locale. Adds an optional `locale` param to the trash endpoint, filters `findTrashed`/`countTrashed` by it, returns `locale` on each item, and renders a Locale column in the trash table.
🦋 Changeset detectedLatest commit: ff9eb86 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-moderation
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
This PR fixes a clear bug on multilingual sites: the admin Trash tab was ignoring the locale picker and showing trashed entries for every locale. The approach is sound and consistent with how the All tab already works.
What changed and why it fits:
- The trash endpoint
GET /_emdash/api/content/{collection}/trashnow accepts an optionallocalequery parameter. Existing callers that omit it still receive every locale, so the change is backwards-compatible. ContentRepository.findTrashedandcountTrashedfilter bylocalewhen provided, using the same parameterized Kysely pattern the regular content list uses.- The handler returns
localeandtranslationGroupon each trashed item, and the admin UI pipes the active locale through to the fetch and renders a Locale column in the trash table when i18n is enabled. - The UI correctly adjusts the trash table colSpan for the new column.
What I checked:
- Traced the locale parameter through the route (
trash.ts), handler, repository, and adminrouter.tsx/ContentList.tsx. - Confirmed the locale filter is applied with a parameterized query and does not interpolate user input into SQL.
- Reviewed the Zod schema change for
contentTrashQueryand the response schema additions fortrashedContentItemSchema. - Verified the Astro
EmDashHandlerstype andEmDashRuntimeforwarding are updated to includelocalein trash handler signatures. - Reviewed tests: the admin component tests verify the Locale column appears only with i18n, the API client test verifies the query parameter is sent, and the integration test exercises the DB filtering across dialects.
- Reviewed the changeset against
.changeset/README.md; it leads with the user-facing fix, names the affected API/behavior, and notes backwards compatibility.
No blocking issues found. The fix is targeted, well-tested, and follows the existing locale-filtering patterns.
Overlapping PRsThis PR modifies files that are also changed by other open PRs:
This may cause merge conflicts or duplicated work. A maintainer will coordinate. |
What does this PR do?
The trash listing ignored the locale picker and showed entries from
every locale. Adds an optional
localeparam to the trash endpoint,filters
findTrashed/countTrashedby it, returnslocaleon eachitem, and renders a Locale column in the trash table.
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure
Screenshots / test output