insomnia/app/components/Sidebar.js

101 lines
3.5 KiB
JavaScript
Raw Normal View History

2016-03-23 05:26:27 +00:00
import React, {Component, PropTypes} from 'react'
2016-03-22 05:01:58 +00:00
import Dropdown from './base/Dropdown'
2016-03-23 05:26:27 +00:00
import DebouncingInput from './base/DebouncingInput'
2016-03-18 00:36:00 +00:00
2016-03-23 05:26:27 +00:00
class Sidebar extends Component {
onFilterChange (value) {
this.props.changeFilter(value);
}
render () {
const {
requests,
activeRequest,
activeFilter,
loading,
activateRequest,
addRequest
} = this.props;
return (
<aside className="sidebar pane">
<div className="grid-v">
<header className="pane__header bg-primary">
<h1>
<Dropdown right={true}>
2016-03-23 18:34:39 +00:00
<button className="pane__header__content">
2016-03-23 05:26:27 +00:00
<i className="fa fa-angle-down pull-right"></i>
{loading ? <i className="fa fa-refresh fa-spin pull-right"></i> : ''}
Insomnia
2016-03-23 18:34:39 +00:00
</button>
2016-03-23 05:26:27 +00:00
<ul className="bg-super-light">
2016-03-23 18:34:39 +00:00
<li>
<button onClick={(e) => addRequest()}>
<i className="fa fa-plus-circle"></i> Add Request
</button>
</li>
<li><button><i className="fa fa-share-square-o"></i> Import/Export</button></li>
<li><button><i className="fa fa-empty"></i> Toggle Sidebar</button></li>
<li><button><i className="fa fa-empty"></i> Delete Workspace</button></li>
2016-03-23 05:26:27 +00:00
</ul>
</Dropdown>
</h1>
</header>
<div className="pane__body hide-scrollbars bg-dark">
<div className="stock-height form-control form-control--outlined col">
<DebouncingInput
type="text"
placeholder="Filter Requests"
debounceMillis={100}
value={activeFilter}
onChange={this.onFilterChange.bind(this)}/>
2016-03-22 05:01:58 +00:00
</div>
2016-03-23 05:26:27 +00:00
<ul>
<li>
2016-03-23 17:15:19 +00:00
<div className="grid">
<button className="sidebar__item col text-left">
<i className="fa fa-folder-open-o"></i>&nbsp;&nbsp;&nbsp;Request Group
</button>
<button className="sidebar__item-btn" onClick={(e) => addRequest()}>
2016-03-23 05:26:27 +00:00
<i className="fa fa-plus-circle"></i>
</button>
</div>
<ul>
{requests.filter(request => {
if (!activeFilter) {
return true;
}
return request.name.toLowerCase().indexOf(activeFilter.toLowerCase()) >= 0;
}).map(request => {
const isActive = request.id === activeRequest.id;
return (
<li key={request.id} className={isActive ? 'active': ''}>
2016-03-23 17:15:19 +00:00
<button onClick={() => {activateRequest(request.id)}}
className="sidebar__item">
2016-03-23 05:26:27 +00:00
{request.name}
</button>
</li>
);
})}
</ul>
2016-03-22 05:01:58 +00:00
</li>
2016-03-23 05:26:27 +00:00
</ul>
</div>
</div>
</aside>
)
}
}
2016-03-18 00:36:00 +00:00
2016-03-20 04:00:40 +00:00
Sidebar.propTypes = {
2016-03-20 04:47:43 +00:00
activateRequest: PropTypes.func.isRequired,
2016-03-22 05:01:58 +00:00
addRequest: PropTypes.func.isRequired,
2016-03-23 05:26:27 +00:00
changeFilter: PropTypes.func.isRequired,
activeFilter: PropTypes.string,
2016-03-20 23:20:00 +00:00
requests: PropTypes.array.isRequired,
activeRequest: PropTypes.object,
2016-03-20 04:00:40 +00:00
loading: PropTypes.bool.isRequired
};
2016-03-18 00:36:00 +00:00
export default Sidebar;