npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@abpjs/permission-management

v4.0.0

Published

ABP Framework permission-management components for React - translated from @abp/ng.permission-management

Readme

@abpjs/permission-management

Permission management UI components for ABP Framework in React

npm version License: LGPL-3.0

Overview

@abpjs/permission-management provides a complete permission management interface for ABP-based React applications. It allows administrators to view, grant, and revoke permissions for users, roles, and other permission providers through a user-friendly modal interface.

This package is a React translation of the original @abp/ng.permission-management Angular package, offering the same powerful permission management capabilities with modern React patterns.

Features

  • Permission Modal - Ready-to-use modal dialog for managing permissions
  • Role Permissions - Manage permissions for roles
  • User Permissions - Manage permissions for individual users
  • Permission Groups - Organized permission display by groups
  • Bulk Operations - Grant or revoke multiple permissions at once
  • Real-time Updates - Instant UI feedback on permission changes
  • Chakra UI - Beautiful, accessible components
  • TypeScript - Full type safety with comprehensive definitions

Installation

# Using npm
npm install @abpjs/permission-management

# Using yarn
yarn add @abpjs/permission-management

# Using pnpm
pnpm add @abpjs/permission-management

Required Dependencies

This package requires the following peer dependencies:

npm install @abpjs/core @abpjs/theme-shared @chakra-ui/react @emotion/react @emotion/styled framer-motion

Quick Start

Basic Usage with Permission Modal

import { useState } from 'react';
import { PermissionManagementModal } from '@abpjs/permission-management';
import { Button } from '@chakra-ui/react';

function RoleManagement() {
  const [isOpen, setIsOpen] = useState(false);
  const [selectedRole, setSelectedRole] = useState(null);

  const openPermissions = (role) => {
    setSelectedRole(role);
    setIsOpen(true);
  };

  return (
    <div>
      <Button onClick={() => openPermissions({ id: 'role-id', name: 'admin' })}>
        Manage Permissions
      </Button>

      <PermissionManagementModal
        isOpen={isOpen}
        onClose={() => setIsOpen(false)}
        providerName="R"  // R for Role
        providerKey={selectedRole?.id}
      />
    </div>
  );
}

Managing User Permissions

import { PermissionManagementModal } from '@abpjs/permission-management';

function UserPermissions({ userId }) {
  const [isOpen, setIsOpen] = useState(false);

  return (
    <>
      <Button onClick={() => setIsOpen(true)}>
        Edit User Permissions
      </Button>

      <PermissionManagementModal
        isOpen={isOpen}
        onClose={() => setIsOpen(false)}
        providerName="U"  // U for User
        providerKey={userId}
      />
    </>
  );
}

Components

PermissionManagementModal

The main component for displaying and managing permissions.

import { PermissionManagementModal } from '@abpjs/permission-management';

<PermissionManagementModal
  isOpen={isOpen}
  onClose={handleClose}
  providerName="R"
  providerKey="admin-role-id"
  onSave={handleSave}
/>

Props:

| Prop | Type | Description | |------|------|-------------| | isOpen | boolean | Controls modal visibility | | onClose | () => void | Callback when modal is closed | | providerName | string | Permission provider type ("R" for Role, "U" for User) | | providerKey | string | The identifier of the role or user | | onSave | () => void | Optional callback after permissions are saved |

Hooks

usePermissionManagement

Hook for accessing permission management functionality programmatically.

import { usePermissionManagement } from '@abpjs/permission-management';

function CustomPermissionUI() {
  const {
    permissions,
    isLoading,
    error,
    getPermissions,
    updatePermissions,
  } = usePermissionManagement();

  useEffect(() => {
    getPermissions({
      providerName: 'R',
      providerKey: 'admin',
    });
  }, []);

  const handleToggle = async (permissionName, isGranted) => {
    await updatePermissions({
      providerName: 'R',
      providerKey: 'admin',
      permissions: {
        [permissionName]: isGranted,
      },
    });
  };

  if (isLoading) return <Spinner />;
  if (error) return <ErrorMessage error={error} />;

  return (
    <div>
      {permissions.groups.map(group => (
        <PermissionGroup
          key={group.name}
          group={group}
          onToggle={handleToggle}
        />
      ))}
    </div>
  );
}

