Socket
Socket
Sign inDemoInstall

@build-security/react-rbac-ui-manager

Package Overview
Dependencies
114
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @build-security/react-rbac-ui-manager

react-rbac-ui-manager is a simple RBAC (Role Based Access Control) user interface library based on the material design system using the Material-UI lib.


Version published
Weekly downloads
7
increased by600%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

React RBAC UI Manager - User Guide

react-rbac-ui-manager is a simple RBAC (Role Based Access Control) user interface library based on the material design system using the Material-UI lib.

license npm latest package npm bundle size GitHub Workflow Status

This lib generates a simple json output of the roles and permissions and can be used internally with any react with material-ui based application.

react rbac ui manager - live demo

Table of contents

Install

npm install @build-security/react-rbac-ui-manager --save

If your project doesn't already use them, you need to install @material-ui/core, @material-ui/icons and @material-ui/lab as well.

Demo

Check the live working example on codesandbox:
Edit react-rbac-ui-sample

Usage

Simple usage:

import Rbac from "@build-security/react-rbac-ui-manager";
import { PermissionsObject } from "@build-security/react-rbac-ui-manager/dist/types";

const handleChange = (value: PermissionsObject) => {
    console.log(value)
};

<Rbac
    onChange={handleChange}
/>

Customized icons:

import Rbac from "@build-security/react-rbac-ui-manager";
import { PermissionsObject } from "@build-security/react-rbac-ui-manager/dist/types";
import DeleteIcon from '@material-ui/icons/Delete';
import styled from "styled-components";

const handleChange = (value: PermissionsObject) => {
    console.log(value)
 };

const deleteIcon = styled(DeleteIcon)`
    background: red;
    color: black;

    &.MuiSvgIcon-colorError {
        color: black;
    }
`;
 
<Rbac
    icons={{
        deleteIcon: deleteIcon
    }}
    onChange={handleChange}
/>

👉 Note - the JSON Viewer is not part of this lib.
The live example (in codesandbox) contains a working version with external viewer

API

<Rbac />

The Rbac component accepts the following props (none of which is required):

NameTypeDescription
defaultValueobjectJSON structure, same as the one that is generated by the lib
onChangefunctionCallback fired on every change.
signature:
function(data: object) => void
data: The JSON object with the new value.
resourceForbiddenCharsRegexRegExpRegular expression to remove invalid characters from the resource
buttonsobjectObject contains buttons to be used as replacement for the default buttons (see below)
iconsobjectObject contains icons to be used as replacement for the default icons (see below)
componentsobjectObject contains components to be used as replacement for the default components (see below)

The Buttons object:

NameTypeDescription
cancelButtonnodeThe component to use for the cancel button inside the modal
closeButtonnodeThe component to use for the close button inside the modal
deleteButtonnodeThe component to use for the delete button inside the modal
saveButtonnodeThe component to use for the save button inside the modal

The Icons object:

NameTypeDescription
deleteIconnodeThe component to use for the delete icon in the roles column
editIconnodeThe component to use for the edit icon in the roles column
treeAddIconnodeThe component to use for the add icon in the tree
treeCollapseIconnodeThe component to use for the collapse icon in the tree
treeDeleteIconnodeThe component to use for the delete icon in the tree
treeExpandIconnodeThe component to use for the expand icon in the tree
treeEditIconnodeThe component to use for the edit icon in the tree
treeNodeIconnodeThe component to use for the non-expandable node in the tree
treeParentIconnodeThe component to use for the expandable node in the tree

The Components object:

NameTypeDescription
addResourcenodeThe component to use for the Add Resource block
addRolenodeThe component to use for the Add Role block
checkboxTableContainernodeThe component to use for the container of the checkbox table
roleTagnodeThe component to use for the role name tag

License

Licensed under the MIT License, Copyright © 2021-present Dekel Braunstein.

See LICENSE for more information.

FAQs

Last updated on 10 Mar 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc