create InfoUrl and InfoBasePath (#4330)
* create `InfoUrl` component * create `InfoBasePath` component * linter fixes
This commit is contained in:
@@ -5,7 +5,7 @@ import ImPropTypes from "react-immutable-proptypes"
|
|||||||
import { sanitizeUrl } from "core/utils"
|
import { sanitizeUrl } from "core/utils"
|
||||||
|
|
||||||
|
|
||||||
class Path extends React.Component {
|
export class InfoBasePath extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
host: PropTypes.string,
|
host: PropTypes.string,
|
||||||
basePath: PropTypes.string
|
basePath: PropTypes.string
|
||||||
@@ -68,6 +68,17 @@ class License extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class InfoUrl extends React.PureComponent {
|
||||||
|
static propTypes = {
|
||||||
|
url: PropTypes.string.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { url } = this.props
|
||||||
|
return <a target="_blank" href={ sanitizeUrl(url) }><span className="url"> { url } </span></a>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default class Info extends React.Component {
|
export default class Info extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
info: PropTypes.object,
|
info: PropTypes.object,
|
||||||
@@ -90,6 +101,8 @@ export default class Info extends React.Component {
|
|||||||
|
|
||||||
const Markdown = getComponent("Markdown")
|
const Markdown = getComponent("Markdown")
|
||||||
const VersionStamp = getComponent("VersionStamp")
|
const VersionStamp = getComponent("VersionStamp")
|
||||||
|
const InfoUrl = getComponent("InfoUrl")
|
||||||
|
const InfoBasePath = getComponent("InfoBasePath")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="info">
|
<div className="info">
|
||||||
@@ -97,8 +110,8 @@ export default class Info extends React.Component {
|
|||||||
<h2 className="title" >{ title }
|
<h2 className="title" >{ title }
|
||||||
{ version && <VersionStamp version={version}></VersionStamp> }
|
{ version && <VersionStamp version={version}></VersionStamp> }
|
||||||
</h2>
|
</h2>
|
||||||
{ host || basePath ? <Path host={ host } basePath={ basePath } /> : null }
|
{ host || basePath ? <InfoBasePath host={ host } basePath={ basePath } /> : null }
|
||||||
{ url && <a target="_blank" href={ sanitizeUrl(url) }><span className="url"> { url } </span></a> }
|
{ url && <InfoUrl url={url} /> }
|
||||||
</hgroup>
|
</hgroup>
|
||||||
|
|
||||||
<div className="description">
|
<div className="description">
|
||||||
|
|||||||
@@ -45,7 +45,10 @@ import Headers from "core/components/headers"
|
|||||||
import Errors from "core/components/errors"
|
import Errors from "core/components/errors"
|
||||||
import ContentType from "core/components/content-type"
|
import ContentType from "core/components/content-type"
|
||||||
import Overview from "core/components/overview"
|
import Overview from "core/components/overview"
|
||||||
import Info from "core/components/info"
|
import Info, {
|
||||||
|
InfoUrl,
|
||||||
|
InfoBasePath
|
||||||
|
} from "core/components/info"
|
||||||
import Footer from "core/components/footer"
|
import Footer from "core/components/footer"
|
||||||
import ParamBody from "core/components/param-body"
|
import ParamBody from "core/components/param-body"
|
||||||
import Curl from "core/components/curl"
|
import Curl from "core/components/curl"
|
||||||
@@ -124,7 +127,9 @@ export default function() {
|
|||||||
OperationExtRow,
|
OperationExtRow,
|
||||||
ParameterExt,
|
ParameterExt,
|
||||||
OperationContainer,
|
OperationContainer,
|
||||||
DeepLink
|
DeepLink,
|
||||||
|
InfoUrl,
|
||||||
|
InfoBasePath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user