import React, {Component, PropTypes} from 'react' import {connect} from 'react-redux' import {bindActionCreators} from 'redux' import {Tab, Tabs, TabList, TabPanel} from 'react-tabs'; import Editor from '../components/base/Editor' import RequestBodyEditor from '../components/RequestBodyEditor' import RequestUrlBar from '../components/RequestUrlBar' import Sidebar from '../components/Sidebar' import * as RequestActions from '../actions/requests' import * as RequestGroupActions from '../actions/requestGroups' import * as GlobalActions from '../actions/global' // Don't inject component styles (use our own) Tabs.setUseDefaultStyles(false); class App extends Component { renderPageBody (actions, activeRequest) { if (!activeRequest) { return
; } const updateRequestBody = actions.updateRequestBody.bind(null, activeRequest.id); const updateRequestUrl = actions.updateRequestUrl.bind(null, activeRequest.id); const updateRequestMethod = actions.updateRequestMethod.bind(null, activeRequest.id); return (
Params Basic Auth Headers
200 SUCCESS
TIME 143ms
Headers Cookies
) } render () { const {actions, loading, requests, requestGroups} = this.props; const activeRequest = requests.all.find(r => r.id === requests.active); return (
{this.renderPageBody(actions, activeRequest)}
) } } App.propTypes = { actions: PropTypes.shape({ activateRequest: PropTypes.func.isRequired, updateRequestBody: PropTypes.func.isRequired, updateRequestUrl: PropTypes.func.isRequired, changeFilter: PropTypes.func.isRequired, updateRequestMethod: PropTypes.func.isRequired, toggleRequestGroup: PropTypes.func.isRequired }).isRequired, requests: PropTypes.shape({ all: PropTypes.array.isRequired, active: PropTypes.string // "required" but can be null }).isRequired, requestGroups: PropTypes.shape({ all: PropTypes.array.isRequired }).isRequired, loading: PropTypes.bool.isRequired }; function mapStateToProps (state) { return { actions: state.actions, requests: state.requests, requestGroups: state.requestGroups, loading: state.loading }; } function mapDispatchToProps (dispatch) { return { actions: Object.assign( {}, bindActionCreators(GlobalActions, dispatch), bindActionCreators(RequestActions, dispatch), bindActionCreators(RequestGroupActions, dispatch) ) } } export default connect( mapStateToProps, mapDispatchToProps )(App);