public/js/views/mixins/tabs.js in conjur-asset-ui-1.3.1 vs public/js/views/mixins/tabs.js in conjur-asset-ui-1.3.2
- old
+ new
@@ -1,154 +1,114 @@
/** @jsx React.DOM */
-/* global conjur, React, ReactBootstrap, _ */
-(function(conjur, React, ReactBootstrap, _) {
+(function(conjur, ReactBootstrap) {
'use strict';
- var TabPane = ReactBootstrap.TabPane,
- OwnedResources = conjur.views.OwnedResources,
- RoleLink = conjur.views.RoleLink,
- AnnotationsBox = conjur.views.AnnotationsBox,
- Permissions = conjur.views.Permissions;
+ var TabbedArea = ReactBootstrap.TabbedArea,
+ TabPane = ReactBootstrap.TabPane,
+ OwnedResources = conjur.views.OwnedResources;
// we can't create custom TabPanes as components,
// because they won't be recognized by TabbedArea as tabs
// that's why we just generalize their constructors
- this.Tab = {
- containsOwnedItems: function() {
- return (
- this.props.data.owned &&
- this.props.data.owned.length &&
- this.props.data.owned.length > 0
- );
+ conjur.views.mixins.Tab = {
+ lexical_sorter: function(a,b) {
+
},
- ownedIds: function() {
- if (this.containsOwnedItems()) {
- return this.props.data.owned.map(function(ownedItem) {
- return ownedItem.id;
+ contains_owned_items: function() {
+ return (this.props.data.owned && this.props.data.owned.length && this.props.data.owned.length > 0 );
+ },
+
+ owned_ids: function() {
+ if (this.contains_owned_items()) {
+ return this.props.data.owned.map(function(owned_item) {
+ return owned_item.id;
});
}
return [];
},
- ownedTab: function() {
- if (this.containsOwnedItems()) {
- var result = (
- <TabPane key="owned"
- tab={conjur.utils.getTabname('Owned resources', this.props.data.owned)}>
- <OwnedResources owned={this.props.data.owned} tabview={true} />
- </TabPane>
- );
+ owned_tab: function() {
+ if (this.contains_owned_items()) {
+ var result =
+ <TabPane key="owned" tab={get_tabname("Owned resources",this.props.data.owned)}>
+ <OwnedResources owned={this.props.data.owned} tabview={true} />
+ </TabPane>;
return result;
}
return null;
},
- containsNontrivialRoles: function() {
- return (
- this.props.data.roles &&
- this.props.data.roles.length &&
- this.props.data.roles.length > 1
- );
+ contains_nontrivial_roles: function() {
+ return (this.props.data.roles && this.props.data.roles.length && this.props.data.roles.length>1);
},
- externalRoles: function(ownId) {
- if (!this.containsNontrivialRoles()) {
+ external_roles: function( own_id ) {
+ if (!this.contains_nontrivial_roles()) {
return [];
}
- var ownedIds = this.ownedIds();
+ var owned_ids = this.owned_ids();
return this.props.data.roles.filter(function(roleid) {
// do not show themself
- return roleid !== ownId;
+ return roleid!=own_id;
}).filter(function(roleid) {
// do not show internal roles
- return roleid.split(':')[1] !== '@';
+ return ! (roleid.split(':')[1]=='@') ;
}).filter(function(roleid) {
// do not show owned groups
- return ! _.contains(ownedIds, roleid);
+ return ! _.contains(owned_ids, roleid);
});
},
- membershipsTab: function(ownId) {
- if (!this.containsNontrivialRoles()) {
+ memberships_tab: function( own_id ) {
+ if (!this.contains_nontrivial_roles()) {
return null;
}
- var membershipLinks = this.externalRoles(ownId)
- .sort(function(a, b) {
- return a.toLowerCase().localeCompare(b.toLowerCase());
- })
- .map(function(roleid) {
- return (
- <li className="list-group-item list-group-item-noborder">
- <RoleLink id={roleid} />
- </li>
- );
- });
+ var membership_links = this.external_roles(own_id)
+ .sort( function(a,b) { return a.toLowerCase().localeCompare(b.toLowerCase());} )
+ .map ( function(roleid) { return <li className="list-group-item list-group-item-noborder"><RoleLink id={roleid}/></li> });
- if (membershipLinks.length === 0) {
- return null;
- }
+ if (membership_links.length==0) { return null; }
- var result = (
- <TabPane key="memberships"
- tab={conjur.utils.getTabname('Explicit memberships', membershipLinks)}>
- <ul className="list-group">
- {membershipLinks}
- </ul>
- </TabPane>
- );
+ var result =
+ <TabPane key="memberships" tab={get_tabname("Explicit memberships", membership_links)}>
+ <ul className="list-group">{membership_links}</ul>
+ </TabPane>;
return result;
- },
+ } ,
- containsAnnotations: function() {
- return (
- this.props.data.annotations &&
- this.props.data.annotations.length &&
- this.props.data.annotations.length > 0
- );
+ contains_annotations: function() {
+ return (this.props.data.annotations && this.props.data.annotations.length && this.props.data.annotations.length>0);
},
- annotationsTab: function() {
- if (!this.containsAnnotations()) {
+ annotations_tab: function() {
+ if (!this.contains_annotations()) {
return null;
}
- var result = (
- <TabPane key="annotations"
- tab={conjur.utils.getTabname('Annotations', this.props.data.annotations)}>
- <AnnotationsBox annotations={this.props.data.annotations} />
- </TabPane>
- );
+ var result =
+ <TabPane key="annotations" tab={get_tabname("Annotations",this.props.data.annotations)}>
+ <AnnotationsBox annotations={this.props.data.annotations}/>
+ </TabPane>;
return result;
},
- permissionsTab: function(roleid) {
- var result = (
- <TabPane key="permissions" tab="Permissions held">
- <Permissions owned={this.props.data.owned}
- roles={this.props.data.roles}
- role={roleid}
- tabview={true} />
- </TabPane>
- );
+ permissions_tab: function(roleid) {
+ var result =
+ <TabPane key="permissions" tab="Permissions held">
+ <Permissions owned={this.props.data.owned} roles={this.props.data.roles} role={roleid} tabview={true}/>
+ </TabPane>;
return result;
}
};
-
-}).bind(conjur.views.mixins)
-(
- conjur,
- React,
- ReactBootstrap,
- _
-);
+})(conjur, ReactBootstrap);