Services

PermissionManagementService

Service class for direct API interaction.

import { PermissionManagementService } from '@abpjs/permission-management';

// Get permissions for a role
const permissions = await PermissionManagementService.get({
  providerName: 'R',
  providerKey: 'admin-role-id',
});

// Update permissions
await PermissionManagementService.update({
  providerName: 'R',
  providerKey: 'admin-role-id',
  permissions: [
    { name: 'MyApp.Users.Create', isGranted: true },
    { name: 'MyApp.Users.Delete', isGranted: false },
  ],
});

Permission Providers

ABP uses different provider types for different permission subjects:

| Provider | Key | Description | |----------|-----|-------------| | R | Role | Permissions for roles | | U | User | Permissions for specific users | | C | Client | Permissions for OAuth clients |

Data Models

PermissionGroup

interface PermissionGroup {
  name: string;
  displayName: string;
  permissions: Permission[];
}

Permission

interface Permission {
  name: string;
  displayName: string;
  isGranted: boolean;
  allowedProviders: string[];
  grantedProviders: GrantedProvider[];
}

Integration Example

Complete example integrating with role management:

import { useState } from 'react';
import { usePermission } from '@abpjs/core';
import { PermissionManagementModal } from '@abpjs/permission-management';
import {
  Table,
  Button,
  IconButton,
  useDisclosure
} from '@chakra-ui/react';
import { SettingsIcon } from '@chakra-ui/icons';

function RolesTable({ roles }) {
  const { hasPermission } = usePermission();
  const { isOpen, onOpen, onClose } = useDisclosure();
  const [selectedRole, setSelectedRole] = useState(null);

  const canManagePermissions = hasPermission('AbpIdentity.Roles.ManagePermissions');

  const handleManagePermissions = (role) => {
    setSelectedRole(role);
    onOpen();
  };

  return (
    <>
      <Table>
        <thead>
          <tr>
            <th>Role Name</th>
            <th>Actions</th>
          </tr>
        </thead>
        <tbody>
          {roles.map(role => (
            <tr key={role.id}>
              <td>{role.name}</td>
              <td>
                {canManagePermissions && (
                  <IconButton
                    aria-label="Manage permissions"
                    icon={<SettingsIcon />}
                    onClick={() => handleManagePermissions(role)}
                  />
                )}
              </td>
            </tr>
          ))}
        </tbody>
      </Table>

      <PermissionManagementModal
        isOpen={isOpen}
        onClose={onClose}
        providerName="R"
        providerKey={selectedRole?.id}
      />
    </>
  );
}

Customization

Custom Permission Display

Create your own permission display component:

import { usePermissionManagement } from '@abpjs/permission-management';
import { Checkbox, VStack, Heading } from '@chakra-ui/react';

function CustomPermissionList({ providerName, providerKey }) {
  const { permissions, updatePermissions } = usePermissionManagement();

  const handleChange = async (permissionName, isGranted) => {
    await updatePermissions({
      providerName,
      providerKey,
      permissions: [{ name: permissionName, isGranted }],
    });
  };

  return (
    <VStack align="stretch" spacing={4}>
      {permissions?.groups.map(group => (
        <div key={group.name}>
          <Heading size="sm">{group.displayName}</Heading>
          {group.permissions.map(permission => (
            <Checkbox
              key={permission.name}
              isChecked={permission.isGranted}
              onChange={(e) => handleChange(permission.name, e.target.checked)}
            >
              {permission.displayName}
            </Checkbox>
          ))}
        </div>
      ))}
    </VStack>
  );
}

Related Packages

Contributing

This package is part of the ABP React monorepo. Contributions are welcome!

License

LGPL-3.0 - See LICENSE for details.


View Full Documentation | Report Issues | View Source