/** @jsx React.DOM */
/* global conjur, React, _ */
(function(conjur, React, _) {
'use strict';
/** render a link to the role represented by this.props.id
Example:
*/
this.RoleLink = React.createClass({
render: function() {
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];
}
// TODO: shouldn't point to unknown types
var href = '/ui/' + conjur.utils.pluralize(kind) + '/' + window.encodeURIComponent(id);
var classes = ['role-link'],
knownTypes = ['user','group','layer','host','policy'],
kindIsKnown = _.contains(knownTypes, kind),
text = id;
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
}
return (
{text}
);
}
});
}).bind(conjur.views)
(
conjur,
React,
_
);