diff --git a/.gitignore b/.gitignore index ad4e0a9a..dedbbf00 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ node_modules .idea +.vscode .deps_check .DS_Store .nyc_output diff --git a/src/core/components/operation-summary-method.jsx b/src/core/components/operation-summary-method.jsx new file mode 100644 index 00000000..b625e725 --- /dev/null +++ b/src/core/components/operation-summary-method.jsx @@ -0,0 +1,25 @@ +import React, { PureComponent } from "react" +import PropTypes from "prop-types" +import { Iterable } from "immutable" + +export default class OperationSummaryMethod extends PureComponent { + + static propTypes = { + operationProps: PropTypes.instanceOf(Iterable).isRequired, + method: PropTypes.string.isRequired, + } + + static defaultProps = { + operationProps: null, + } + render() { + + let { + method, + } = this.props + + return ( + {method.toUpperCase()} + ) + } +} diff --git a/src/core/components/operation-summary-path.jsx b/src/core/components/operation-summary-path.jsx new file mode 100644 index 00000000..7b0d7315 --- /dev/null +++ b/src/core/components/operation-summary-path.jsx @@ -0,0 +1,48 @@ +import React, { PureComponent } from "react" +import PropTypes from "prop-types" +import { Iterable } from "immutable" +import ImPropTypes from "react-immutable-proptypes" + +export default class OperationSummaryPath extends PureComponent{ + + static propTypes = { + specPath: ImPropTypes.list.isRequired, + operationProps: PropTypes.instanceOf(Iterable).isRequired, + getComponent: PropTypes.func.isRequired, + } + + render(){ + let { + getComponent, + operationProps, + specPath, + } = this.props + + + let { + deprecated, + isShown, + path, + tag, + operationId, + isDeepLinkingEnabled, + } = operationProps.toJS() + + let isShownKey = ["operations", tag, operationId] + + const JumpToPath = getComponent("JumpToPath", true) + const DeepLink = getComponent( "DeepLink" ) + + return( + + + {/* TODO: use wrapComponents here, swagger-ui doesn't care about jumpToPath */} + + + ) + } +} diff --git a/src/core/components/operation-summary.jsx b/src/core/components/operation-summary.jsx new file mode 100644 index 00000000..fd60b2ce --- /dev/null +++ b/src/core/components/operation-summary.jsx @@ -0,0 +1,85 @@ +import React, { PureComponent } from "react" +import PropTypes from "prop-types" +import { Iterable, List } from "immutable" +import ImPropTypes from "react-immutable-proptypes" + + +export default class OperationSummary extends PureComponent { + + static propTypes = { + specPath: ImPropTypes.list.isRequired, + operationProps: PropTypes.instanceOf(Iterable).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 { + toggleShown, + getComponent, + authActions, + authSelectors, + operationProps, + specPath, + } = this.props + + let { + summary, + isAuthorized, + method, + op, + showSummary, + operationId, + originalOperationId, + displayOperationId, + } = operationProps.toJS() + + let { + summary: resolvedSummary, + } = op + + let security = operationProps.get("security") + + const AuthorizeOperationBtn = getComponent("authorizeOperationBtn") + const OperationSummaryMethod = getComponent("OperationSummaryMethod") + const OperationSummaryPath = getComponent("OperationSummaryPath") + + return ( + +
+ + + + {!showSummary ? null : +
+ {resolvedSummary || summary} +
+ } + + {displayOperationId && (originalOperationId || operationId) ? {originalOperationId || operationId} : null} + + { + (!security || !security.count()) ? null : + { + const applicableDefinitions = authSelectors.definitionsForRequirements(security) + authActions.showDefinitions(applicableDefinitions) + }} + /> + } +
+ ) + + } +} diff --git a/src/core/components/operation.jsx b/src/core/components/operation.jsx index e58047d8..f784e816 100644 --- a/src/core/components/operation.jsx +++ b/src/core/components/operation.jsx @@ -62,34 +62,26 @@ export default class Operation extends PureComponent { let operationProps = this.props.operation let { - summary, deprecated, isShown, - isAuthorized, path, method, op, tag, - showSummary, operationId, - originalOperationId, allowTryItOut, - displayOperationId, displayRequestDuration, - isDeepLinkingEnabled, tryItOutEnabled, executeInProgress } = operationProps.toJS() let { - summary: resolvedSummary, description, externalDocs, schemes } = op let operation = operationProps.getIn(["op"]) - let security = operationProps.get("security") let responses = operation.get("responses") let produces = operation.get("produces") let parameters = getList(operation, ["parameters"]) @@ -101,14 +93,12 @@ export default class Operation extends PureComponent { 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" ) const OperationServers = getComponent( "OperationServers" ) const OperationExt = getComponent( "OperationExt" ) - const DeepLink = getComponent( "DeepLink" ) + const OperationSummary = getComponent( "OperationSummary" ) const { showExtensions } = getConfigs() @@ -122,39 +112,7 @@ export default class Operation extends PureComponent { return (
-
- {/*TODO: convert this into a component, that can be wrapped - and pulled in with getComponent */} - {method.toUpperCase()} - - - {/*TODO: use wrapComponents here, swagger-ui doesn't care about jumpToPath */} - - - { !showSummary ? null : -
- { resolvedSummary || summary } -
- } - - { displayOperationId && (originalOperationId || operationId) ? {originalOperationId || operationId} : null } - - { - (!security || !security.count()) ? null : - { - const applicableDefinitions = authSelectors.definitionsForRequirements(security) - authActions.showDefinitions(applicableDefinitions) - }} - /> - } -
- +
{ (operation && operation.size) || operation === null ? null : diff --git a/src/core/presets/base.js b/src/core/presets/base.js index 77cabf59..bb821a5e 100644 --- a/src/core/presets/base.js +++ b/src/core/presets/base.js @@ -33,6 +33,9 @@ import OnlineValidatorBadge from "core/components/online-validator-badge" import Operations from "core/components/operations" import OperationTag from "core/components/operation-tag" import Operation from "core/components/operation" +import OperationSummary from "core/components/operation-summary" +import OperationSummaryMethod from "core/components/operation-summary-method" +import OperationSummaryPath from "core/components/operation-summary-path" import OperationExt from "core/components/operation-extensions" import OperationExtRow from "core/components/operation-extension-row" import HighlightCode from "core/components/highlight-code" @@ -102,6 +105,9 @@ export default function() { onlineValidatorBadge: OnlineValidatorBadge, operations: Operations, operation: Operation, + OperationSummary, + OperationSummaryMethod, + OperationSummaryPath, highlightCode: HighlightCode, responses: Responses, response: Response,