@@ -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 }
0 commit comments