Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Component groups: a maximum number of components (e.g. exactly one CTA)

已关闭
#464 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

已经有一个关联 PR 被合并了。

  • #467 来自 @silverbackdan —— 已合并

评估

难度
4/5
预计耗时
3-5 天
新手友好度
20/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
php, symfony
领域
backend

调研方向

Start with src/Validator/Constraints/ComponentPositionValidator.php, which already checks allowed and ExplicitAllowOnly types, and the ComponentGroup entity that will hold maxComponents. Pull request #467 is already open against this issue, so read it and talk to the maintainers before writing anything. Done means a position that would exceed the limit fails validation on add and on move, and over-limit existing groups are reported rather than deleted.

由索引模型根据 Issue 内容生成。

描述

A component group can restrict which components it holds (allowedComponents, ExplicitAllowOnly), but not how many. Some areas of a design hold exactly one thing: a header's single call-to-action button, a hero, a page's one form. Today an editor can add a second, and it stacks.

Example

Cymru Kitchens' header is getting a layout-level headerButton group with one HeaderButton (ExplicitAllowOnly). The designer's spec is a single CTA, because several CTAs together are bad practice. Nothing stops a second button.

Proposal

  • A maxComponents (nullable int) on ComponentGroup, next to allowedComponents.
  • Written by the front end the same way as allowedComponents: from the CwaComponentGroup prop, through the group synchronizer. Settable in fixtures and over REST.
  • Enforced on the server in ComponentPositionValidator (src/Validator/Constraints/ComponentPositionValidator.php), which already checks allowed and ExplicitAllowOnly types. A position that would exceed the limit fails validation, so no client can bypass it.
  • Exposed on the group resource, so the admin knows when the group is full.

Points to settle

  • What counts. Every position in the group, or only static positions with a component? A dynamic pageDataProperty position is a slot too. A component's draft and published versions share one position, so they must count once.
  • Moves. Moving a position into a full group is rejected the same way as adding one.
  • Existing over-limit groups. When a limit is set on a group that already holds more, nothing is deleted. Report them, e.g. as a validation notice in the admin and in the orphan or stranded-group tooling, and only block adding more.
  • Contract with the module. The same as allowedComponents: the prop value, the serialized field and the validation messages.

Front-end side: components-web-app/cwa-nuxt-module (linked below).

主要语言
PHP
星标
32
派生
8
平均合并
56 分钟
30 天内合并 PR
164

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

components-web-app/api-components-bundle 的其他 Issue

查看 components-web-app/api-components-bundle 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。