/** @jsx React.DOM */ /* global conjur, React, ReactBootstrap, _ */ (function(conjur, React, ReactBootstrap, _) { 'use strict'; var TabPane = ReactBootstrap.TabPane, OwnedResources = conjur.views.OwnedResources, RoleLink = conjur.views.RoleLink, AnnotationsBox = conjur.views.AnnotationsBox, Permissions = conjur.views.Permissions; // 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 ); }, ownedIds: function() { if (this.containsOwnedItems()) { return this.props.data.owned.map(function(ownedItem) { return ownedItem.id; }); } return []; }, ownedTab: function() { if (this.containsOwnedItems()) { var result = ( ); return result; } return null; }, containsNontrivialRoles: function() { return ( this.props.data.roles && this.props.data.roles.length && this.props.data.roles.length > 1 ); }, externalRoles: function(ownId) { if (!this.containsNontrivialRoles()) { return []; } var ownedIds = this.ownedIds(); return this.props.data.roles.filter(function(roleid) { // do not show themself return roleid !== ownId; }).filter(function(roleid) { // do not show internal roles return roleid.split(':')[1] !== '@'; }).filter(function(roleid) { // do not show owned groups return ! _.contains(ownedIds, roleid); }); }, membershipsTab: function(ownId) { if (!this.containsNontrivialRoles()) { return null; } var membershipLinks = this.externalRoles(ownId) .sort(function(a, b) { return a.toLowerCase().localeCompare(b.toLowerCase()); }) .map(function(roleid) { return (
  • ); }); if (membershipLinks.length === 0) { return null; } var result = ( ); return result; }, containsAnnotations: function() { return ( this.props.data.annotations && this.props.data.annotations.length && this.props.data.annotations.length > 0 ); }, annotationsTab: function() { if (!this.containsAnnotations()) { return null; } var result = ( ); return result; }, permissionsTab: function(roleid) { var result = ( ); return result; } }; }).bind(conjur.views.mixins) ( conjur, React, ReactBootstrap, _ );