Package to render components if them have permissions.
npm install -s goten-react-permissions
var GotenList = require('goten-react-permissions').GotenForm; // ES5
import { GotenList } from 'goten-react-permissions'; // ES6
...
<GotenPermissionsProvider
permissions={permissions}
>
<GotenPermissionsValidator
permission='permission'
>
...
<Component/>
</GotenPermissionsValidator>
...
</GotenPermissionsProvider>
import React, { Component } from 'react'
import { GotenPermissionsProvider,
GotenPermissionsValidator } from 'goten-react-permissions'
import './exampleGotenPermissions.css'
const permissions = ['add', 'edit', 'delete'] //You can obtain this from redux.
export default class App extends Component {
render() {
return (
<GotenPermissionsProvider
permissions = {permissions}
>
<div>Normal Component</div>
<GotenPermissionsValidator
permission='add'
>
<div>ADD COMPONENT</div>
</GotenPermissionsValidator>
<GotenPermissionsValidator
permission = 'edit'
>
<label>EDIT COMPONENT 1</label>
<br/>
<label>EDIT COMPONENT 2</label>
<br/>
</GotenPermissionsValidator>
<GotenPermissionsValidator
permission='delete'
>
<div>DELETE COMPONENT</div>
</GotenPermissionsValidator>
</GotenPermissionsProvider>
)
}
}
Prop Name | Type | Default | Required | Description |
---|---|---|---|---|
permissions | array | true | Array to permissions for show the components. |
Prop Name | Type | Default | Required | Description |
---|---|---|---|---|
permission | string | true | Permission to show the component. |
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.