11import React from "react"
22import PropTypes from "prop-types"
3- import { fromJS } from "immutable"
43import ImPropTypes from "react-immutable-proptypes"
54import { sanitizeUrl } from "core/utils"
5+ import { buildUrl } from "core/utils/url"
66
77
88export class InfoBasePath extends React . Component {
@@ -26,13 +26,16 @@ export class InfoBasePath extends React.Component {
2626class Contact extends React . Component {
2727 static propTypes = {
2828 data : PropTypes . object ,
29- getComponent : PropTypes . func . isRequired
29+ getComponent : PropTypes . func . isRequired ,
30+ specSelectors : PropTypes . object . isRequired ,
31+ selectedServer : PropTypes . string ,
32+ url : PropTypes . string . isRequired ,
3033 }
3134
3235 render ( ) {
33- let { data, getComponent } = this . props
36+ let { data, getComponent, selectedServer , url : specUrl } = this . props
3437 let name = data . get ( "name" ) || "the developer"
35- let url = data . get ( "url" )
38+ let url = buildUrl ( data . get ( "url" ) , specUrl , { selectedServer } )
3639 let email = data . get ( "email" )
3740
3841 const Link = getComponent ( "Link" )
@@ -53,17 +56,18 @@ class Contact extends React.Component {
5356class License extends React . Component {
5457 static propTypes = {
5558 license : PropTypes . object ,
56- getComponent : PropTypes . func . isRequired
57-
59+ getComponent : PropTypes . func . isRequired ,
60+ specSelectors : PropTypes . object . isRequired ,
61+ selectedServer : PropTypes . string ,
62+ url : PropTypes . string . isRequired ,
5863 }
5964
6065 render ( ) {
61- let { license, getComponent } = this . props
66+ let { license, getComponent, selectedServer , url : specUrl } = this . props
6267
6368 const Link = getComponent ( "Link" )
64-
65- let name = license . get ( "name" ) || "License"
66- let url = license . get ( "url" )
69+ let name = license . get ( "name" ) || "License"
70+ let url = buildUrl ( license . get ( "url" ) , specUrl , { selectedServer} )
6771
6872 return (
6973 < div className = "info__license" >
@@ -88,7 +92,7 @@ export class InfoUrl extends React.PureComponent {
8892
8993 const Link = getComponent ( "Link" )
9094
91- return < Link target = "_blank" href = { sanitizeUrl ( url ) } > < span className = "url" > { url } </ span > </ Link >
95+ return < Link target = "_blank" href = { sanitizeUrl ( url ) } > < span className = "url" > { url } </ span > </ Link >
9296 }
9397}
9498
@@ -100,17 +104,21 @@ export default class Info extends React.Component {
100104 basePath : PropTypes . string ,
101105 externalDocs : ImPropTypes . map ,
102106 getComponent : PropTypes . func . isRequired ,
107+ oas3selectors : PropTypes . func ,
108+ selectedServer : PropTypes . string ,
103109 }
104110
105111 render ( ) {
106- let { info, url, host, basePath, getComponent, externalDocs } = this . props
112+ let { info, url, host, basePath, getComponent, externalDocs, selectedServer , url : specUrl } = this . props
107113 let version = info . get ( "version" )
108114 let description = info . get ( "description" )
109115 let title = info . get ( "title" )
110- let termsOfService = info . get ( "termsOfService" )
116+ let termsOfServiceUrl = buildUrl ( info . get ( "termsOfService" ) , specUrl , { selectedServer } )
111117 let contact = info . get ( "contact" )
112118 let license = info . get ( "license" )
113- const { url :externalDocsUrl , description :externalDocsDescription } = ( externalDocs || fromJS ( { } ) ) . toJS ( )
119+ let rawExternalDocsUrl = externalDocs && externalDocs . get ( "url" )
120+ let externalDocsUrl = buildUrl ( rawExternalDocsUrl , specUrl , { selectedServer} )
121+ let externalDocsDescription = externalDocs && externalDocs . get ( "description" )
114122
115123 const Markdown = getComponent ( "Markdown" , true )
116124 const Link = getComponent ( "Link" )
@@ -133,14 +141,14 @@ export default class Info extends React.Component {
133141 </ div >
134142
135143 {
136- termsOfService && < div className = "info__tos" >
137- < Link target = "_blank" href = { sanitizeUrl ( termsOfService ) } > Terms of service</ Link >
144+ termsOfServiceUrl && < div className = "info__tos" >
145+ < Link target = "_blank" href = { sanitizeUrl ( termsOfServiceUrl ) } > Terms of service</ Link >
138146 </ div >
139147 }
140148
141- { contact && contact . size ? < Contact getComponent = { getComponent } data = { contact } /> : null }
142- { license && license . size ? < License getComponent = { getComponent } license = { license } /> : null }
143- { externalDocsUrl ?
149+ { contact && contact . size ? < Contact getComponent = { getComponent } data = { contact } selectedServer = { selectedServer } url = { url } /> : null }
150+ { license && license . size ? < License getComponent = { getComponent } license = { license } selectedServer = { selectedServer } url = { url } /> : null }
151+ { externalDocs ?
144152 < Link className = "info__extdocs" target = "_blank" href = { sanitizeUrl ( externalDocsUrl ) } > { externalDocsDescription || externalDocsUrl } </ Link >
145153 : null }
146154
0 commit comments