public/js/views/dashboard.js in conjur-asset-ui-1.3.1 vs public/js/views/dashboard.js in conjur-asset-ui-1.3.2

- old
+ new

@@ -1,103 +1,67 @@ /**@jsx React.DOM*/ -/* global conjur, React, jQuery */ -(function(conjur, React, $) { - 'use strict'; +var DashboardSearchForm = React.createClass({ + mixins: [ conjur.views.mixins.Search ], - var OwnedResourcesBox = conjur.views.OwnedResourcesBox, - Search = conjur.views.mixins.Search; + render: function() { + return ( + <form id="dashboard-search" className="form-inline search" role="search" onSubmit={this.handleSubmit}> + <div className="form-group"> + <input ref="input" type="text" className="form-control" placeholder="Search Conjur" value={this.props.searchText}> + </input> + </div> + <button type="submit" className="btn btn-default search-button">Search</button> + </form> + ); + } +}); - var DashboardSearchForm = React.createClass({ - mixins: [Search], +var DashboardFrequent = React.createClass({ + getInitialState: function() { + return {resources: [], loaded: false} + }, - render: function() { - return ( - <form id="dashboard-search" - className="form-inline search" - role="search" - onSubmit={this.handleSubmit}> - <div className="form-group"> - <input ref="input" - type="text" - className="form-control" - placeholder="Search Conjur" - value={this.props.searchText} /> - </div> - <button type="submit" className="btn btn-default search-button"> - Search - </button> - </form> - ); - } - }); + componentWillMount: function() { + $.get("/api/authz/" + conjur.app.configuration.account + "/resources?owner=" + encodeURIComponent(conjur.app.userId), function(data) { + var filtered_data = data.filter( function(item) { + return item.id.split(':')[1]!="secret"; // assets of 'secret' kind are internal + }); + this.setState({resources: filtered_data, loaded: true}); + }.bind(this)); + }, - var DashboardFrequent = React.createClass({ - getInitialState: function() { - return {resources: [], loaded: false}; - }, + render: function() { + var content, + OwnedResourcesBox = conjur.views.OwnedResourcesBox; - componentWillMount: function() { - $.get('/api/authz/' + - conjur.app.configuration.account + - '/resources?owner=' + - encodeURIComponent(conjur.app.userId), - function(data) { - var filteredData = data.filter(function(item) { - // assets of 'secret' kind are internal - return item.id.split(':')[1] !== 'secret'; - }); + if (this.state.loaded) + content = <OwnedResourcesBox resources={this.state.resources} /> + else + content = <span>Loading...</span> - this.setState({resources: filteredData, loaded: true}); - }.bind(this)); - }, + return <section> + <h3>Owned assets</h3> + {content} + </section>; + } +}); - render: function() { - var content; - - if (this.state.loaded) { - content = ( - <OwnedResourcesBox resources={this.state.resources} /> - ); - } else { - content = ( - <span>Loading...</span> - ); - } - - return ( - <section> - <h3>Owned assets</h3> - {content} - </section> - ); - } - }); - - this.Dashboard = React.createClass({ - render: function() { - var AuditTable = window.AuditTable; - - return ( - <div className="dashboard"> - <div className="row"> - <DashboardSearchForm /> - </div> - <div className="row summary"> - <div className="col-xs-6"> - <DashboardFrequent /> - </div> - <div className="col-xs-6 audit"> - <AuditTable src={'/api/audit/all'} caption={'Recent activity'} compact={true}/> - </div> - </div> - </div> - ); - } - }); - -}).bind(conjur.views) -( - conjur, - React, - jQuery -); +var Dashboard = React.createClass({ + render: function(){ + return ( + <div className="dashboard"> + <div className="row"> + <DashboardSearchForm /> + </div> + <div className="row summary"> + <div className="col-xs-6"> + <DashboardFrequent /> + </div> + <div className="col-xs-6 audit"> + <AuditTable src={'/api/audit/all'} caption={'Recent activity'} compact={true}/> + </div> + </div> + </div> + ); + } +});