Skip to content

fix(admin): scope Trash tab to the active locale - #2807

Open
LeanderG wants to merge 2 commits into
emdash-cms:mainfrom
LeanderG:main
Open

fix(admin): scope Trash tab to the active locale#2807
LeanderG wants to merge 2 commits into
emdash-cms:mainfrom
LeanderG:main

Conversation

@LeanderG

Copy link
Copy Markdown
Contributor

What does this PR do?

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.

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • I have added and reviewed the user-facing changeset (if this PR changes a published package)

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 5

Screenshots / test output

Screenshot 2026-08-31 at 13 37 22

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-bot

changeset-bot Bot commented Aug 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ff9eb86

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
emdash Patch
@emdash-cms/admin Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Aug 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/admin@2807

@emdash-cms/auth

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/auth@2807

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/auth-atproto@2807

@emdash-cms/blocks

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/blocks@2807

@emdash-cms/cloudflare

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/cloudflare@2807

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/contentful-to-portable-text@2807

emdash

npm i https://pkg.pr.new/emdash-cms/emdash@2807

create-emdash

npm i https://pkg.pr.new/emdash-cms/emdash/create-emdash@2807

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/gutenberg-to-portable-text@2807

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-cli@2807

@emdash-cms/plugin-types

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-types@2807

@emdash-cms/registry-client

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/registry-client@2807

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/registry-lexicons@2807

@emdash-cms/registry-moderation

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/registry-moderation@2807

@emdash-cms/registry-verification

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/registry-verification@2807

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/sandbox-workerd@2807

@emdash-cms/x402

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/x402@2807

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-ai-moderation@2807

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-atproto@2807

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-audit-log@2807

@emdash-cms/plugin-color

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-color@2807

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-embeds@2807

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-field-kit@2807

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-forms@2807

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/emdash-cms/emdash/@emdash-cms/plugin-webhook-notifier@2807

commit: ff9eb86

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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}/trash now accepts an optional locale query parameter. Existing callers that omit it still receive every locale, so the change is backwards-compatible.
  • ContentRepository.findTrashed and countTrashed filter by locale when provided, using the same parameterized Kysely pattern the regular content list uses.
  • The handler returns locale and translationGroup on 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 admin router.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 contentTrashQuery and the response schema additions for trashedContentItemSchema.
  • Verified the Astro EmDashHandlers type and EmDashRuntime forwarding are updated to include locale in 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.

@github-actions

Copy link
Copy Markdown
Contributor

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant