import React, { PureComponent } from "react" import PropTypes from "prop-types" import { getList } from "core/utils" import { Iterable } from "immutable" export default class Operation extends PureComponent { static propTypes = { operation: PropTypes.instanceOf(Iterable).isRequired, toggleShown: PropTypes.func.isRequired, onTryoutClick: PropTypes.func.isRequired, onCancelClick: PropTypes.func.isRequired, onExecute: PropTypes.func.isRequired, getComponent: PropTypes.func.isRequired, authActions: PropTypes.object, authSelectors: PropTypes.object, specActions: PropTypes.object.isRequired, specSelectors: PropTypes.object.isRequired, layoutActions: PropTypes.object.isRequired, layoutSelectors: PropTypes.object.isRequired, fn: PropTypes.object.isRequired } static defaultProps = { showSummary: true, response: null, allowTryItOut: true, displayOperationId: false, displayRequestDuration: false } shouldComponentUpdate(nextProps) { return this.props.operation !== nextProps.operation } render() { let { toggleShown, onTryoutClick, onCancelClick, onExecute, fn, getComponent, specActions, specSelectors, authActions, authSelectors } = this.props let operationProps = this.props.operation let { isShown, isShownKey, jumpToKey, path, method, op, showSummary, operationId, allowTryItOut, displayOperationId, displayRequestDuration, isDeepLinkingEnabled, tryItOutEnabled, executeInProgress } = operationProps.toJS() let response = operationProps.get("response") let request = operationProps.get("request") let { summary, description, deprecated, externalDocs, schemes } = op.operation let operation = operationProps.getIn(["op", "operation"]) let responses = operation.get("responses") let produces = operation.get("produces") let security = operation.get("security") || specSelectors.security() let parameters = getList(operation, ["parameters"]) let operationScheme = specSelectors.operationScheme(path, method) const Responses = getComponent("responses") const Parameters = getComponent( "parameters" ) const Execute = getComponent( "execute" ) const Clear = getComponent( "clear" ) const AuthorizeOperationBtn = getComponent( "authorizeOperationBtn" ) const JumpToPath = getComponent("JumpToPath", true) const Collapse = getComponent( "Collapse" ) const Markdown = getComponent( "Markdown" ) const Schemes = getComponent( "schemes" ) // Merge in Live Response if(responses && response && response.size > 0) { let notDocumented = !responses.get(String(response.get("status"))) response = response.set("notDocumented", notDocumented) } let onChangeKey = [ path, method ] // Used to add values to _this_ operation ( indexed by path and method ) return (