Convert pathMethod prop to two separate props.
This commit is contained in:
@@ -30,17 +30,18 @@ export default class LiveResponse extends React.Component {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
response: PropTypes.object.isRequired,
|
response: PropTypes.object.isRequired,
|
||||||
specSelectors: PropTypes.object.isRequired,
|
specSelectors: PropTypes.object.isRequired,
|
||||||
pathMethod: PropTypes.object.isRequired,
|
path: PropTypes.string.isRequired,
|
||||||
|
method: PropTypes.string.isRequired,
|
||||||
getComponent: PropTypes.func.isRequired,
|
getComponent: PropTypes.func.isRequired,
|
||||||
displayRequestDuration: PropTypes.bool.isRequired,
|
displayRequestDuration: PropTypes.bool.isRequired,
|
||||||
getConfigs: PropTypes.func.isRequired
|
getConfigs: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { response, getComponent, getConfigs, displayRequestDuration, specSelectors, pathMethod } = this.props
|
const { response, getComponent, getConfigs, displayRequestDuration, specSelectors, path, method } = this.props
|
||||||
const { showMutatedRequest } = getConfigs()
|
const { showMutatedRequest } = getConfigs()
|
||||||
|
|
||||||
const curlRequest = showMutatedRequest ? specSelectors.mutatedRequestFor(pathMethod[0], pathMethod[1]) : specSelectors.requestFor(pathMethod[0], pathMethod[1])
|
const curlRequest = showMutatedRequest ? specSelectors.mutatedRequestFor(path, method) : specSelectors.requestFor(path, method)
|
||||||
const status = response.get("status")
|
const status = response.get("status")
|
||||||
const url = response.get("url")
|
const url = response.get("url")
|
||||||
const headers = response.get("headers").toJS()
|
const headers = response.get("headers").toJS()
|
||||||
|
|||||||
@@ -213,7 +213,8 @@ export default class Operation extends PureComponent {
|
|||||||
specActions={ specActions }
|
specActions={ specActions }
|
||||||
produces={ produces }
|
produces={ produces }
|
||||||
producesValue={ operation.get("produces_value") }
|
producesValue={ operation.get("produces_value") }
|
||||||
pathMethod={ [path, method] }
|
path={ path }
|
||||||
|
method={ method }
|
||||||
displayRequestDuration={ displayRequestDuration }
|
displayRequestDuration={ displayRequestDuration }
|
||||||
fn={fn} />
|
fn={fn} />
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,18 +4,18 @@ import { fromJS, Iterable } from "immutable"
|
|||||||
import { defaultStatusCode } from "core/utils"
|
import { defaultStatusCode } from "core/utils"
|
||||||
|
|
||||||
export default class Responses extends React.Component {
|
export default class Responses extends React.Component {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
request: PropTypes.instanceOf(Iterable),
|
request: PropTypes.instanceOf(Iterable),
|
||||||
tryItOutResponse: PropTypes.instanceOf(Iterable),
|
tryItOutResponse: PropTypes.instanceOf(Iterable),
|
||||||
responses: PropTypes.instanceOf(Iterable).isRequired,
|
responses: PropTypes.instanceOf(Iterable).isRequired,
|
||||||
produces: PropTypes.instanceOf(Iterable),
|
produces: PropTypes.instanceOf(Iterable),
|
||||||
producesValue: PropTypes.any,
|
producesValue: PropTypes.any,
|
||||||
|
displayRequestDuration: PropTypes.bool.isRequired,
|
||||||
|
path: PropTypes.string.isRequired,
|
||||||
|
method: PropTypes.string.isRequired,
|
||||||
getComponent: PropTypes.func.isRequired,
|
getComponent: PropTypes.func.isRequired,
|
||||||
specSelectors: PropTypes.object.isRequired,
|
specSelectors: PropTypes.object.isRequired,
|
||||||
specActions: PropTypes.object.isRequired,
|
specActions: PropTypes.object.isRequired,
|
||||||
pathMethod: PropTypes.array.isRequired,
|
|
||||||
displayRequestDuration: PropTypes.bool.isRequired,
|
|
||||||
fn: PropTypes.object.isRequired,
|
fn: PropTypes.object.isRequired,
|
||||||
getConfigs: PropTypes.func.isRequired
|
getConfigs: PropTypes.func.isRequired
|
||||||
}
|
}
|
||||||
@@ -27,9 +27,26 @@ export default class Responses extends React.Component {
|
|||||||
displayRequestDuration: false
|
displayRequestDuration: false
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangeProducesWrapper = ( val ) => this.props.specActions.changeProducesValue(this.props.pathMethod, val)
|
shouldComponentUpdate(nextProps) {
|
||||||
|
console.log("Responses SCU", this.props.tryItOutResponse.toJS(), nextProps.tryItOutResponse.toJS())
|
||||||
|
let render = this.props.request !== nextProps.request
|
||||||
|
|| this.props.tryItOutResponse !== nextProps.tryItOutResponse
|
||||||
|
|| this.props.responses !== nextProps.responses
|
||||||
|
|| this.props.produces !== nextProps.produces
|
||||||
|
|| this.props.producesValue !== nextProps.producesValue
|
||||||
|
|| this.props.displayRequestDuration !== nextProps.displayRequestDuration
|
||||||
|
|| this.props.path !== nextProps.path
|
||||||
|
|| this.props.method !== nextProps.method
|
||||||
|
|
||||||
|
console.log("render", render)
|
||||||
|
|
||||||
|
return render
|
||||||
|
}
|
||||||
|
|
||||||
|
onChangeProducesWrapper = ( val ) => this.props.specActions.changeProducesValue([this.props.path, this.props.method], val)
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
console.log("Responses render")
|
||||||
let { responses, request, tryItOutResponse, getComponent, getConfigs, specSelectors, fn, producesValue, displayRequestDuration } = this.props
|
let { responses, request, tryItOutResponse, getComponent, getConfigs, specSelectors, fn, producesValue, displayRequestDuration } = this.props
|
||||||
let defaultCode = defaultStatusCode( responses )
|
let defaultCode = defaultStatusCode( responses )
|
||||||
|
|
||||||
@@ -60,7 +77,8 @@ export default class Responses extends React.Component {
|
|||||||
getComponent={ getComponent }
|
getComponent={ getComponent }
|
||||||
getConfigs={ getConfigs }
|
getConfigs={ getConfigs }
|
||||||
specSelectors={ specSelectors }
|
specSelectors={ specSelectors }
|
||||||
pathMethod={ this.props.pathMethod }
|
path={ this.props.path }
|
||||||
|
method={ this.props.method }
|
||||||
displayRequestDuration={ displayRequestDuration } />
|
displayRequestDuration={ displayRequestDuration } />
|
||||||
<h4>Responses</h4>
|
<h4>Responses</h4>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user