Created
August 29, 2018 05:17
-
-
Save iswanj/41dee7caed092016a0b8cdaece8be012 to your computer and use it in GitHub Desktop.
Permission handle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
const isPremited = (roles, type) => { | |
// premission check logic | |
return ...; | |
} | |
export default () => { | |
let { roles, permissionId, children } = this.props; | |
if(!isPremited(roles, permissionId)) return </div>; | |
return ( | |
<React.Fragment>{children}</React.Fragment> | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import Access from "./Access"; | |
export default class TodoList extends React.Component { | |
render() { | |
return ( | |
<div> | |
<Access roles={this.props.roles} permissionId="VIEW_TODO" > | |
<ToDos /> | |
</Access> | |
<Access roles={this.props.roles} permissionId="ADD_TODO" > | |
<AddTodo /> | |
</Access> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment