Przeglądaj źródła

back to schema & create directly to table

xy 7 lat temu
rodzic
commit
7033a2014a

+ 2 - 1
src/components/common/schema/Create.js

@@ -64,7 +64,8 @@ class Create extends Component {
             pathname: `/table`,
             state:{
                 schemaName:this.state.schemaName,
-                schemaID:varobj.id
+                schemaID:varobj.id,
+                create: true
             }
         });
     };

+ 13 - 5
src/components/common/schema/Schema.jsx

@@ -10,12 +10,11 @@ import Table from "./Table";
 class Schema extends Component {
     constructor(props) {
         super(props);
-        console.log('Schema props',props);
         this.state = {
-            currentTable: props.schemaID ?'':'add',
+            currentTable: props.location.state.create ? 'add' : '',
             // default schemaID and schemaName
-            schemaID: props.schemaID || props.history.location.state.schemaID,
-            schemaName: props.schemaName || props.history.location.state.schemaName,
+            schemaID: props.schemaID || props.location.state.schemaID,
+            schemaName: props.schemaName || props.location.state.schemaName,
         };
     }
 
@@ -30,9 +29,15 @@ class Schema extends Component {
 
     findRemark = data => this.state.currentTable === '' ? '' : data.find(table => table.name === this.state.currentTable) ? data.find(table => table.name === this.state.currentTable).remark : '';
 
+    goBack = () => {
+        this.setState({
+            currentTable: ''
+        })
+    };
+
     componentWillReceiveProps(next) {
         this.setState({
-            currentTable: '',
+            currentTable: next.location.state.create ? 'add' : '',
             schemaID: next.schemaID,
             schemaName: next.schemaName
         });
@@ -100,12 +105,14 @@ class Schema extends Component {
                                         :
                                         this.state.currentTable === 'add' ?
                                             <Table
+                                                currentTable={''}
                                                 currentTableIndex={-2}
                                                 columns={[]}
                                                 remark=''
                                                 schemaID={this.state.schemaID}
                                                 schemaName={this.state.schemaName}
                                                 userID={userID}
+                                                goBack={this.goBack}
                                             /> :
                                             <Table
                                                 currentTable={this.state.currentTable}
@@ -115,6 +122,7 @@ class Schema extends Component {
                                                 schemaID={this.state.schemaID}
                                                 schemaName={this.state.schemaName}
                                                 userID={userID}
+                                                goBack={this.goBack}
                                             />
                                 }
 

+ 2 - 1
src/components/common/schema/Table.js

@@ -112,7 +112,8 @@ class Table extends Component {
 
         return (
             <div>
-                <div className="column-menu" onClick={()=>this.props.history.goBack()}>
+                <div className="column-menu" onClick={this.props.goBack}>
+                    {/*()=>this.props.history.goBack()*/}
                     <Icon type="left" style={{color:'#3187FA'}} /> {schemaName}
                 </div>
 

+ 1 - 1
src/components/trialCase/TrialCase.jsx

@@ -74,7 +74,7 @@ class TrialCase extends Component {
                             (() => {
                                 switch (this.state.menuLevel2) {
                                     case 'schema':
-                                        return <Schema userID={this.state.userID} schemaName={schemaName} schemaID={schemaID} />;
+                                        return <Schema userID={this.state.userID} schemaName={schemaName} schemaID={schemaID} location={this.props.location}/>;
                                     case 'deploy':
                                         return <Deploy userID={this.state.userID} schemaID={schemaID} schemaName={schemaName}/>;
                                     case 'graphql':