|
|
@@ -1,6 +1,6 @@
|
|
|
import React, {Component} from 'react';
|
|
|
import {Link} from 'react-router-dom';
|
|
|
-import {deployAll, graphqlUrl, storeFile, copyCos} from "../../../config";
|
|
|
+import {deployAll, graphqlUrl, storeFile, deployFC} from "../../../config";
|
|
|
import {ADD_APIGROUP, ADD_APIGWPATH, ADD_DEPLOY, ADD_PROJECT, SHOW_CLOUD} from "../../../gql";
|
|
|
import {CloudConfig} from "../../../login/CloudConfig";
|
|
|
import {Layout, Button, message, Modal, Icon, Steps, Row, Col, Radio, Input} from 'antd';
|
|
|
@@ -51,7 +51,7 @@ class UserCustom extends Component {
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
- let {disableDeployButton, userID, cloudID, bucketName, deployFailed, appId, secretID, secretKey} = this.state;
|
|
|
+ let {userID, cloudID, bucketName, deployFailed, appId, secretID, secretKey} = this.state;
|
|
|
return (
|
|
|
<Content className="content">
|
|
|
<div>
|
|
|
@@ -83,7 +83,7 @@ class UserCustom extends Component {
|
|
|
/>
|
|
|
<Step title=<Step4/> />
|
|
|
<Step title=<Step5 bucketName={bucketName} userID={userID}/> />
|
|
|
- <Step title=<Step6/> />
|
|
|
+ <Step title=<Step6 bucketName={bucketName} userID={userID}/> />
|
|
|
|
|
|
</Steps>
|
|
|
</Col>
|
|
|
@@ -205,7 +205,7 @@ class NameAndDB extends Component {
|
|
|
userID: props.userID,
|
|
|
visible: false,
|
|
|
confirmLoading: false,
|
|
|
- customName: props.bucketName + '-' + props.userID,
|
|
|
+ customName: props.bucketName,
|
|
|
dbKind: 'fc-db',
|
|
|
host: '',
|
|
|
db: '',
|
|
|
@@ -668,14 +668,46 @@ class Step5 extends Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const Step6 = (props) => (
|
|
|
- <div className='step-block'>
|
|
|
- 开始使用
|
|
|
- <div>
|
|
|
- <Button type='primary'>使用</Button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-);
|
|
|
+class Step6 extends Component {
|
|
|
+ constructor(props) {
|
|
|
+ super(props)
|
|
|
+ this.state = {
|
|
|
+ visible: false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ handleCancel = () => {
|
|
|
+ this.setState({
|
|
|
+ visible: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ render() {
|
|
|
+ let {visible} = this.state
|
|
|
+ let {userID, bucketName} = this.props
|
|
|
+ return (
|
|
|
+ <div className='step-block'>
|
|
|
+ 开始使用
|
|
|
+ <div>
|
|
|
+ <Button type='primary' onClick={() => {
|
|
|
+ this.setState({visible: true})
|
|
|
+ }}>使用</Button>
|
|
|
+ <Modal
|
|
|
+ title="公众号/小程序二次部署"
|
|
|
+ visible={visible}
|
|
|
+ footer={null}
|
|
|
+ onCancel={this.handleCancel}
|
|
|
+ >
|
|
|
+ <WechatDeploy
|
|
|
+ userID={userID}
|
|
|
+ bucketName={bucketName}
|
|
|
+ />
|
|
|
+ </Modal>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
class Wechat extends Component {
|
|
|
constructor(props) {
|
|
|
@@ -814,8 +846,8 @@ class Wechat extends Component {
|
|
|
|
|
|
</div>
|
|
|
{
|
|
|
- saving?
|
|
|
- '保存中,请稍后。。。':
|
|
|
+ saving ?
|
|
|
+ '保存中,请稍后。。。' :
|
|
|
<Button type='primary' onClick={() => {
|
|
|
this.storeEdn()
|
|
|
this.setState({
|
|
|
@@ -826,12 +858,87 @@ class Wechat extends Component {
|
|
|
</Button>
|
|
|
}
|
|
|
{
|
|
|
- savingCompleted?
|
|
|
- <Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/>:''
|
|
|
+ savingCompleted ?
|
|
|
+ <Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/> : ''
|
|
|
}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+class WechatDeploy extends Component {
|
|
|
+ constructor(props) {
|
|
|
+ super(props)
|
|
|
+ this.state = {
|
|
|
+ dbKind: 'fc-db',
|
|
|
+ customName: props.bucketName,
|
|
|
+ deployButton: true,
|
|
|
+ deploySuccess: false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ render() {
|
|
|
+ let {customName, dbKind, deployButton, deploySuccess} = this.state
|
|
|
+ let {bucketName, userID} = this.props;
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ <div>
|
|
|
+ <div className={'schema-name'}><FormattedMessage id='Name'/></div>
|
|
|
+ <div>
|
|
|
+ <span className='item-title-cloud'><FormattedMessage id='name'/>:</span>
|
|
|
+ <Input style={{width: 250}} value={customName}
|
|
|
+ onChange={(e) => {
|
|
|
+ this.setState({customName: e.target.value})
|
|
|
+ }}/>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div style={{marginTop: 20}}>
|
|
|
+ <div className={'schema-name'}><FormattedMessage id='DB Choose'/></div>
|
|
|
+ <RadioGroup onChange={(e) => {
|
|
|
+ this.setState({dbKind: e.target.value})
|
|
|
+ }} value={dbKind}>
|
|
|
+ <Radio value='fc-db'>fc-db</Radio>
|
|
|
+ <Radio value='mongodb'>mongodb</Radio>
|
|
|
+ </RadioGroup>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {
|
|
|
+ deployButton?
|
|
|
+ <Button type='primary' onClick={() => {
|
|
|
+ this.setState({
|
|
|
+ deployButton: false
|
|
|
+ })
|
|
|
+ let functionName = customName,
|
|
|
+ resources = [`${bucketName}/schema.edn`, `${bucketName}/resolve-map.edn`, `${bucketName}/${dbKind}/${userID}/deploy-conf.edn`, `${bucketName}/html/index.html`, `${bucketName}/wx-config.edn`];
|
|
|
+
|
|
|
+ if (dbKind === 'mongodb') {
|
|
|
+ resources.push(`${bucketName}/${dbKind}/${userID}/mongo-config.edn`)
|
|
|
+ }
|
|
|
+ axios.post(deployFC, {
|
|
|
+ 'fc-name': userID + '_' + functionName,
|
|
|
+ 'bucket': dbKind === 'mongodb' ? 'native-fc' : 'fcdb-deploy',
|
|
|
+ 'object-file': 'fc-only.zip',
|
|
|
+ 'res-bucket': 'case',
|
|
|
+ 'resources': resources
|
|
|
+ }).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ this.setState({
|
|
|
+ deployButton: true,
|
|
|
+ deploySuccess: true
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }}>使用</Button>
|
|
|
+ :
|
|
|
+ '正在部署中...'
|
|
|
+ }
|
|
|
+ {
|
|
|
+ deploySuccess?
|
|
|
+ '部署成功' : ''
|
|
|
+ }
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|