/**@jsx React.DOM*/ var SearchGroupTitle = React.createClass({ render: function(){ return {this.title()} }, title: function(){ var words = this.props.data.kind.replace(/[-_]/, ' ').split(' '); words[words.length - 1] = pluralize(words[words.length - 1]); return words.map(_.str.capitalize).join(' ') + ' (' + this.props.data.items.length + ')'; } }); var SearchGroupHeading = React.createClass({ render: function(){ var targetId = "#search-collapse-" + this.props.data.kind; return

; }, title: function(){ var words = this.props.data.kind.replace(/[-_]/, ' ').split(' '); words[words.length - 1] = pluralize(words[words.length - 1]); return words.map(_.str.capitalize).join(' ') + ' (' + this.props.data.items.length + ')'; } }); var SearchResultItem = React.createClass({ render: function(){ return

{ this.titleLink() }

ID: Owner:
{this.commentText()}
; }, commentText: function(){ var annots = this.annotationsMap(); return annots['description'] || ""; }, titleLink: function(){ var annots = this.annotationsMap(); return }, annotationsMap: function(){ if(this._annotationsMap) return this._annotationsMap; var map = this._annotationsMap = {}; (this.props.data.annotations || []).forEach(function(a){ map[a.name] = a.value; }); return map; } }); // accepts props like data: { kind:"", items:[] } var SearchGroup = React.createClass({ render: function(){ var id = "search-group-" + this.props.data.kind; var items = this.props.data.items.map(function(r){ return }) return
{items}
; } }); var SearchResults = React.createClass({ render: function() { var results = this.props.data.results; var grouped = _.groupBy(results, function(r){ return r.id.split(':')[1]; }); // Don't care about these delete grouped['environment-variables'] delete grouped['notification'] delete grouped['queue'] var groups = _.map(grouped,function(items, key){ var data = {items:items, kind: key}; // - prevent editor barfing return }); var scores = { 'policy': 0, 'layer': 1, 'group': 2, 'host': 3, 'user': 4, 'variable': 5, 'key_pair': 6 }; groups.sort(function(a, b) { return ( scores[a.props.data.kind] || 100 ) - ( scores[b.props.data.kind] || 100 ); }); var toc = groups.map(function(g) { var gid = "#search-group-" + g.props.data.kind; return
}); var heading = "Found " + this.props.data.results.length + " resources matching \"" + this.props.data.search + "\""; return (

{ heading }

{toc}
{groups}
); } }); SearchResults.search = function(search, container){ container = container || document.getElementById('content'); $.get(endpoints.authz("resources", {search: search}), function(results){ var data = {search: search, results: results}; React.renderComponent(, container); }); }