public/js/views/role.js in conjur-asset-ui-1.3.1 vs public/js/views/role.js in conjur-asset-ui-1.3.2
- old
+ new
@@ -1,56 +1,41 @@
/** @jsx React.DOM */
-/* global conjur, React, _ */
-(function(conjur, React, _) {
- 'use strict';
+/** render a link to the role represented by this.props.id
+ Example: <RoleLink id="ci:user:jon"/>
+*/
+var RoleLink = React.createClass({
+ render: function() {
+ var tokens = this.props.id.split(":");
+ var kind = tokens[1];
+ var id = tokens[tokens.length-1];
+ if (tokens.length==1) { // just username
+ kind="user";
+ id=tokens[0];
+ }
- /** render a link to the role represented by this.props.id
- Example: <RoleLink id='ci:user:jon'/>
- */
- this.RoleLink = React.createClass({
- render: function() {
- var tokens = this.props.id.split(':'),
- kind = tokens[1],
- id = tokens[tokens.length-1];
+ // TODO: shouldn't point to unknown types
+ var href = "/ui/" + conjur.utils.pluralize(kind) + "/" + encodeURIComponent(id);
+ var classes = ["role-link"];
- if (tokens.length === 1) { // just username
- kind = 'user';
- id = tokens[0];
- }
+ var known_types=['user','group','layer','host','policy'];
+ var kind_is_known = _.contains(known_types, kind);
+ var text = id;
- // 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
+ if( !this.props.noIcon ) {
+ if (kind_is_known) {
+ 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
}
-
- return (
- <a className={classes.join(' ')} href={href}>
- {text}
- </a>
- );
}
- });
+ } else if (text==id) {
+ text=[kind,text].join(":"); // prepend kind to id
+ }
-}).bind(conjur.views)
-(
- conjur,
- React,
- _
-);
+ return <a className={classes.join(' ')} href={href}>
+ {text}
+ </a>;
+ }
+});