martin
(Martin Brennan)
16. Juli 2026 um 03:48
19
martin:
Nehmen wir zum Beispiel die Gruppen-Sidebar-Menüs. Ich denke, ich würde es auf die gleiche Weise implementieren, sodass du dies in der Konfiguration hast:
groups:
type: groups
required: true
resolve_group_memberships: true
validations:
max: 20
Dann würde groups auf der Client-Seite als boolescher Wert user_in_groups erscheinen.
Ich habe dies im untenstehenden PR implementiert:
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
Und @Lilly , ich habe einen PR für dein Theme-Component „group-sidebar-menus“ aus einem Fork erstellt, der diese Funktionalität in einer abwärtskompatiblen Weise anwendet:
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
Als Nächstes werde ich mich um den Teil disallowed_groups kümmern.
2 „Gefällt mir“