Skip to content

MongocampRoles ​

Full CRUD table for managing roles — create, edit (admin flag, collection grants), and delete. Includes a server-side debounced search input and sortable column headers. The key icon on each row links to the grant management page.

Usage ​

vue
<template>
  <MongocampRoles grants-path="/secured/admin/roles" />
</template>

Props ​

PropTypeDefaultDescription
grantsPathstring/secured/admin/rolesBase path the key icon links to: <grantsPath>/<roleName>

Behavior ​

  • List — fetched via useMongocampAdmin().listRoles(filter), debounced 300ms on the search input.
  • Details — the info icon opens a read-only side drawer with the role's Admin/Standard badge and its grants (MongocampGrantList), rendered from the list row (getRole returns exactly the same object, so there is no extra request) on a copy. Editing keeps going through the edit dialog and MongocampRoleGrants.
  • Clone — the copy icon opens a dialog asking for the new role name; the new role gets the source role's admin flag and a copy of all its grants (created with a single addRole call). A refused clone (e.g. name already taken) keeps the dialog open with the reason.
  • Add / Edit — name, isAdmin flag.
  • Delete — confirmation modal before calling deleteRole. If the server refuses, the dialog stays open and shows why so you can try again or cancel; the list is only reloaded after a successful delete.
  • Bulk delete — a checkbox column (with select-all) and a selection bar; confirming deletes the selected roles a few at a time (MongocampBulkDelete). The selection is cleared on every reload; failures are reported and stay selected.
  • Errors / empty — a failed load shows MongocampErrorAlert with retry; no rows shows an empty state.
  • Grant management itself lives in MongocampRoleGrants, reached via the key icon.

Released under the MIT License.