Sha256: 6c8f1e495b8b51ac6848ab461a403899ee89154e15f4d81fa721806d092980ad
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 KB
Contents
var React = require('react'), Router = require('react-router'); import {includes} from 'lodash'; var Link = Router.Link; /** render a link to the role represented by this.props.id Example: <RoleLink id='ci:user:jon'/> */ export default React.createClass({ displayName: 'RoleLink', knownTypes: ['user', 'group', 'layer', 'host', 'policy'], render() { // guard against misuse such as https://github.com/conjurinc/conjur-asset-ui/issues/78 if (typeof this.props.id === 'undefined') { return ( <em>undefined</em> ); } var tokens = this.props.id.split(':'), kind = tokens[1], id = tokens[tokens.length-1]; if (tokens.length === 1) { // just username kind = 'user'; id = tokens[0]; } var kindIsKnown = includes(this.knownTypes, kind), text = id, classes = ['role-link']; if (!this.props.noIcon) { if (kindIsKnown) { classes.push(kind); } else { classes.push('abstract'); // we have no picture for abstract role yet if (text === id) { text = [kind, text].join(':'); // prepend kind to id } } } else if (text === id) { text = [kind, text].join(':'); // prepend kind to id } if (kindIsKnown) { return ( <Link to={kind} params={{id: window.encodeURIComponent(id)}} className={classes.join(' ')} style={this.props.style}> {text} </Link> ); } else { return ( <a href="#" className={classes.join(' ')} style={this.props.style}> {text} </a> ); } } });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
conjur-asset-ui-1.6.0 | app/src/components/generic/role_link.js |