/** @jsx React.DOM */
(function(conjur, ReactBootstrap) {
'use strict';
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
conjur.views.mixins.Tab = {
lexical_sorter: function(a,b) {
},
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 [];
},
owned_tab: function() {
if (this.contains_owned_items()) {
var result =
;
return result;
}
return null;
},
contains_nontrivial_roles: function() {
return (this.props.data.roles && this.props.data.roles.length && this.props.data.roles.length>1);
},
external_roles: function( own_id ) {
if (!this.contains_nontrivial_roles()) {
return [];
}
var owned_ids = this.owned_ids();
return this.props.data.roles.filter(function(roleid) {
// do not show themself
return roleid!=own_id;
}).filter(function(roleid) {
// do not show internal roles
return ! (roleid.split(':')[1]=='@') ;
}).filter(function(roleid) {
// do not show owned groups
return ! _.contains(owned_ids, roleid);
});
},
memberships_tab: function( own_id ) {
if (!this.contains_nontrivial_roles()) {
return null;
}
var membership_links = this.external_roles(own_id)
.sort( function(a,b) { return a.toLowerCase().localeCompare(b.toLowerCase());} )
.map ( function(roleid) { return
});
if (membership_links.length==0) { return null; }
var result =
;
return result;
} ,
contains_annotations: function() {
return (this.props.data.annotations && this.props.data.annotations.length && this.props.data.annotations.length>0);
},
annotations_tab: function() {
if (!this.contains_annotations()) {
return null;
}
var result =
;
return result;
},
permissions_tab: function(roleid) {
var result =
;
return result;
}
};
})(conjur, ReactBootstrap);