import React, { PureComponent } from "react" import PropTypes from "prop-types" import { Iterable, List } from "immutable" import ImPropTypes from "react-immutable-proptypes" import toString from "lodash/toString" export default class OperationSummary extends PureComponent { static propTypes = { specPath: ImPropTypes.list.isRequired, operationProps: PropTypes.instanceOf(Iterable).isRequired, isShown: PropTypes.bool.isRequired, toggleShown: PropTypes.func.isRequired, getComponent: PropTypes.func.isRequired, getConfigs: PropTypes.func.isRequired, authActions: PropTypes.object, authSelectors: PropTypes.object, } static defaultProps = { operationProps: null, specPath: List(), summary: "" } render() { let { isShown, toggleShown, getComponent, authActions, authSelectors, operationProps, specPath, } = this.props let { summary, isAuthorized, method, op, showSummary, path, operationId, originalOperationId, displayOperationId, } = operationProps.toJS() let { summary: resolvedSummary, } = op let security = operationProps.get("security") const AuthorizeOperationBtn = getComponent("authorizeOperationBtn", true) const OperationSummaryMethod = getComponent("OperationSummaryMethod") const OperationSummaryPath = getComponent("OperationSummaryPath") const JumpToPath = getComponent("JumpToPath", true) const CopyToClipboardBtn = getComponent("CopyToClipboardBtn", true) const ArrowUpIcon = getComponent("ArrowUpIcon") const ArrowDownIcon = getComponent("ArrowDownIcon") const hasSecurity = security && !!security.count() const securityIsOptional = hasSecurity && security.size === 1 && security.first().isEmpty() const allowAnonymous = !hasSecurity || securityIsOptional return (
{ allowAnonymous ? null : { const applicableDefinitions = authSelectors.definitionsForRequirements(security) authActions.showDefinitions(applicableDefinitions) }} /> } {/* TODO: use wrapComponents here, swagger-ui doesn't care about jumpToPath */}
) } }