var React = require('react'); var ResourceLink = require('../generic/resource_link'), RoleLink = require('../generic/role_link'); import {sortBy, flatten} from 'lodash'; // Renders a permission as a tr var PermissionRow = React.createClass({ displayName: 'PermissionRow', render() { var p = this.props.data; return ( {p.privilege} {p.grant_option ? 'yes' : 'no'} ); } }); export default React.createClass({ displayName: 'PermissionsTable', render() { var rows = []; var resources = sortBy(this.props.resources, function(r) { return r.id; // this way it will be sorting by (kind, id) }); resources.forEach(function(r) { var rowspan = r.permissions.length + 1, parts = r.id.split(':'), kind = parts[1]; // ignore env? var cells = [ ( ), ( {kind} ) ]; if (rowspan === 1) { cells.push( full permissions ); } rows.push( ({cells}) ); if (rowspan > 1) { rows.push(r.permissions.map(function(p) { return ( ); })); } }); rows = flatten(rows); var showhidelink = (
Hide all «
); if (this.props.tabview) { showhidelink = ''; } if (rows.length === 0) { return ( None ); } return (
{showhidelink} {rows}
Resource Kind Privilege Can Grant? Granted By
); } });