Goten Permissions
Package to render components if them have permissions.
Index
Install
npm install -s goten-react-permissions
Usage
var GotenList = GotenForm; // ES5import GotenList from 'goten-react-permissions'; // ES6...<GotenPermissionsProvider=><GotenPermissionsValidator='permission'>...<Component/></GotenPermissionsValidator>...</GotenPermissionsProvider>
Example of use
import React Component from 'react'import GotenPermissionsProviderGotenPermissionsValidator from 'goten-react-permissions'import './exampleGotenPermissions.css'const permissions = 'add' 'edit' 'delete' //You can obtain this from redux.{return<GotenPermissionsProvider=><div>Normal Component</div><GotenPermissionsValidator='add'><div>ADD COMPONENT</div></GotenPermissionsValidator><GotenPermissionsValidator= 'edit'><label>EDIT COMPONENT 1</label><br/><label>EDIT COMPONENT 2</label><br/></GotenPermissionsValidator><GotenPermissionsValidator='delete'><div>DELETE COMPONENT</div></GotenPermissionsValidator></GotenPermissionsProvider>}
Props
GotenPermissionsProvider
Prop Name | Type | Default | Required | Description |
---|---|---|---|---|
permissions | array | true | Array to permissions for show the components. |
GotenPermissionsValidator
Prop Name | Type | Default | Required | Description |
---|---|---|---|---|
permission | string | true | Permission to show the component. |
Contributions
To contribute to this package, we propose the following workflow:
- Add an issue with related tags to describe the contribution (is it a bug?, a feature request?).
- Branch your solution from develop, with the name as
#<issue_number>_<descriptive_name>
. - Send a pull request and wait for approval/corrections.