Skip to content

Restrict the UI and styles of the components a group takes - #613

Merged
silverbackdan merged 2 commits into
mainfrom
feature/allowed-component-ui
Nov 25, 2026
Merged

silverbackdan merged 2 commits into
mainfrom
feature/allowed-component-ui

Conversation

@silverbackdan

Copy link
Copy Markdown
Collaborator

Bundle side of components-web-app/cwa-nuxt-module#488.

Contract

ComponentGroup.allowedComponentUi (nullable JSON, the same serialization groups as allowedComponents, which is unchanged):

"allowedComponentUi": {
  "/component/images": { "ui": [null, "CwaComponentImageHero"], "styles": ["style:large"] }
}
  • Keys are component collection IRIs, as allowedComponents stores them. ui lists allowed uiComponent values, styles allowed uiClassNames entries, both matched exactly; null (primary UI) only when listed; every style must be listed. An omitted ui/styles, or an unlisted type, is unrestricted.
  • null or {} is stored as null.
  • 422 on allowedComponentUi for: a key that is not the collection IRI of a concrete component resource, a rule that is not an object of only ui/styles (an empty rule {} included), a ui that is not a list of strings or nulls, styles that is not a list of strings, and an empty ui or styles.

Enforcement

  • Placement (ComponentPositionValidator, only when the position is new or its component/componentGroup changed): 422 on component. Covers position POST/PATCH, clone, the add flow (componentPositions[i].component) and a dynamic position's fallback; /move reports it as to.componentGroup.
  • UI change (#[ComponentUiAllowedInGroups] on AbstractComponent): changing uiComponent or uiClassNames to a value any group holding the component disallows is a 422 on that field. Only the changed field is checked. One query (ComponentGroupRepository::findRestrictingUiOf()). A draft of a published component is compared with and checked against its published component; a never-published draft against its own positions.
  • Saving a restriction never checks existing contents, publishing adds no check, page data properties are not checked, and nothing is hidden on read.

Follow-through

  • CwaFixtureBuilder ->group(..., allowUi: [Class::class => [...]]) on layouts, pages and components, set only when the builder creates the group.
  • generate-fixtures writes allowUi: after max:; unmatched keys are reported.
  • make:rename-component migrations rename allowed_component_ui keys.
  • CLAUDE.md and CHANGELOG updated.

Also

  • tests/Functional/assets/schema/page.schema.json had #definitions/… in a $ref; justinrainbow/json-schema 6.15.1 refuses it, so three PageTest cases errored locally. Fixed to #/definitions/….

🤖 Generated with Claude Code

ComponentGroup.allowedComponentUi, keyed by component collection IRI, lists
the uiComponent values and uiClassNames entries a group's components may have.
Placing a disallowed component, or changing a placed component's UI or styles
to a disallowed value, is a 422. The fixture builder, generate-fixtures and
make:rename-component carry it.
@codecov

codecov Bot commented Nov 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.22%. Comparing base (6068aa8) to head (a5bfb99).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #613      +/-   ##
============================================
+ Coverage     97.19%   97.22%   +0.02%     
- Complexity     5513     5579      +66     
============================================
  Files           455      459       +4     
  Lines         14174    14316     +142     
============================================
+ Hits          13777    13919     +142     
  Misses          397      397              
Flag Coverage Δ
phpunit 97.22% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@silverbackdan
silverbackdan merged commit 3c1d0e5 into main Nov 25, 2026
14 of 15 checks passed
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.

1 participant