Skip to content

Commit

Permalink
fix: remove dead code and format document (#8048)
Browse files Browse the repository at this point in the history
  • Loading branch information
twjasa authored Jun 3, 2022
1 parent 1bb70a2 commit a7e23b5
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/core/components/primitive-model.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export default class Primitive extends Component {
expandDepth: PropTypes.number
}

render(){
render() {
let { schema, getComponent, getConfigs, name, displayName, depth, expandDepth } = this.props

const { showExtensions } = getConfigs()

if(!schema || !schema.get) {
if (!schema || !schema.get) {
// don't render if schema isn't correctly formed
return <div></div>
}
Expand All @@ -33,42 +33,42 @@ export default class Primitive extends Component {
let description = schema.get("description")
let extensions = getExtensions(schema)
let properties = schema
.filter( ( v, key) => ["enum", "type", "format", "description", "$$ref"].indexOf(key) === -1 )
.filterNot( (v, key) => extensions.has(key) )
.filter((_, key) => ["enum", "type", "format", "description", "$$ref"].indexOf(key) === -1)
.filterNot((_, key) => extensions.has(key))
const Markdown = getComponent("Markdown", true)
const EnumModel = getComponent("EnumModel")
const Property = getComponent("Property")
const ModelCollapse = getComponent("ModelCollapse")
const titleEl = title &&
<span className="model-title">
<span className="model-title__text">{ title }</span>
<span className="model-title__text">{title}</span>
</span>

return <span className="model">
<ModelCollapse title={titleEl} expanded={depth >= expandDepth} collapsedContent=" " hideSelfOnExpand={expandDepth !== depth}>
<span className="prop">
{name && depth > 1 && <span className={`${depth === 1 && "model-title"} prop-name`}>{ title }</span> }
<span className="prop-type">{ type }</span>
{ format && <span className="prop-format">(${format})</span>}
{name && depth > 1 && <span className="prop-name">{title}</span>}
<span className="prop-type">{type}</span>
{format && <span className="prop-format">(${format})</span>}
{
properties.size ? properties.entrySeq().map( ( [ key, v ] ) => <Property key={`${key}-${v}`} propKey={ key } propVal={ v } propClass={ propClass } />) : null
properties.size ? properties.entrySeq().map(([key, v]) => <Property key={`${key}-${v}`} propKey={key} propVal={v} propClass={propClass} />) : null
}
{
showExtensions && extensions.size ? extensions.entrySeq().map( ( [ key, v ] ) => <Property key={`${key}-${v}`} propKey={ key } propVal={ v } propClass={ propClass } />) : null
showExtensions && extensions.size ? extensions.entrySeq().map(([key, v]) => <Property key={`${key}-${v}`} propKey={key} propVal={v} propClass={propClass} />) : null
}
{
!description ? null :
<Markdown source={ description } />
<Markdown source={description} />
}
{
xml && xml.size ? (<span><br /><span className={ propClass }>xml:</span>
xml && xml.size ? (<span><br /><span className={propClass}>xml:</span>
{
xml.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} className={ propClass }><br/>&nbsp;&nbsp;&nbsp;{key}: { String(v) }</span>).toArray()
xml.entrySeq().map(([key, v]) => <span key={`${key}-${v}`} className={propClass}><br />&nbsp;&nbsp;&nbsp;{key}: {String(v)}</span>).toArray()
}
</span>): null
</span>) : null
}
{
enumArray && <EnumModel value={ enumArray } getComponent={ getComponent } />
enumArray && <EnumModel value={enumArray} getComponent={getComponent} />
}
</span>
</ModelCollapse>
Expand Down

0 comments on commit a7e23b5

Please sign in to comment.