Skip to content

Commit

Permalink
create InfoUrl and InfoBasePath (#4330)
Browse files Browse the repository at this point in the history
* create `InfoUrl` component
* create `InfoBasePath` component
* linter fixes
  • Loading branch information
shockey committed Mar 14, 2018
1 parent fb7f125 commit 6c5a370
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
19 changes: 16 additions & 3 deletions src/core/components/info.jsx
Expand Up @@ -5,7 +5,7 @@ import ImPropTypes from "react-immutable-proptypes"
import { sanitizeUrl } from "core/utils"


class Path extends React.Component {
export class InfoBasePath extends React.Component {
static propTypes = {
host: PropTypes.string,
basePath: PropTypes.string
Expand Down Expand Up @@ -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 {
static propTypes = {
info: PropTypes.object,
Expand All @@ -90,15 +101,17 @@ export default class Info extends React.Component {

const Markdown = getComponent("Markdown")
const VersionStamp = getComponent("VersionStamp")
const InfoUrl = getComponent("InfoUrl")
const InfoBasePath = getComponent("InfoBasePath")

return (
<div className="info">
<hgroup className="main">
<h2 className="title" >{ title }
{ version && <VersionStamp version={version}></VersionStamp> }
</h2>
{ host || basePath ? <Path host={ host } basePath={ basePath } /> : null }
{ url && <a target="_blank" href={ sanitizeUrl(url) }><span className="url"> { url } </span></a> }
{ host || basePath ? <InfoBasePath host={ host } basePath={ basePath } /> : null }
{ url && <InfoUrl url={url} /> }
</hgroup>

<div className="description">
Expand Down
9 changes: 7 additions & 2 deletions src/core/presets/base.js
Expand Up @@ -45,7 +45,10 @@ import Headers from "core/components/headers"
import Errors from "core/components/errors"
import ContentType from "core/components/content-type"
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 ParamBody from "core/components/param-body"
import Curl from "core/components/curl"
Expand Down Expand Up @@ -124,7 +127,9 @@ export default function() {
OperationExtRow,
ParameterExt,
OperationContainer,
DeepLink
DeepLink,
InfoUrl,
InfoBasePath
}
}

Expand Down

0 comments on commit 6c5a370

Please sign in to comment.