kulley 7 jaren geleden
bovenliggende
commit
ab5a0db1a7

+ 9 - 3
src/app/basicVersion/BasicVersion.jsx

@@ -130,9 +130,15 @@ class BasicVersion extends Component {
                         <Menu.Item key="example">
                             <Link to="/common/example"><FormattedMessage id="Example"/></Link>
                         </Menu.Item>
-                        <Menu.Item key="my-deploy">
-                            <Link to="/common/deploy"><FormattedMessage id="My deploy"/></Link>
-                        </Menu.Item>
+                        {
+                            !!this.state.userID?
+                                <Menu.Item key="my-deploy">
+                                    <Link to="/common/deploy"><FormattedMessage id="My deploy"/></Link>
+                                </Menu.Item>
+                                :
+                                ''
+                        }
+
                         <Menu.Item key="communication">
                             <Link to="/common/communication"><FormattedMessage id="Communication"/></Link>
                         </Menu.Item>

+ 308 - 126
src/app/basicVersion/exampleShow/DeployCloudChoose.js

@@ -1,93 +1,102 @@
 import React, {Component} from 'react';
-import {Layout, Button, notification, Spin} from 'antd';
+import {Layout, Button, notification, Spin, Row, Col, Icon, message, Input, Radio, Modal} from 'antd';
 import {getCookie} from "../../../cookie";
 import {graphqlUrl, storeFile} from "../../../config";
-import {SHOW_CLOUD} from "../../../gql";
+import {SEARCH_APIGROUP, SHOW_CLOUD} from "../../../gql";
 import {request} from 'graphql-request'
 import axios from 'axios';
 import {deployAll} from "../../../config";
 import {ADD_APIGWPATH, ADD_APIGROUP, ADD_DEPLOY, ADD_PROJECT} from "../../../gql";
 import {idGen} from "../../../func";
+import {FormattedMessage} from 'react-intl';
+import copy from 'copy-to-clipboard';
+import {CloudConfig} from '../../../login/CloudConfig';
 
 const {Content} = Layout;
+const RadioGroup = Radio.Group;
 axios.defaults.withCredentials = true;
 
 class DeployCloudChoose extends Component {
     constructor() {
         super();
         this.state = {
-            userID: 'demo',
-            dbKind: 'mongodb', // mongodb fc-db
+            userID: '',
+            check: new Date().getTime(),
+
+            disableDeployButton: false,
+            domain: '',
+
             cloudName: 'tencent',
-            cloudID: 'tencent_CloudID',
+            cloudID: '',
             secretID: '',
             secretKey: '',
             appId: '',
+
+            customName: '',
             bucketName: '',
-            disabled: false
+            dbKind: 'fc-db', // mongodb fc-db
         }
     }
 
     componentWillMount() {
         this._isMounted = true;
-        let userID = getCookie('user_id') || this.state.userID;
+
+        // 查询是否登录
+        let userID = getCookie('user_id');
         if (userID !== undefined && userID !== '') {
             this.setState({
                 userID
             });
-
-            // 查询是否设置 cloud
-            request(graphqlUrl, SHOW_CLOUD, {user_id: userID}).then(data => {
-                    data.cloud_by_props.forEach(cloud => {
-                        switch (cloud.cloudName) {
-                            case 'tencent':
-                                this.setState({
-                                    cloudID: cloud.id,
-                                    secretID: cloud.secretId,
-                                    secretKey: cloud.secretKey,
-                                    appId: cloud.appId,
-                                    cloudName: 'tencent'
-                                });
-                                break;
-                            case 'aliyun':
-                                // 没写
-                                break;
-                            case 'amazon':
-                                // 没写
-                                break;
-                            default:
-                                break;
-                        }
-                    });
-                }
-            )
         }
+
+        // 查询跳转来的案例,转成 apigroup id
+        let groupID = '';
         if (this.props.location && this.props.location.state) {
             switch (this.props.location.state.schemaID) {
                 case 'order_schemaID':
                     this.setState({
                         bucketName: 'appointment'
                     });
+                    groupID = 'order';
                     break;
                 case 'ecommerce_schemaID':
                     this.setState({
                         bucketName: 'e-commerce'
                     });
+                    groupID = 'ecommerce';
+                    break;
+                case 'bills_schemaID':
+                    this.setState({
+                        bucketName: 'bills'
+                    });
+                    groupID = 'bills';
                     break;
                 default:
                     break;
             }
         }
+
+        // 查询该案例的 domain
+        request(graphqlUrl, SEARCH_APIGROUP, {id: groupID}).then(res => {
+            let caseDeploy = res.apiGWGroupbyid;
+            let domain = caseDeploy.defaultDomain;
+            if (this._isMounted) {
+                this.setState({
+                    domain
+                })
+            }
+        })
+
     }
 
     componentWillUnmount() {
         this._isMounted = false;
     }
 
-    deploy() {
+    deploy = () => {
         this._isMounted = true;
         let _this = this;
-        let {userID, dbKind, bucketName} = this.state;
+        let {userID, dbKind, bucketName, customName} = this.state;
 
         if (bucketName === '') {
             console.log('state, 没有传值');
@@ -96,12 +105,12 @@ class DeployCloudChoose extends Component {
             // 开始调用
             console.log('开始调用');
             this.setState({
-                disabled: true
+                disableDeployButton: true
             });
 
             let now = new Date().getTime(),
-                functionName = this.state.userID + '_' + bucketName.substr(0, 2) + '_' + now,
-                serviceName = this.state.userID + '_' + bucketName.substr(0, 2) + '_' + now,
+                functionName = this.state.userID + '_' + customName,
+                serviceName = this.state.userID + '_' + customName,
                 resources = [`${bucketName}/schema.edn`, `${bucketName}/resolve-map.edn`, `${bucketName}/${dbKind}/${userID}/deploy-conf.edn`];
 
             if (dbKind === 'mongodb') {
@@ -113,7 +122,7 @@ class DeployCloudChoose extends Component {
             axios.post(deployAll,
                 {
                     'fc-name': functionName,
-                    'bucket': dbKind === 'mongodb'? 'native-fc' : 'fcdb-deploy',
+                    'bucket': dbKind === 'mongodb' ? 'native-fc' : 'fcdb-deploy',
                     'object-file': 'fc-only.zip',
                     'res-bucket': 'case',
                     'resources': resources,
@@ -122,7 +131,7 @@ class DeployCloudChoose extends Component {
                 })
                 .then(function (response) {
                     console.log('response', response);
-                    if(response['data']['apigw-result'] && response['data']['fc-result']) {
+                    if (response['data']['apigw-result'] && response['data']['fc-result']) {
                         // 处理数据
                         let result = response['data']['apigw-result'];
                         let apiData = result['api-info'];
@@ -219,9 +228,9 @@ class DeployCloudChoose extends Component {
                                 console.log(value);
 
                                 // 展示数据
-                                if(_this._isMounted) {
+                                if (_this._isMounted) {
                                     _this.setState({
-                                        disabled: false
+                                        disableDeployButton: false
                                     });
                                 }
 
@@ -246,33 +255,58 @@ class DeployCloudChoose extends Component {
                     console.log('axios error', error);
                 });
         }
-    }
+    };
+
+    getCloudDetail = (cloudID, secretID, secretKey, appId) => {
+        this.setState({
+            cloudID,
+            secretID,
+            secretKey,
+            appId
+        })
+    };
 
     render() {
-        let {userID, disabled, appId, secretID, secretKey, bucketName, dbKind} = this.state;
+        let {userID, disableDeployButton, appId, secretID, secretKey, bucketName, dbKind, domain, showCustom, cloudName, check} = this.state;
         return (
             <div className={'deploy-choose-cloud'}>
                 <Layout style={{padding: '24px', minHeight: '300px'}}>
                     <Content style={{padding: '20px 50px', background: '#fff'}}>
-                        <div className={'choose-cloud'}>
-                            <span className={'choose-cloud-title'}>系统默认设置</span><span
-                            className={'choose-cloud-content'}>部署在系统云服务商,部署成功后返回结果</span>
+
+                        <div>
+                            <div className={'schema-name'}><FormattedMessage id='case graphql domain'/></div>
+                            <div className={'schema-table-list-title'}>
+                                <Row>
+                                    <Col span={15}><span className={'schema-table-title'}><FormattedMessage
+                                        id='defaultDomain'/></span></Col>
+                                </Row>
+                            </div>
+                            <div className={'schema-table-list-content'}>
+                                <Row>
+                                    <Col span={15}>
+                                        <span className={'schema-table-content'}>{domain} </span>
+                                        <Icon type="copy" theme="twoTone" onClick={() => {
+                                            copy(domain);
+                                            message.success('复制成功.');
+                                        }}/>
+                                    </Col>
+                                </Row>
+                            </div>
                         </div>
-                        <div className={'choose-cloud'}>
-                            <span className={'choose-cloud-title'}>自定义设置</span><span
-                            className={'choose-cloud-content'}>部署在自有云服务商,部署成功后返回结果,可登陆云服务商后台查看部署结果</span>
+
+
+                        <div style={{marginTop: 20, fontSize: 20}}>
+                            <div className={'schema-name'}><FormattedMessage id='detail'/></div>
+                            这里巴拉巴拉
                         </div>
-                        <div className={'choose-cloud-button-group'}>
+
+
+                        <div style={{marginTop: 20}}>
                             {
-                                disabled ?
-                                    <Spin/>
-                                    :
-                                    <div>
-                                        <Button className={'choose-cloud-button'} type='primary' onClick={() => {
-                                            this.deploy();
-                                        }}>系统默认部署</Button>
+                                !showCustom ?
+                                    <div className={'choose-cloud-button-group'}>
                                         <Button className={'choose-cloud-button'} type='primary' onClick={() => {
-                                            if (userID === 'demo') {
+                                            if (userID === '') {
                                                 notification['warning']({
                                                     message: '需要登录',
                                                     description: '后续使用,需要先登录',
@@ -282,75 +316,123 @@ class DeployCloudChoose extends Component {
                                                     pathname: `/login`
                                                 })
                                             } else {
-                                                if (appId && secretID && secretKey) {
-                                                    this.setState({
-                                                        disabled: true
-                                                    });
-
-                                                    // store *.edn to cos
-                                                    let deployConf = dbKind === 'mongodb' ?
-                                                        ` {:secretId "${secretID}"\n` +
-                                                        ` :secretKey "${secretKey}"\n` +
-                                                        ` :appId "${appId}"\n` +
-                                                        ' :region "ap-beijing" \n' +
-                                                        ' }\n'
-                                                        :
-                                                        ` {:secretId "${secretID}"\n` +
-                                                        ` :secretKey "${secretKey}"\n` +
-                                                        ` :appId "${appId}"\n` +
-                                                        ' :region "ap-beijing"\n' +
-                                                        ' :bucket "fc-db"\n' +
-                                                        ' :trustStore "/etc/ssl/certs/java/cacerts"\n' +
-                                                        ` :fc-db-store "save/${bucketName}.dat"\n` +
-                                                        ' :fc-db-dir "fc-db"\n' +
-                                                        ' :graphql-url "http://orderfcdb.ioobot.cn/graphql"\n' +
-                                                        ' :local-tmp-dir "/tmp"\n' +
-                                                        ' :local-db-file "fcdb.dat"\n' +
-                                                        ' :update-tx? true \n' +
-                                                        ' :force-down? true\n' +
-                                                        ' }';
-
-                                                    let a = axios.post(storeFile, {
-                                                        'file-name': `${bucketName}/${dbKind}/${userID}/deploy-conf.edn`,
-                                                        bucket: 'case',
-                                                        cont: deployConf
-                                                    });
-
-                                                    let cont = '{:uri {\n' +
-                                                        ':auth {:admin-db   "order"\n' +
-                                                        ' :u    "ly"\n' +
-                                                        ' :p   "autorunC1705"\n' +
-                                                        ' :host "119.27.174.13"}}\n' +
-                                                        ' :db-name "order"}';
-
-                                                    let b = dbKind === 'mongodb' ?
-                                                        axios.post(storeFile, {
-                                                            'file-name': `${bucketName}/${dbKind}/${userID}/mongo-config.edn`,
-                                                            bucket: 'case',
-                                                            cont
-                                                        })
-                                                        :
-                                                        Promise.resolve({status: 200});
-
-                                                    Promise.all([a, b]).then(value=> {
-                                                        if(value.every(res=> res.status === 200)) {
-                                                            console.log('store file success , start deploying');
-                                                            this.deploy();
-                                                        }
-                                                    });
-                                                } else {
-                                                    notification['warning']({
-                                                        message: '需要填写配置',
-                                                        description: '后续使用,需要先填写配置',
-                                                    });
-
-                                                    this.props.history.push({
-                                                        pathname: `/login/cloud`
-                                                    })
-                                                }
+                                                this.setState({
+                                                    showCustom: true
+                                                })
                                             }
                                         }}>自定义参数设置</Button>
                                     </div>
+                                    :
+                                    <div>
+                                        <hr/>
+                                        <div>
+                                            <div className={'schema-name'}><FormattedMessage id='Name'/></div>
+                                            <div>
+                                                <span className='item-title-cloud'><FormattedMessage id='name'/>:</span>
+                                                <Input style={{width: 250}} value={this.state.customName}
+                                                       onChange={(e) => {
+                                                           this.setState({customName: e.target.value})
+                                                       }}/>
+                                            </div>
+                                        </div>
+                                        <div style={{marginTop: 20}}>
+                                            <div className={'schema-name'}><FormattedMessage id='Cloud Setting'/></div>
+                                            <RadioGroup onChange={(e) => {
+                                                this.setState({cloudName: e.target.value})
+                                            }} value={this.state.cloudName}>
+                                                <Radio value={'tencent'}><FormattedMessage id='tencent cloud'/></Radio>
+                                                <Radio value={'aliyun'}><FormattedMessage id='aliyun'/></Radio>
+                                                <Radio value={'amazon'}><FormattedMessage id='amazon cloud'/></Radio>
+                                            </RadioGroup>
+                                            <CloudQueryAndConfig cloudName={cloudName} userID={userID}
+                                                                 getCloudDetail={this.getCloudDetail} check={check}
+                                                                 reCheck={() => {
+                                                                     this.setState({check: new Date().getTime()})
+                                                                 }}/>
+                                        </div>
+                                        <div style={{marginTop: 20}}>
+                                            <div className={'schema-name'}><FormattedMessage id='DB Choose'/></div>
+                                            <RadioGroup onChange={(e) => {
+                                                this.setState({dbKind: e.target.value})
+                                            }} value={this.state.dbKind}>
+                                                <Radio value='fc-db'>fc-db</Radio>
+                                                <Radio value='mongodb'>mongodb</Radio>
+                                            </RadioGroup>
+                                        </div>
+                                        {
+                                            disableDeployButton ?
+                                                <Spin/>
+                                                :
+                                                <Button style={{marginTop: 20}} type='primary' onClick={() => {
+                                                    if (appId && secretID && secretKey) {
+                                                        this.setState({
+                                                            disableDeployButton: true
+                                                        });
+
+                                                        // store *.edn to cos
+                                                        let deployConf = dbKind === 'mongodb' ?
+                                                            ` {:secretId "${secretID}"\n` +
+                                                            ` :secretKey "${secretKey}"\n` +
+                                                            ` :appId "${appId}"\n` +
+                                                            ' :region "ap-beijing" \n' +
+                                                            ' }\n'
+                                                            :
+                                                            ` {:secretId "${secretID}"\n` +
+                                                            ` :secretKey "${secretKey}"\n` +
+                                                            ` :appId "${appId}"\n` +
+                                                            ' :region "ap-beijing"\n' +
+                                                            ' :bucket "fc-db"\n' +
+                                                            ' :trustStore "/etc/ssl/certs/java/cacerts"\n' +
+                                                            ` :fc-db-store "save/${bucketName}.dat"\n` +
+                                                            ' :fc-db-dir "fc-db"\n' +
+                                                            ' :graphql-url "http://orderfcdb.ioobot.cn/graphql"\n' +
+                                                            ' :local-tmp-dir "/tmp"\n' +
+                                                            ' :local-db-file "fcdb.dat"\n' +
+                                                            ' :update-tx? true \n' +
+                                                            ' :force-down? true\n' +
+                                                            ' }';
+
+                                                        let a = axios.post(storeFile, {
+                                                            'file-name': `${bucketName}/${dbKind}/${userID}/deploy-conf.edn`,
+                                                            bucket: 'case',
+                                                            cont: deployConf
+                                                        });
+
+                                                        let cont = '{:uri {\n' +
+                                                            ':auth {:admin-db   "order"\n' +
+                                                            ' :u    "ly"\n' +
+                                                            ' :p   "autorunC1705"\n' +
+                                                            ' :host "119.27.174.13"}}\n' +
+                                                            ' :db-name "order"}';
+
+                                                        let b = dbKind === 'mongodb' ?
+                                                            axios.post(storeFile, {
+                                                                'file-name': `${bucketName}/${dbKind}/${userID}/mongo-config.edn`,
+                                                                bucket: 'case',
+                                                                cont
+                                                            })
+                                                            :
+                                                            Promise.resolve({status: 200});
+
+                                                        Promise.all([a, b]).then(value => {
+                                                            if (value.every(res => res.status === 200)) {
+                                                                console.log('store file success , start deploying');
+                                                                this.deploy();
+                                                            }
+                                                        });
+                                                    } else {
+                                                        notification['warning']({
+                                                            message: '需要填写配置',
+                                                            description: '后续使用,需要先填写配置',
+                                                        });
+
+                                                        this.props.history.push({
+                                                            pathname: `/login/cloud`
+                                                        })
+                                                    }
+                                                }}>部署</Button>
+                                        }
+                                    </div>
                             }
                         </div>
                     </Content>
@@ -360,4 +442,104 @@ class DeployCloudChoose extends Component {
     }
 }
 
-export default DeployCloudChoose
+export default DeployCloudChoose
+
+class CloudQueryAndConfig extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            cloudName: props.cloudName,
+            userID: props.userID,
+            cloudID: '',
+            secretID: '',
+            secretKey: '',
+            appId: '',
+            showCloudConfigTip: false,
+
+            visible: false,
+            confirmLoading: false,
+        }
+    }
+
+    searchCloud = () => {
+        let {userID, cloudName} = this.state;
+        // 如果登录,查询该用户是否设置 cloud
+        request(graphqlUrl, SHOW_CLOUD, {user_id: userID}).then(data => {
+                let clouds = data.cloud_by_props.filter(cloud => cloud.cloudName === cloudName);
+                // 如果限制一个云服务商一个 cloud,那么就是clouds[0]
+                if (clouds.length === 1) {
+                    let cloud = clouds[0];
+                    let {id, secretId, secretKey, appId} = cloud;
+                    this.setState({
+                        cloudID: id,
+                        secretID: secretId,
+                        secretKey,
+                        appId
+                    });
+                    this.props.getCloudDetail(id, secretId, secretKey, appId);
+                    this.setState({
+                        showCloudConfigTip: false
+                    })
+                } else if (clouds.length > 1) {
+                    console.log('数据库有多个同一云服务商的 key');
+                } else {
+                    this.setState({
+                        showCloudConfigTip: true
+                    })
+                }
+            }
+        )
+    };
+
+    componentWillMount() {
+        this.searchCloud()
+    }
+
+    componentWillReceiveProps(next) {
+        this.setState({
+            cloudName: next.cloudName,
+            userID: next.userID,
+        }, this.searchCloud);
+    }
+
+    showModal = () => {
+        this.setState({
+            visible: true,
+        });
+    };
+
+    handleCancel = () => {
+        this.setState({
+            visible: false,
+        });
+        this.props.reCheck();
+    };
+
+
+    render() {
+        let {showCloudConfigTip, visible, confirmLoading} = this.state;
+        return (
+            <div>
+                {
+                    showCloudConfigTip ?
+                        <div>
+                            <Button type="danger" size="small" onClick={this.showModal}>
+                                <FormattedMessage id='no this cloud, click to save'/>
+                            </Button>
+                            <Modal
+                                title="设置 cloud"
+                                visible={visible}
+                                confirmLoading={confirmLoading}
+                                footer={null}
+                                onCancel={this.handleCancel}
+                            >
+                                <CloudConfig/>
+                            </Modal>
+                        </div>
+                        :
+                        ''
+                }
+            </div>
+        )
+    }
+}

+ 6 - 5
src/app/basicVersion/myDeploy/TencentDeploy.js

@@ -47,10 +47,11 @@ class TencentDeploy extends Component {
 
     render() {
         let {userID, url, deployed, show} = this.state;
+        let regexp = new RegExp(userID + '_');
         return (
             <div>
                 {
-                    userID === 'demo' && !!url ?
+                    userID === '' && !!url ?
                         <Alert
                             message="WARNING"
                             description="it will be deleted soon, please login to deploy in your owm account"
@@ -72,7 +73,7 @@ class TencentDeploy extends Component {
                             <div className={'schema-table-list-content'}>
                                 <Row>
                                     <Col span={15}>
-                                        <span className={'schema-table-content'}>{`http://${url}/test/graphql`} </span>
+                                        <span className={'schema-table-content'}>{url} </span>
                                         <Icon type="copy" theme="twoTone" onClick={() => {
                                             copy(url);
                                             message.success('复制成功.');
@@ -84,8 +85,9 @@ class TencentDeploy extends Component {
                         :
                         ''
                 }
+
                 {
-                    userID === 'demo' ?
+                    userID === '' ?
                         <div style={{marginTop: 50}}>
                             <FormattedMessage id='go to deploy,then see more'/>
                         </div>
@@ -110,8 +112,7 @@ class TencentDeploy extends Component {
                                             deployed.map(deploy => (
                                                 <Row key={deploy.id}>
                                                     <Col span={5}>
-                                                        <span
-                                                            className={'schema-table-content'}>{deploy.serviceId}</span>
+                                                        <span className={'schema-table-content'}>{deploy.groupName.replace(regexp, '')}</span>
                                                     </Col>
                                                     <Col span={15}>
                                                         <span

+ 22 - 2
src/gql.js

@@ -561,9 +561,28 @@ const UPDATE_DEPLOY = `
             }
         `;
 
+const SEARCH_APIGROUP = `
+    query apiGWGroupbyid($id: ID) {
+          apiGWGroupbyid: apiGWGroup_by_id(id: $id) {
+                environmentName
+                userStatus
+                defaultDomain
+                updatedAt
+                userDomain
+                groupName
+                createdAt
+                frontType
+                region
+                serviceId
+                status
+                id
+          }
+}
+`;
+
 const SHOW_APIGROUP = `
-    query apiGWGroupbyprops($user_id: ID) {
-          apiGWGroupbyprops: apiGWGroup_by_props(user_id: $user_id) {
+    query apiGWGroupbyprops($user_id: ID, $groupName: String) {
+          apiGWGroupbyprops: apiGWGroup_by_props(user_id: $user_id, groupName: $groupName) {
                 environmentName
                 userStatus
                 defaultDomain
@@ -1068,6 +1087,7 @@ export {
     UPDATE_CLOUD,
     ADD_DEPLOY,
     UPDATE_DEPLOY,
+    SEARCH_APIGROUP,
     SHOW_APIGROUP,
     ADD_APIGROUP,
     UPDATE_APIGROUP,

+ 9 - 1
src/language/en_US.js

@@ -164,6 +164,14 @@ const en_US = {
     'loading': 'loading...',
     'nothing': 'nothing...',
     'new': 'new!',
-    'go to deploy,then see more': 'go to deploy,then see more'
+    'go to deploy,then see more': 'go to deploy,then see more',
+    'case graphql domain': 'case graphql domain',
+    'Cloud Setting': 'Cloud Setting',
+    'DB Choose': 'DataBase Type Choose',
+    'detail': 'Detail',
+    'tencent cloud': 'Tencent Cloud',
+    'aliyun': 'Aliyun',
+    'amazon cloud': 'AWS',
+    'no this cloud, click to save': 'no this cloud, click to save'
 };
 export default en_US;

+ 9 - 1
src/language/zh_CN.js

@@ -165,6 +165,14 @@ const zh_CN = {
     'loading': '加载中...',
     'nothing': '暂无部署...',
     'new': '新!',
-    'go to deploy,then see more': '部署以查看更多'
+    'go to deploy,then see more': '部署以查看更多',
+    'case graphql domain': '案例 graphql 地址',
+    'Cloud Setting': '云服务商参数',
+    'DB Choose': '选择数据库类型',
+    'detail': '详情',
+    'tencent cloud': '腾讯云',
+    'aliyun': '阿里云',
+    'amazon cloud': 'AWS',
+    'no this cloud, click to save': '没有该服务商的 key,点我设置'
 };
 export default zh_CN;

+ 117 - 125
src/login/CloudConfig.js

@@ -88,9 +88,6 @@ class CloudConfig extends Component {
                                 this.setState({
                                     showOK: ''
                                 });
-                                this.props.history.push({
-                                    pathname: '/'
-                                })
                             }, 1500)
                         } else {
                             this.setState({
@@ -141,140 +138,135 @@ class CloudConfig extends Component {
 
     render() {
         return (
-            this.state.userID !== '' ?
+            <div>
+                {
+                    this.state.show ?
+                        <div>
 
-                this.state.show ?
-                    <div>
-                        <div className="column-menu" onClick={() => {
-                            this.props.history.push({
-                                pathname: '/login',
-                            })
-                        }}>
-                            <Icon type="left" style={{color: '#3187FA'}}/> <FormattedMessage id="login"/>
-                        </div>
-
-                        <div style={{marginTop: 15}}>
-                            <span className='cloud-name'><FormattedMessage id="Tencent"/>: </span>
-                            <div style={{marginBottom: 15}}>
-                                <div>
-                                    <div style={{marginBottom: 20}}>
-                                        <span className='item-title-cloud'>APPID:</span>
-                                        <Input style={{width: 250}} value={this.state.tenAppID}
-                                               onChange={this.inputChange('tenAppID')}/>
-                                    </div>
-                                    <div style={{marginBottom: 20}}>
-                                        <span className='item-title-cloud'>SecretId:</span>
-                                        <Input style={{width: 250}} value={this.state.tenID}
-                                               onChange={this.inputChange('tenID')}/>
-                                    </div>
-                                    <div style={{marginBottom: 20}}>
-                                        <span className='item-title-cloud'>SecretKey:</span>
-                                        <Input style={{width: 250}} value={this.state.tenKey}
-                                               onChange={this.inputChange('tenKey')}/>
-                                    </div>
-                                    {
-                                        this.state.showOK === 'tencent' ?
-                                            <Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/>
-                                            :
-                                            this.state.showNotOK === 'tencent' ?
-                                                <span>not ok</span>
+                            <div style={{marginTop: 15}}>
+                                <span className='cloud-name'><FormattedMessage id="Tencent"/>: </span>
+                                <div style={{marginBottom: 15}}>
+                                    <div>
+                                        <div style={{marginBottom: 20}}>
+                                            <span className='item-title-cloud'>APPID:</span>
+                                            <Input style={{width: 250}} value={this.state.tenAppID}
+                                                   onChange={this.inputChange('tenAppID')}/>
+                                        </div>
+                                        <div style={{marginBottom: 20}}>
+                                            <span className='item-title-cloud'>SecretId:</span>
+                                            <Input style={{width: 250}} value={this.state.tenID}
+                                                   onChange={this.inputChange('tenID')}/>
+                                        </div>
+                                        <div style={{marginBottom: 20}}>
+                                            <span className='item-title-cloud'>SecretKey:</span>
+                                            <Input style={{width: 250}} value={this.state.tenKey}
+                                                   onChange={this.inputChange('tenKey')}/>
+                                        </div>
+                                        {
+                                            this.state.showOK === 'tencent' ?
+                                                <Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/>
                                                 :
-                                                ""
-                                    }
+                                                this.state.showNotOK === 'tencent' ?
+                                                    <span>not ok</span>
+                                                    :
+                                                    ""
+                                        }
+                                    </div>
+                                    <Button type='primary'
+                                            onClick={this.submit(this.state.tencentCLoudID, 'tencent', this.state.tenID, this.state.tenKey, this.state.tenAppID)}>
+                                        <FormattedMessage id="save"/>
+                                    </Button>
                                 </div>
-                                <Button type='primary'
-                                        onClick={this.submit(this.state.tencentCLoudID, 'tencent', this.state.tenID, this.state.tenKey, this.state.tenAppID)}>
-                                    <FormattedMessage id="save"/>
-                                </Button>
                             </div>
-                        </div>
 
-                        {/*<div>*/}
-                        {/*<span className='cloud-name'><FormattedMessage id="Aliyun"/>: </span>*/}
-                        {/*<div style={{marginBottom: 15}}>*/}
-                        {/*<div>*/}
-                        {/*<div style={{marginBottom: 10}}>*/}
-                        {/*<span className='item-title-cloud'>ID:</span>*/}
-                        {/*<Input style={{width: 250}} value={this.state.aliID} onChange={this.inputChange('aliID')}/>*/}
-                        {/*</div>*/}
-                        {/*<div style={{marginBottom: 10}}>*/}
-                        {/*<span className='item-title-cloud'>Key:</span>*/}
-                        {/*<Input style={{width: 250}} value={this.state.aliKey} onChange={this.inputChange('aliKey')}/>*/}
-                        {/*</div>*/}
+                            <div>
+                                <span className='cloud-name'><FormattedMessage id="Aliyun"/>: </span>
+                                <div style={{marginBottom: 15}}>
+                                    <div>
+                                        <div style={{marginBottom: 10}}>
+                                            <span className='item-title-cloud'>ID:</span>
+                                            <Input style={{width: 250}} value={this.state.aliID}
+                                                   onChange={this.inputChange('aliID')}/>
+                                        </div>
+                                        <div style={{marginBottom: 10}}>
+                                            <span className='item-title-cloud'>Key:</span>
+                                            <Input style={{width: 250}} value={this.state.aliKey}
+                                                   onChange={this.inputChange('aliKey')}/>
+                                        </div>
 
-                        {/*{*/}
-                        {/*this.state.showOK === 'aliyun' ?*/}
-                        {/*<Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/>*/}
-                        {/*:*/}
-                        {/*this.state.showNotOK === 'aliyun' ?*/}
-                        {/*<span>not ok</span>*/}
-                        {/*:*/}
-                        {/*""*/}
-                        {/*}*/}
-                        {/*</div>*/}
-                        {/*<Button type='primary'*/}
-                        {/*onClick={this.submit(this.state.aliyunCLoudID, 'aliyun', this.state.aliID, this.state.aliKey)}>*/}
-                        {/*<FormattedMessage id="save"/>*/}
-                        {/*</Button>*/}
-                        {/*</div>*/}
-                        {/*</div>*/}
-
-                        {/*<div>*/}
-                        {/*<span className='cloud-name'><FormattedMessage id="AWS"/>: </span>*/}
-                        {/*<div style={{marginBottom: 15}}>*/}
-                        {/*<div>*/}
-                        {/*<div style={{marginBottom: 10}}>*/}
-                        {/*<span className='item-title-cloud'>ID:</span>*/}
-                        {/*<Input style={{width: 250}} value={this.state.aliID} onChange={this.inputChange('awsID')}/>*/}
-                        {/*</div>*/}
-                        {/*<div style={{marginBottom: 10}}>*/}
-                        {/*<span className='item-title-cloud'>Key:</span>*/}
-                        {/*<Input style={{width: 250}} value={this.state.aliKey} onChange={this.inputChange('awsKey')}/>*/}
-                        {/*</div>*/}
-                        {/*{*/}
-                        {/*this.state.showOK === 'amazon' ?*/}
-                        {/*<Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/>*/}
-                        {/*:*/}
-                        {/*this.state.showNotOK === 'amazon' ?*/}
-                        {/*<span>not ok</span>*/}
-                        {/*:*/}
-                        {/*""*/}
-                        {/*}*/}
-                        {/*</div>*/}
-                        {/*<Button type='primary'*/}
-                        {/*onClick={this.submit(this.state.awsCLoudID, 'amazon', this.state.awsID, this.state.awsKey)}>*/}
-                        {/*<FormattedMessage id="save"/>*/}
-                        {/*</Button>*/}
-                        {/*</div>*/}
-                        {/*</div>*/}
+                                        {
+                                            this.state.showOK === 'aliyun' ?
+                                                <Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/>
+                                                :
+                                                this.state.showNotOK === 'aliyun' ?
+                                                    <span>not ok</span>
+                                                    :
+                                                    ""
+                                        }
+                                    </div>
+                                    <Button type='primary'
+                                            onClick={this.submit(this.state.aliyunCLoudID, 'aliyun', this.state.aliID, this.state.aliKey)}>
+                                        <FormattedMessage id="save"/>
+                                    </Button>
+                                </div>
+                            </div>
 
-                    </div>
-                    :
-                    <Spin style={{marginLeft: 3}}/>
-                :
-                <Row style={{marginTop: 100}}>
-                    <Col span={12} offset={6} className={'cloud-wrapper'}>
-                        <Row>
-                            <Col span={4} offset={20}>
-                                <div className="back-to-login" onClick={() => {
-                                    this.props.history.push({
-                                        pathname: '/login',
-                                    })
-                                }}>
-                                    <FormattedMessage id="login"/> <Icon type="right"
-                                                                         style={{color: '#848fa6'}}/>
+                            <div>
+                                <span className='cloud-name'><FormattedMessage id="AWS"/>: </span>
+                                <div style={{marginBottom: 15}}>
+                                    <div>
+                                        <div style={{marginBottom: 10}}>
+                                            <span className='item-title-cloud'>ID:</span>
+                                            <Input style={{width: 250}} value={this.state.awsID}
+                                                   onChange={this.inputChange('awsID')}/>
+                                        </div>
+                                        <div style={{marginBottom: 10}}>
+                                            <span className='item-title-cloud'>Key:</span>
+                                            <Input style={{width: 250}} value={this.state.awsKey}
+                                                   onChange={this.inputChange('awsKey')}/>
+                                        </div>
+                                        {
+                                            this.state.showOK === 'amazon' ?
+                                                <Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/>
+                                                :
+                                                this.state.showNotOK === 'amazon' ?
+                                                    <span>not ok</span>
+                                                    :
+                                                    ""
+                                        }
+                                    </div>
+                                    <Button type='primary'
+                                            onClick={this.submit(this.state.awsCLoudID, 'amazon', this.state.awsID, this.state.awsKey)}>
+                                        <FormattedMessage id="save"/>
+                                    </Button>
                                 </div>
-                            </Col>
-                        </Row>
-                        <div className={'no-login-tip'}>
-                            <span>你还没有登录</span>
+                            </div>
+
                         </div>
-                    </Col>
-                </Row>
+                        :
+                        <Spin style={{marginLeft: 3}}/>
+                }
+            </div>
         )
     }
 }
 
-export default CloudConfig;
+const CloudConfigWrapper = (props) => {
+    return (
+        <div>
+            <div className="column-menu" onClick={() => {
+                props.history.push({
+                    pathname: '/login',
+                })
+            }}>
+                <Icon type="left" style={{color: '#3187FA'}}/> <FormattedMessage id="login"/>
+            </div>
+            <CloudConfig {...props}/>
+        </div>
+    )
+};
+
+export {CloudConfig};
+export default CloudConfigWrapper;