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 Modals from '../components/modals/ModalContainer' import KeyValueEditor from '../components/base/KeyValueEditor' import RequestBodyEditor from '../components/RequestBodyEditor' import RequestAuthEditor from '../components/RequestAuthEditor' import RequestUrlBar from '../components/RequestUrlBar' import Sidebar from '../components/Sidebar' import * as GlobalActions from '../actions/global' import * as RequestGroupActions from '../actions/requestGroups' import * as RequestActions from '../actions/requests' import * as ResponseActions from '../actions/responses' // Don't inject component styles (use our own) Tabs.setUseDefaultStyles(false); class App extends Component { _renderPageBody (actions, activeRequest, activeResponse, tabs) { if (!activeRequest) { return
; } return (
{actions.updateRequest({id: activeRequest.id, url})}} onMethodChange={method => {actions.updateRequest({id: activeRequest.id, method})}} request={activeRequest}/>
actions.selectTab('request', i)} selectedIndex={tabs.request || 0}> {actions.updateRequest({id: activeRequest.id, body})}} request={activeRequest}/> actions.updateRequest({id: activeRequest.id, params})} /> actions.updateRequest({id: activeRequest.id, authentication})} /> actions.updateRequest({id: activeRequest.id, headers})} />
200 SUCCESS
TIME 143ms
actions.selectTab('response', i)} selectedIndex={tabs.response || 0}>
{!activeResponse ? null : activeResponse.headers.map((h, i) => (
{h.name}
{h.value}
))}
) } render () { const {actions, requests, responses, requestGroups, tabs} = this.props; const activeRequest = requests.all.find(r => r.id === requests.active); const activeResponse = responses[activeRequest && activeRequest.id]; return (
{/*

Hi World

*/} {this._renderPageBody(actions, activeRequest, activeResponse, tabs)}
) } } App.propTypes = { actions: PropTypes.shape({ activateRequest: PropTypes.func.isRequired, deleteRequestGroup: PropTypes.func.isRequired, addRequest: PropTypes.func.isRequired, sendRequest: PropTypes.func.isRequired, updateRequest: PropTypes.func.isRequired, changeFilter: PropTypes.func.isRequired, toggleRequestGroup: PropTypes.func.isRequired, updateRequestGroup: PropTypes.func.isRequired }).isRequired, requestGroups: PropTypes.shape({ all: PropTypes.array.isRequired }).isRequired, requests: PropTypes.shape({ all: PropTypes.array.isRequired, active: PropTypes.string // "required" but can be null }).isRequired, responses: PropTypes.object.isRequired, tabs: PropTypes.object.isRequired }; function mapStateToProps (state) { return { actions: state.actions, requests: state.requests, requestGroups: state.requestGroups, responses: state.responses, tabs: state.tabs }; } function mapDispatchToProps (dispatch) { return { actions: Object.assign( {}, bindActionCreators(GlobalActions, dispatch), bindActionCreators(RequestGroupActions, dispatch), bindActionCreators(RequestActions, dispatch), bindActionCreators(ResponseActions, dispatch) ) } } export default connect( mapStateToProps, mapDispatchToProps )(App);