xy 7 rokov pred
rodič
commit
f7c602badf

+ 0 - 1
src/components/app/App.jsx

@@ -285,7 +285,6 @@ class GraphqlSidebar extends Component {
         let _this = this;
         axios.get(this.state.getID_url)
             .then((res) => {
-                console.log(res);
                 if (res.data !== '') {
                     _this.setState({
                         userID: res.data,

+ 20 - 14
src/components/common/deploy/Deploy.jsx

@@ -31,22 +31,30 @@ class Deploy extends Component {
             tencentCloudID: '',
             aliyunCloudID: '',
             amazonCloudID: '',
-            // todo: 该schema应该由props传入,无论是哪一层,反正不是这一层。(路由传入吧)
-            // 有fc的schema -- 测试数据
-            // schemaID: 'schema_1542243424669_92094965',
-            // 无fc的schema -- 测试数据
-            schemaID: 'schema_1542967129456_05958413',
             schemaName: '',
             tencentFC: '',
             aliyunFC: '',
-            amazonFC: ''
+            amazonFC: '',
+            schemaID: props.schemaID
         };
+        this.hello();
+    }
+
+    componentWillReceiveProps(next) {
+        this.setState({
+            schemaID: next.schemaID
+        }, this.hello)
+    }
 
-        request('http://123.206.193.98:3000/graphql', SHOW_FC, {schema_id: this.props.schemaID || this.state.schemaID}).then(
+    hello = () => {
+        request('http://123.206.193.98:3000/graphql', SHOW_FC, {schema_id: this.state.schemaID}).then(
+            // 根据 schemaID 查询 fc 是否成功
             data => {
-                request('http://123.206.193.98:3000/graphql', SEARCH_SCHEMA, {id: this.props.schemaID || this.state.schemaID}).then(
+                request('http://123.206.193.98:3000/graphql', SEARCH_SCHEMA, {id: this.state.schemaID}).then(
+                    // 根据 schemaID 查询 schemaName
                     _data => {
                         if (data.fc_by_props.length === 0) {
+                            // 如果没有 fc,根据 userID 查 cloudId
                             request('http://123.206.193.98:3000/graphql', SHOW_CLOUD, {user_id: this.props.userID}).then(
                                 __data => {
                                     __data.cloud_by_props.forEach(cloud => {
@@ -82,6 +90,7 @@ class Deploy extends Component {
                                 }
                             );
                         } else {
+                            // 如果有 fc, 则获取 cloudID
                             data.fc_by_props.forEach(cloud => {
                                 switch (cloud.cloud_id.cloudName) {
                                     case 'tencent':
@@ -114,18 +123,15 @@ class Deploy extends Component {
                 );
             }
         );
-    }
-
+    };
 
 
     render() {
         const contentListNoTitle = {
             tencent: <TencentConfig cloudID={this.state.tencentCloudID} fc={this.tencentFC}
                                     schemaName={this.state.schemaName} userID={this.props.userID}/>,
-            aliyun: <AliConfig cloudID={this.state.aliyunCloudID} fc={this.aliyunFC} schemaName={this.state.schemaName}
-                               userID={this.props.userID}/>,
-            amazon: <AmazonConfig cloudID={this.state.amazonCloudID} fc={this.amazonFC}
-                                  schemaName={this.state.schemaName} userID={this.props.userID}/>,
+            aliyun: <AliConfig/>,
+            amazon: <AmazonConfig/>,
         };
 
         return (

+ 16 - 8
src/components/common/schema/Schema.jsx

@@ -21,7 +21,7 @@ class Schema extends Component {
         this.state = {
             currentTable: '',
             // default schemaID and schemaName
-            schemaID: 'schema_1542243424669_92094965',
+            schemaID: props.schemaID,
             schemaName: 'ecommerce'
         };
     }
@@ -37,10 +37,16 @@ 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 : '';
 
+    componentWillReceiveProps(next) {
+        this.setState({
+            schemaID: next.schemaID
+        });
+    }
+
     render() {
         let userID = this.props.userID;
         return (
-            <Query query={gql(SHOW_TABLE)} variables={{schema_id: this.props.schemaID || this.state.schemaID}}>
+            <Query query={gql(SHOW_TABLE)} variables={{schema_id: this.state.schemaID}}>
 
                 {
                     ({loading, error, data}) => {
@@ -59,9 +65,11 @@ class Schema extends Component {
 
                         return (
                             <div>
-                                <div onClick={()=>{this.setState({
-                                    currentTable: ''
-                                })}}>
+                                <div onClick={() => {
+                                    this.setState({
+                                        currentTable: ''
+                                    })
+                                }}>
                                     {schemaName || this.state.schemaName}
                                 </div>
                                 {
@@ -72,7 +80,7 @@ class Schema extends Component {
                                                     <Col span={8}><span>Name</span></Col>
                                                     <Col span={8}><span>Remark</span></Col>
                                                     <Col span={8}>
-                                                        <span onClick={()=> {
+                                                        <span onClick={() => {
                                                             this.setState({
                                                                 currentTable: 'add'
                                                             })
@@ -99,7 +107,7 @@ class Schema extends Component {
                                                 currentTableIndex={-2}
                                                 columns={[]}
                                                 remark=''
-                                                schemaID={this.props.schemaID || this.state.schemaID}
+                                                schemaID={this.state.schemaID}
                                                 userID={userID}
                                             /> :
                                             <Table
@@ -107,7 +115,7 @@ class Schema extends Component {
                                                 currentTableIndex={this.state.currentTable === '' ? -2 : data.findIndex(obj => obj.name === this.state.currentTable)}
                                                 columns={this.findColumns(data)}
                                                 remark={this.findRemark(data)}
-                                                schemaID={this.props.schemaID || this.state.schemaID}
+                                                schemaID={this.state.schemaID}
                                                 userID={userID}
                                             />
                                 }

+ 2 - 3
src/components/trialCase/TrialCase.jsx

@@ -44,7 +44,7 @@ class TrialCase extends Component {
     }
 
     componentWillReceiveProps(nextProps) {
-        let schemaID  = '';
+        let schemaID;
         switch (nextProps.match.params.caseId) {
             case 'e-commerce':
                 schemaID = 'schema_1542243424669_92094965';
@@ -56,7 +56,7 @@ class TrialCase extends Component {
                 schemaID = 'schema_1542246903496_97115305';
                 break;
             default:
-                schemaID = nextProps.match.params.caseId;
+                schemaID = nextProps.match.params.caseId || 'schema_1542243424669_92094965';
         }
         this.setState({
             schemaID
@@ -108,7 +108,6 @@ class TrialCase extends Component {
                                     default:
                                         return <Graphql/>
                                 }
-
                             })()
                         }