Просмотр исходного кода

fix no deploy_id and group_id when first commit path

xy 7 лет назад
Родитель
Сommit
e85219df88

+ 7 - 3
src/components/common/deploy/tencent/APIGroupCard.js

@@ -70,10 +70,10 @@ class APIGroupCard extends Component {
         };
     };
 
-    ok = () => {
+    ok = (id) => {
         let {userStatus, userDomain, groupName, frontType, environmentName} = this.state;
         let varObj = {
-            id: idGen('group'),
+            id,
             cloud_id: this.props.cloudID,
             user_id: this.props.userID,
             userStatus,
@@ -196,7 +196,11 @@ class APIGroupCard extends Component {
                         </div>
                     </Panel>
                 </Collapse>
-                <Button onClick={this.ok} type='primary'>ok</Button>
+                <Button onClick={()=>{
+                    const id = idGen('group');
+                    this.ok(id);
+                    this.props.pass(id, 'group');
+                }} type='primary'>ok</Button>
                 {
                     this.state.showOK === true?
                         <Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/>

+ 15 - 13
src/components/common/deploy/tencent/APIPathCard.js

@@ -75,20 +75,22 @@ class APIPathCard extends Component {
             updatedAt: ''
         };
         if (this.props.path === '') {
-            request('http://123.206.193.98:3000/graphql', ADD_APIGWPATH, varObj).then(
-                data => {
-                    if (data.create_apiGWPath !== null) {
-                        this.setState({
-                            showOK: true
-                        })
+            if(this.props.deployID !== '' && this.props.groupID!=='') {
+                request('http://123.206.193.98:3000/graphql', ADD_APIGWPATH, varObj).then(
+                    data => {
+                        if (data.create_apiGWPath !== null) {
+                            this.setState({
+                                showOK: true
+                            })
+                        }
+                        setTimeout(()=>{
+                            this.setState({
+                                showOK: false
+                            })
+                        }, 1500)
                     }
-                    setTimeout(()=>{
-                        this.setState({
-                            showOK: false
-                        })
-                    }, 1500)
-                }
-            )
+                )
+            }
         } else {
             let {apiGWName, apiGWDesc, requestMethod} = this.state;
             let varObj = {

+ 7 - 3
src/components/common/deploy/tencent/DeployCard.js

@@ -78,10 +78,10 @@ class DeployCard extends Component {
         };
     };
 
-    ok = () => {
+    ok = (id) => {
         let {description, cosBucketName, subnetId, cosObjectName, region, vpcId, cosBucketRegion, functionName} = this.state;
         let varObj = {
-            id: idGen('deploy'),
+            id,
             cloud_id: this.props.cloudID,
             user_id: this.props.userID,
             description,
@@ -204,7 +204,11 @@ class DeployCard extends Component {
                         }
                     </Panel>
                 </Collapse>
-                <Button onClick={this.ok} type='primary'>ok</Button>
+                <Button onClick={()=>{
+                    const id = idGen('deploy');
+                    this.ok(id);
+                    this.props.pass(id, 'deploy');
+                }} type='primary'>ok</Button>
                 {
                     this.state.showOK === true?
                         <Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/>

+ 17 - 4
src/components/common/deploy/tencent/TencentConfig.js

@@ -17,7 +17,9 @@ class TencentConfig extends Component {
             groups: [],
             currentGroup: '',
             paths: [],
-            currentPath: ''
+            currentPath: '',
+            deployIdPassToPath: '',
+            groupIdPassToPath: ''
         };
 
         // todo: 没做每个 deploy 和 apigroup 和 apipath 的切换
@@ -51,6 +53,17 @@ class TencentConfig extends Component {
         }
     }
 
+    pass = (value, kind) => {
+        if(kind === 'deploy')
+            this.setState({
+                deployIdPassToPath: value
+            });
+        else
+            this.setState({
+                groupIdPassToPath: value
+            })
+    };
+
     switchRegion = (e) => {
         this.setState({
             region: e.target.value
@@ -63,9 +76,9 @@ class TencentConfig extends Component {
                 <div style={{padding: '30px'}}>
                     <Row gutter={16}>
                         <Col span={14}>
-                            <Card title="Deploy" style={{marginBottom: 10}}><DeployCard deploy={this.state.currentDeploy} switchRegion={this.switchRegion} region={this.state.region} schemaName={this.props.schemaName} userID={this.props.userID} cloudID={this.props.cloudID}/></Card>
-                            <Card title="API Group" style={{marginBottom: 10}}><APIGroupCard group={this.state.currentGroup} switchRegion={this.switchRegion} region={this.state.region} userID={this.props.userID} cloudID={this.props.cloudID}/></Card>
-                            <Card title="API Path"><APIPathCard path={this.state.currentPath} schemaName={this.props.schemaName} userID={this.props.userID} deployID={this.state.currentDeploy.id} groupID={this.state.currentGroup.id}/></Card>
+                            <Card title="Deploy" style={{marginBottom: 10}}><DeployCard deploy={this.state.currentDeploy} switchRegion={this.switchRegion} region={this.state.region} schemaName={this.props.schemaName} userID={this.props.userID} cloudID={this.props.cloudID} pass={this.pass}/></Card>
+                            <Card title="API Group" style={{marginBottom: 10}}><APIGroupCard group={this.state.currentGroup} switchRegion={this.switchRegion} region={this.state.region} userID={this.props.userID} cloudID={this.props.cloudID} pass={this.pass}/></Card>
+                            <Card title="API Path"><APIPathCard path={this.state.currentPath} schemaName={this.props.schemaName} userID={this.props.userID} deployID={this.state.currentDeploy? this.state.currentDeploy.id : this.state.deployIdPassToPath} groupID={this.state.currentGroup? this.state.currentGroup.id : this.state.groupIdPassToPath}/></Card>
                         </Col>
                         <Col offset={2} span={6}>
                             <Button type='primary'>deploy it</Button>