Sha256: 4bacd552982ab63b2a2e9728df97498708f7be2bd19c19bc30d0a239598ad3c3

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

/** @jsx React.DOM */

var OwnedResourcesBox = React.createClass({
  render: function() {
    var items = this.props.resources.map(function(resource) {
      return <li>
          <ResourceLink data={resource} />
        </li>
    });
    
    return <div className="owned">
      <div className="hide-all">
        <a onClick={this.props.hideHandler}>Hide all &laquo;</a>
      </div>
      <ul>
        {items}
      </ul>
    </div>
  }
});

var OwnedResourcesSummary = React.createClass({
  render: function() {
    var expand = "";
    if ( this.props.length > 0 )
      expand = <span>
        <br/>
        <span>
          <a onClick={this.props.expandHandler}>Show all &raquo;</a>
        </span>
      </span>;
    
    var message = "";
    if ( this.props.length === 0 )
      message = "none";
    else
      message = "" + this.props.length + " things";
    
    return <div>
      <span>
        {message}
      </span>
      {expand}
    </div>
  }
});

var OwnedResources = React.createClass({
  getInitialState: function() {
    return { expand: false }
  },
  
  expand: function(event) {
    this.setState({expand: true})
  },
  
  collapse: function(event) {
    this.setState({expand: false})
  },
  
  render: function() {
    var owned = this.props.owned;
    
    var content = null;
    if ( this.state.expand )
      content = <OwnedResourcesBox resources={owned} hideHandler={this.collapse} />
    else
      content = <OwnedResourcesSummary length={owned.length} expandHandler={this.expand} />

    return <section className="owned">
      <h3>Owned assets</h3>
      <div id="ownedDetails">
        {content}
      </div>
    </section>;
  }
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conjur-asset-ui-api-1.2.0 public/js/views/owned.js