fix(assets-tab): slugify the project title before matching a bucket - #6318
Open
pedrofrxncx wants to merge 1 commit into
Open
fix(assets-tab): slugify the project title before matching a bucket#6318pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
#6296 switched the Assets tab's bucket match from metadata.siteSlug to entity.title (a free-form display name), and its own description called out the gap: a title like "Deco CMS" won't match a deco-assets-decocms bucket because matchSiteSlugConfig only lowercases, it doesn't slugify. Reuse the existing @decocms/shared slugify() (no new dependency) inside matchSiteSlugConfig so any caller passing a display name gets the same matching a slug would. No-op for values that were already slugs, so both existing call sites (use-main-panel-tabs.ts, assets-tab.tsx) keep working unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Source
Follows #6296 ("gate assets tab on project name, not metadata.siteSlug"), which switched
matchSiteSlugConfig's callers fromentity.metadata.siteSlugtoentity.title. That PR's own description flagged the gap it left open:Why a maintainer wants this
Any project whose display title isn't already a bare slug (has a space, capital letter, or punctuation) silently loses its Assets tab even though the matching bucket exists — a real regression class for any non-imported or renamed project, not just deco.cx imports.
The fix
matchSiteSlugConfignow runs its input through the existing@decocms/sharedslugify()(no new dependency, no hand-rolled normalization) before comparing againstconfig.siteSlug/config.bucket. This is a no-op for inputs that were already slugs, so both existing call sites (use-main-panel-tabs.ts,assets-tab.tsx) keep behaving exactly as before for the common case, and now also match titles like "Deco CMS" against adeco-assets-deco-cmsbucket.Added two test cases: a free-form title matching its slugified bucket, and an all-punctuation title slugifying to empty (still returns null, same as an empty string).
Verify
bun test apps/web/src/components/file-picker/match-site-slug-config.test.tsChecks run locally
bun run fmt— cleancd apps/web && bunx tsc --noEmit— cleanbunx oxlinton both changed files — 0 warnings/errorsFull CI validates the rest.
Summary by cubic
Slugifies project titles before matching an Assets bucket so titles with spaces or punctuation still match. Previously we only lowercased titles and missed matches; now we use
slugify()and return null if the slug is empty. Inputs already in slug form behave the same.slugifyfrom@decocms/shared/utils/slugify; no new dependency.matchSiteSlugConfig; call sites and common cases remain unchanged.Written for commit 1db6d7a. Summary will update on new commits.