/** @jsx React.DOM */ /* global conjur, React, _ */ (function(conjur, React, _) { 'use strict'; var knownTypes = ['user', 'group', 'layer', 'host', 'variable', 'policy']; var OwnedResourcesBox = this.OwnedResourcesBox = React.createClass({ getInitialState: function() { return { filter: '' }; }, handleChange: function(e) { e.preventDefault(); this.setState({filter: e.target.value}); }, render: function() { var filters = []; if (!this.props.resources) { return ( None ); } var items = this.props.resources .sort(function(a, b) { // TODO: sort by kind with custom weights, by id, by creation date // automatically gives sort by kind, id return a.id.toLowerCase().localeCompare(b.id.toLowerCase()); }).map(function(resource) { var kind = resource.id.split(':')[1]; filters.push(kind); if ((this.state.filter === '') || (this.state.filter !== 'other' && this.state.filter === kind) || (this.state.filter === 'other' && _.intersection([kind], knownTypes).length === 0)) { var ResourceLink = conjur.views.ResourceLink; return (
  • ); } return ''; }.bind(this)); var toggleButton = ''; if (!this.props.tabview) { toggleButton = (
    Hide all «
    ); } var filterSelect = ''; if (this.props.resources.length > 9 || this.state.filter !== '') { // TODO: sort, when done with previous TODO filterSelect = _.intersection(_.uniq(filters, true), knownTypes).map(function(f) { return ( ); }); filterSelect = (
    ); } return (
    {toggleButton} {filterSelect}
    ); } }); var OwnedResourcesSummary = React.createClass({ render: function() { var expand = ''; if (this.props.length > 0) { expand = (
    Show all »
    ); } var message = ''; if (this.props.length === 0) { message = 'none'; } else { message = '' + this.props.length + ' things'; } return (
    {message} {expand}
    ); } }); this.OwnedResources = React.createClass({ getInitialState: function() { return { expanded: false }; }, toggle: function(e) { e.preventDefault(); this.setState({expanded: !this.state.expanded}); }, render: function() { var content = null; if (this.state.expanded || this.props.tabview) { content = ( ); } else { content = ( ); } var ownedheader = this.props.tabview ? '': (

    Owned assets

    ); return (
    {ownedheader}
    {content}
    ); } }); }).bind(conjur.views) ( conjur, React, _ );