Skip to content

Commit 8cde08b

Browse files
bestmike007shockey
authored andcommitted
improvement: allow viewing model when Try-It-Out is enabled (via #4723)
1 parent 8a86b2f commit 8cde08b

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/core/components/model-example.jsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ export default class ModelExample extends React.Component {
1515

1616
constructor(props, context) {
1717
super(props, context)
18-
let { getConfigs } = this.props
18+
let { getConfigs, isExecute } = this.props
1919
let { defaultModelRendering } = getConfigs()
2020
if (defaultModelRendering !== "example" && defaultModelRendering !== "model") {
2121
defaultModelRendering = "example"
2222
}
2323
this.state = {
24-
activeTab: defaultModelRendering
24+
activeTab: isExecute ? "example" : defaultModelRendering
2525
}
2626
}
2727

@@ -33,26 +33,32 @@ export default class ModelExample extends React.Component {
3333
})
3434
}
3535

36+
componentWillReceiveProps(props) {
37+
if (props.isExecute && props.isExecute !== this.props.isExecute) {
38+
this.setState({ activeTab: "example" })
39+
}
40+
}
41+
3642
render() {
3743
let { getComponent, specSelectors, schema, example, isExecute, getConfigs, specPath } = this.props
3844
let { defaultModelExpandDepth } = getConfigs()
3945
const ModelWrapper = getComponent("ModelWrapper")
4046

4147
return <div>
4248
<ul className="tab">
43-
<li className={ "tabitem" + ( isExecute || this.state.activeTab === "example" ? " active" : "") }>
44-
<a className="tablinks" data-name="example" onClick={ this.activeTab }>Example Value</a>
49+
<li className={ "tabitem" + ( this.state.activeTab === "example" ? " active" : "") }>
50+
<a className="tablinks" data-name="example" onClick={ this.activeTab }>{isExecute ? "Edit Value" : "Example Value"}</a>
4551
</li>
46-
{ schema ? <li className={ "tabitem" + ( !isExecute && this.state.activeTab === "model" ? " active" : "") }>
52+
{ schema ? <li className={ "tabitem" + ( this.state.activeTab === "model" ? " active" : "") }>
4753
<a className={ "tablinks" + ( isExecute ? " inactive" : "" )} data-name="model" onClick={ this.activeTab }>Model</a>
4854
</li> : null }
4955
</ul>
5056
<div>
5157
{
52-
(isExecute || this.state.activeTab === "example") && example
58+
this.state.activeTab === "example" && example
5359
}
5460
{
55-
!isExecute && this.state.activeTab === "model" && <ModelWrapper schema={ schema }
61+
this.state.activeTab === "model" && <ModelWrapper schema={ schema }
5662
getComponent={ getComponent }
5763
getConfigs={ getConfigs }
5864
specSelectors={ specSelectors }

src/style/_layout.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,7 @@
396396
{
397397
font-size: 12px;
398398

399-
min-width: 100px;
400-
min-width: 90px;
399+
min-width: 60px;
401400
padding: 0;
402401

403402
cursor: pointer;
@@ -409,6 +408,7 @@
409408
position: relative;
410409

411410
padding-left: 0;
411+
padding-right: 12px;
412412

413413
&:after
414414
{

0 commit comments

Comments
 (0)