소스 검색

修复 deploy 显示

xy 7 년 전
부모
커밋
66c4f276a4
2개의 변경된 파일28개의 추가작업 그리고 10개의 파일을 삭제
  1. 4 5
      src/components/common/deploy/Deploy.jsx
  2. 24 5
      src/components/common/deploy/tencent/TencentConfig.js

+ 4 - 5
src/components/common/deploy/Deploy.jsx

@@ -37,16 +37,16 @@ class Deploy extends Component {
             amazonFC: '',
             schemaID: props.schemaID
         };
-        this.hello();
+        this.fetch();
     }
 
     componentWillReceiveProps(next) {
         this.setState({
             schemaID: next.schemaID
-        }, this.hello)
+        }, this.fetch)
     }
 
-    hello = () => {
+    fetch = () => {
         request('http://123.206.193.98:3000/graphql', SHOW_FC, {schema_id: this.state.schemaID}).then(
             // 根据 schemaID 查询 fc 是否成功
             data => {
@@ -128,8 +128,7 @@ class Deploy extends Component {
 
     render() {
         const contentListNoTitle = {
-            tencent: <TencentConfig cloudID={this.state.tencentCloudID} fc={this.tencentFC}
-                                    schemaName={this.state.schemaName} userID={this.props.userID}/>,
+            tencent: <TencentConfig cloudID={this.state.tencentCloudID} fc={this.state.tencentFC} schemaName={this.state.schemaName} userID={this.props.userID}/>,
             aliyun: <AliConfig/>,
             amazon: <AmazonConfig/>,
         };

+ 24 - 5
src/components/common/deploy/tencent/TencentConfig.js

@@ -20,13 +20,26 @@ class TencentConfig extends Component {
             paths: [],
             currentPath: '',
             deployIdPassToPath: '',
-            groupIdPassToPath: ''
+            groupIdPassToPath: '',
+            cloudID: props.cloudID,
+            fc: props.fc
         };
+        this.fetch();
+    }
+
+
+    componentWillReceiveProps(next) {
+        this.setState({
+            fc: next.fc,
+            cloudID: next.cloudID
+        }, this.fetch);
+    }
 
+    fetch = () => {
         // todo: 没做每个 deploy 和 apigroup 和 apipath 的切换
         // todo: 换成 apollo 会更好
-        if (props.fc === true) {
-            request('http://123.206.193.98:3000/graphql', SHOW_DEPLOY, {cloud_id: props.cloudID}).then(
+        if (this.state.fc === true) {
+            request('http://123.206.193.98:3000/graphql', SHOW_DEPLOY, {cloud_id: this.state.cloudID}).then(
                 data => {
                     this.setState({
                         deploys: data.deploy_by_props,
@@ -34,7 +47,7 @@ class TencentConfig extends Component {
                     })
                 }
             );
-            request('http://123.206.193.98:3000/graphql', SHOW_APIGWGROUP, {cloud_id: props.cloudID}).then(
+            request('http://123.206.193.98:3000/graphql', SHOW_APIGWGROUP, {cloud_id: this.state.cloudID}).then(
                 data => {
                     this.setState({
                         groups: data.apiGWGroup_by_props,
@@ -51,8 +64,14 @@ class TencentConfig extends Component {
                     });
                 }
             );
+        } else {
+            this.setState({
+                currentDeploy: '',
+                currentGroup: '',
+                currentPath: '',
+            })
         }
-    }
+    };
 
     pass = (value, kind) => {
         if(kind === 'deploy')