martin
(Martin Brennan)
Julho 16, 2026, 3:48am
19
martin:
Este, por exemplo, dos menus laterais de grupos, acho que faria funcionar da mesma maneira, então você teria isso na configuração:
grupos:
tipo: grupos
obrigatório: true
resolver_membros_do_grupo: true
validações:
máximo: 20
Em seguida, no cliente, grupos se tornaria user_in_groups como um booleano.
Implementei isso no PR abaixo:
main ← dev/resolve-group-membership-theme-object-group
merged 12:19AM - 17 Jul 26 UTC
Followup 7e77ce4bd3889820d67b52a5788357ac6f7b2f58
We need to automatically re… solve group membership into a boolean
for theme object type settings which are of the group type, similar
to what we did in the original commit above for group list type
settings.
This behaves in the same way -- for an object setting schema like this:
```
menu_sections:
type: objects
default:
- name: section 1
groups:
- 1
- 3
schema:
name: menu section
properties:
name:
type: string
groups:
type: groups
resolve_group_membership: true
```
We replace `groups` with a boolean `user_in_groups` (groups is just
the property name, it could be foo_bar etc.) and then you can
do this on the client:
```
for (const section of settings.menu_sections) {
if (section.user_in_groups) {
// User is in at least one selected group for this section.
}
}
```
Rather than inspecting the `currentUser.groups`, which only includes
visible groups, not all groups the user is a member of. This allows
for more accurate permission checks for theme settings that are group
based.
Also c.f. https://meta.discourse.org/t/granular-group-based-permissions-for-anonymous-and-logged-in-users/402273/18?u=martin
E @Lilly fiz um PR para seu componente de tema group-sidebar-menus a partir de um fork que aplica essa funcionalidade de forma compatível com versões anteriores:
main ← martin-brennan:dev/apply-resolve-group-changes
opened 03:43AM - 16 Jul 26 UTC
See https://github.com/discourse/discourse/pull/41756, which must
be merged fir… st
`resolve_group_membership` can now be used on group type of theme setting object settings, so instead of relying on currentUser.groups which only has visible groups in the client, we can use `user_in_groups` which is automatically resolved from the server side
This is backwards-compatible with sites that don't yet have the
core functionality deployed
Trabalharei na parte disallowed_groups em seguida.
2 curtidas