Ga naar hoofdinhoud

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

ArgTypeDescription
widgetobjectWidget definition. Checks widget.visibility.users (array of user IDs) and widget.visibility.groups (array of group names).
userIdstring | nullCurrent user ID.
userGroupsstring[]Current user's group memberships.

Returns

boolean.

Visibility rules

Evaluated in this order — the first match that grants access wins:

  1. No widget.visibility block → visible.
  2. Both users and groups empty → visible.
  3. userId is listed in visibility.usersvisible.
  4. Any group in userGroups appears in visibility.groupsvisible.
  5. Otherwise → hidden.

users and groups combine with OR logic: either match is enough.