File tree Expand file tree Collapse file tree 5 files changed +37
-13
lines changed Expand file tree Collapse file tree 5 files changed +37
-13
lines changed Original file line number Diff line number Diff line change 1+ import React from "react"
2+ import PropTypes from "prop-types"
3+
4+ export const DeepLink = ( { enabled, path, text } ) => {
5+ return (
6+ < a className = "nostyle"
7+ onClick = { enabled ? ( e ) => e . preventDefault ( ) : null }
8+ href = { enabled ? `#/${ path } ` : null } >
9+ < span > { text } </ span >
10+ </ a >
11+ )
12+ }
13+ DeepLink . propTypes = {
14+ enabled : PropTypes . bool ,
15+ isShown : PropTypes . bool ,
16+ path : PropTypes . string ,
17+ text : PropTypes . string
18+ }
19+
20+ export default DeepLink
Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ export default class Operation extends PureComponent {
102102 const Schemes = getComponent ( "schemes" )
103103 const OperationServers = getComponent ( "OperationServers" )
104104 const OperationExt = getComponent ( "OperationExt" )
105+ const DeepLink = getComponent ( "DeepLink" )
105106
106107 const { showExtensions } = getConfigs ( )
107108
@@ -120,12 +121,11 @@ export default class Operation extends PureComponent {
120121 and pulled in with getComponent */ }
121122 < span className = "opblock-summary-method" > { method . toUpperCase ( ) } </ span >
122123 < span className = { deprecated ? "opblock-summary-path__deprecated" : "opblock-summary-path" } >
123- < a
124- className = "nostyle"
125- onClick = { isDeepLinkingEnabled ? ( e ) => e . preventDefault ( ) : null }
126- href = { isDeepLinkingEnabled ? `#/${ isShownKey . join ( "/" ) } ` : null } >
127- < span > { path } </ span >
128- </ a >
124+ < DeepLink
125+ enabled = { isDeepLinkingEnabled }
126+ isShown = { isShown }
127+ path = { `${ isShownKey . join ( "/" ) } ` }
128+ text = { path } />
129129 < JumpToPath path = { specPath } /> { /*TODO: use wrapComponents here, swagger-ui doesn't care about jumpToPath */ }
130130 </ span >
131131
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export default class Operations extends React.Component {
3737 const OperationContainer = getComponent ( "OperationContainer" , true )
3838 const Collapse = getComponent ( "Collapse" )
3939 const Markdown = getComponent ( "Markdown" )
40+ const DeepLink = getComponent ( "DeepLink" )
4041
4142 let {
4243 docExpansion,
@@ -79,12 +80,11 @@ export default class Operations extends React.Component {
7980 onClick = { ( ) => layoutActions . show ( isShownKey , ! showTag ) }
8081 className = { ! tagDescription ? "opblock-tag no-desc" : "opblock-tag" }
8182 id = { isShownKey . join ( "-" ) } >
82- < a
83- className = "nostyle"
84- onClick = { isDeepLinkingEnabled ? ( e ) => e . preventDefault ( ) : null }
85- href = { isDeepLinkingEnabled ? `#/${ tag } ` : null } >
86- < span > { tag } </ span >
87- </ a >
83+ < DeepLink
84+ enabled = { isDeepLinkingEnabled }
85+ isShown = { showTag }
86+ path = { tag }
87+ text = { tag } />
8888 { ! tagDescription ? null :
8989 < small >
9090 < Markdown source = { tagDescription } />
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ import PrimitiveModel from "core/components/primitive-model"
6161import Property from "core/components/property"
6262import TryItOutButton from "core/components/try-it-out-button"
6363import VersionStamp from "core/components/version-stamp"
64+ import DeepLink from "core/components/deep-link"
6465
6566import Markdown from "core/components/providers/markdown"
6667
@@ -121,7 +122,8 @@ export default function() {
121122 OperationExt,
122123 OperationExtRow,
123124 ParameterExt,
124- OperationContainer
125+ OperationContainer,
126+ DeepLink
125127 }
126128 }
127129
Original file line number Diff line number Diff line change @@ -3,11 +3,13 @@ import React from "react"
33import expect , { createSpy } from "expect"
44import { render } from "enzyme"
55import { fromJS } from "immutable"
6+ import DeepLink from "components/deep-link"
67import Operations from "components/operations"
78import { Collapse } from "components/layout-utils"
89
910const components = {
1011 Collapse,
12+ DeepLink,
1113 OperationContainer : ( { path, method } ) => < span className = "mocked-op" id = { `${ path } -${ method } ` } />
1214}
1315
You can’t perform that action at this time.
0 commit comments