isWidgetVisible
Synchronous predicate: returns true when a single widget is visible to the given user + groups. Used internally by filterWidgetsByVisibility; exported for consumers that already have the user ID and groups and want to run the check themselves without re-fetching.
Signature
import { isWidgetVisible, getCurrentUserId, getCurrentUserGroups } from '@conduction/nextcloud-vue'
const userId = getCurrentUserId()
const userGroups = await getCurrentUserGroups()
const visible = isWidgetVisible(widget, userId, userGroups)
Parameters
| Arg | Type | Description |
|---|---|---|
widget | object | Widget definition. Checks widget.visibility.users (array of user IDs) and widget.visibility.groups (array of group names). |
userId | string | null | Current user ID. |
userGroups | string[] | Current user's group memberships. |
Returns
boolean.
Visibility rules
Evaluated in this order — the first match that grants access wins:
- No
widget.visibilityblock → visible. - Both
usersandgroupsempty → visible. userIdis listed invisibility.users→ visible.- Any group in
userGroupsappears invisibility.groups→ visible. - Otherwise → hidden.
users and groups combine with OR logic: either match is enough.
Related
- filterWidgetsByVisibility — Async wrapper that fetches the user's groups.
- getCurrentUserId / getCurrentUserGroups — Supplies the inputs.