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 PromptModal from '../components/base/PromptModal' import KeyValueEditor from '../components/base/KeyValueEditor' import RequestBodyEditor from '../components/RequestBodyEditor' import RequestUrlBar from '../components/RequestUrlBar' import Sidebar from '../components/Sidebar' import {Modal, ModalHeader, ModalBody, ModalFooter} from '../components/base/Modal' 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
; } return (
{actions.updateRequest({id: activeRequest.id, url})}} onMethodChange={method => {actions.updateRequest({id: activeRequest.id, method})}} request={activeRequest}/>
{actions.updateRequest({id: activeRequest.id, body})}} request={activeRequest}/> actions.updateRequest({id: activeRequest.id, params})} /> Basic Auth Hello
200 SUCCESS
TIME 143ms
Headers
) } render () { const {actions, loading, requests, requestGroups, prompt} = this.props; const activeRequest = requests.all.find(r => r.id === requests.active); return (
Header

Hello

Footer
{!prompt ? null : ( actions.hidePrompt(prompt.id)} onSubmit={name => actions.updateRequest({id: prompt.data.id, name})}/> )}
{/*

Hi World

*/} {this.renderPageBody(actions, activeRequest)}
) } } App.propTypes = { actions: PropTypes.shape({ activateRequest: PropTypes.func.isRequired, deleteRequestGroup: PropTypes.func.isRequired, addRequest: PropTypes.func.isRequired, updateRequest: 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, prompt: PropTypes.object }; function mapStateToProps (state) { return { actions: state.actions, requests: state.requests, requestGroups: state.requestGroups, loading: state.loading, prompt: state.prompt }; } function mapDispatchToProps (dispatch) { return { actions: Object.assign( {}, bindActionCreators(GlobalActions, dispatch), bindActionCreators(RequestActions, dispatch), bindActionCreators(RequestGroupActions, dispatch) ) } } export default connect( mapStateToProps, mapDispatchToProps )(App);