Add BaseLayout to core
This commit is contained in:
92
src/core/components/layouts/base.jsx
Normal file
92
src/core/components/layouts/base.jsx
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
import React, { PropTypes } from "react"
|
||||||
|
|
||||||
|
export default class BaseLayout extends React.Component {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
errSelectors: PropTypes.object.isRequired,
|
||||||
|
errActions: PropTypes.object.isRequired,
|
||||||
|
specActions: PropTypes.object.isRequired,
|
||||||
|
specSelectors: PropTypes.object.isRequired,
|
||||||
|
layoutSelectors: PropTypes.object.isRequired,
|
||||||
|
layoutActions: PropTypes.object.isRequired,
|
||||||
|
getComponent: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
let { specSelectors, specActions, getComponent } = this.props
|
||||||
|
|
||||||
|
let info = specSelectors.info()
|
||||||
|
let url = specSelectors.url()
|
||||||
|
let basePath = specSelectors.basePath()
|
||||||
|
let host = specSelectors.host()
|
||||||
|
let securityDefinitions = specSelectors.securityDefinitions()
|
||||||
|
let externalDocs = specSelectors.externalDocs()
|
||||||
|
let schemes = specSelectors.schemes()
|
||||||
|
|
||||||
|
let Info = getComponent("info")
|
||||||
|
let Operations = getComponent("operations", true)
|
||||||
|
let Models = getComponent("models", true)
|
||||||
|
let AuthorizeBtn = getComponent("authorizeBtn", true)
|
||||||
|
let Row = getComponent("Row")
|
||||||
|
let Col = getComponent("Col")
|
||||||
|
let Errors = getComponent("errors", true)
|
||||||
|
const Schemes = getComponent("schemes")
|
||||||
|
|
||||||
|
const loadingStatus = specSelectors.loadingStatus()
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
<div className='swagger-ui'>
|
||||||
|
{ loadingStatus === "loading" &&
|
||||||
|
<div className="info">
|
||||||
|
<h4 className="title">Loading...</h4>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
{ loadingStatus === "failed" &&
|
||||||
|
<div className="info">
|
||||||
|
<h4 className="title">Failed to load spec.</h4>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
{ loadingStatus === "failedConfig" &&
|
||||||
|
<div className="info" style={{ maxWidth: "880px", marginLeft: "auto", marginRight: "auto", textAlign: "center" }}>
|
||||||
|
<h4 className="title">Failed to load config.</h4>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
{ loadingStatus === "success" &&
|
||||||
|
<div>
|
||||||
|
<Errors/>
|
||||||
|
<Row className="information-container">
|
||||||
|
<Col mobile={12}>
|
||||||
|
{ info.count() ? (
|
||||||
|
<Info info={ info } url={ url } host={ host } basePath={ basePath } externalDocs={externalDocs} getComponent={getComponent}/>
|
||||||
|
) : null }
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
{ schemes && schemes.size || securityDefinitions ? (
|
||||||
|
<div className="scheme-container">
|
||||||
|
<Col className="schemes wrapper" mobile={12}>
|
||||||
|
{ schemes && schemes.size ? (
|
||||||
|
<Schemes schemes={ schemes } specActions={ specActions } />
|
||||||
|
) : null }
|
||||||
|
{ securityDefinitions ? (
|
||||||
|
<AuthorizeBtn />
|
||||||
|
) : null }
|
||||||
|
</Col>
|
||||||
|
</div>
|
||||||
|
) : null }
|
||||||
|
|
||||||
|
<Row>
|
||||||
|
<Col mobile={12} desktop={12} >
|
||||||
|
<Operations/>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<Row>
|
||||||
|
<Col mobile={12} desktop={12} >
|
||||||
|
<Models/>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</div> }
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ module.exports = function SwaggerUI(opts) {
|
|||||||
dom_id: null,
|
dom_id: null,
|
||||||
spec: {},
|
spec: {},
|
||||||
url: "",
|
url: "",
|
||||||
layout: "Layout",
|
layout: "BaseLayout",
|
||||||
validatorUrl: "https://online.swagger.io/validator",
|
validatorUrl: "https://online.swagger.io/validator",
|
||||||
configs: {
|
configs: {
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ import Model from "core/components/model"
|
|||||||
import Models from "core/components/models"
|
import Models from "core/components/models"
|
||||||
import TryItOutButton from "core/components/try-it-out-button"
|
import TryItOutButton from "core/components/try-it-out-button"
|
||||||
|
|
||||||
|
import BaseLayout from "core/components/layouts/base"
|
||||||
|
|
||||||
import * as LayoutUtils from "core/components/layout-utils"
|
import * as LayoutUtils from "core/components/layout-utils"
|
||||||
import * as JsonSchemaComponents from "core/json-schema-components"
|
import * as JsonSchemaComponents from "core/json-schema-components"
|
||||||
|
|
||||||
@@ -87,6 +89,7 @@ export default function() {
|
|||||||
model: Model,
|
model: Model,
|
||||||
models: Models,
|
models: Models,
|
||||||
TryItOutButton,
|
TryItOutButton,
|
||||||
|
BaseLayout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user