|
|
@@ -1,11 +1,14 @@
|
|
|
import React, {Component} from 'react';
|
|
|
-import {Input, Collapse, Button, Radio, Icon, Tooltip} from 'antd';
|
|
|
-import {ADD_APIGROUP, UPDATE_APIGROUP, UPDATE_PROJECT_GROUP} from "../../../../gql";
|
|
|
+import {Input, Collapse, Button, Radio, Icon, Tooltip, Spin} from 'antd';
|
|
|
+import {ADD_APIGROUP, GET_PROJECT, UPDATE_APIGROUP, UPDATE_PROJECT_GROUP} from "../../../../gql";
|
|
|
import {request} from 'graphql-request'
|
|
|
import {idGen} from "../../../../func";
|
|
|
import {graphqlUrl} from "../../../../config";
|
|
|
import {manageUsers} from "../../../../config";
|
|
|
import {FormattedMessage} from 'react-intl';
|
|
|
+import {Query} from "react-apollo";
|
|
|
+import gql from "graphql-tag";
|
|
|
+
|
|
|
const Panel = Collapse.Panel;
|
|
|
|
|
|
// 如需改变显示,请在此处 value 处更改
|
|
|
@@ -54,7 +57,7 @@ const shiftPrefix = (prefix, value) => {
|
|
|
class APIGroupCard extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
- if(props.group !== '' && props.group !== null) {
|
|
|
+ if (props.group !== '' && props.group !== null) {
|
|
|
let {groupName, environmentName, defaultDomain, frontType, userDomain, userStatus, region} = props.group;
|
|
|
this.state = {
|
|
|
showOK: false,
|
|
|
@@ -81,19 +84,19 @@ class APIGroupCard extends Component {
|
|
|
}
|
|
|
|
|
|
componentWillReceiveProps(next) {
|
|
|
- if(next.group !== '' && next.group !== null) {
|
|
|
+ if (next.group !== '' && next.group !== null) {
|
|
|
let {groupName, environmentName, defaultDomain, frontType, userDomain, userStatus, region} = next.group;
|
|
|
- this.setState( {
|
|
|
+ this.setState({
|
|
|
groupName,
|
|
|
environmentName,
|
|
|
defaultDomain,
|
|
|
frontType,
|
|
|
userDomain,
|
|
|
userStatus,
|
|
|
- groupRegion: next.region === '' ? region: next.region
|
|
|
+ groupRegion: next.region === '' ? region : next.region
|
|
|
})
|
|
|
} else {
|
|
|
- this.setState ( {
|
|
|
+ this.setState({
|
|
|
groupName: 'graphql_endpoint',
|
|
|
environmentName: 'test',
|
|
|
defaultDomain: '',
|
|
|
@@ -145,11 +148,11 @@ class APIGroupCard extends Component {
|
|
|
updatedAt: new Date().getTime(),
|
|
|
apiGWGroup_id: id
|
|
|
}).then(data => {
|
|
|
- if(data.update_project !== null)
|
|
|
+ if (data.update_project !== null)
|
|
|
this.props.stepByStep(2);
|
|
|
});
|
|
|
}
|
|
|
- setTimeout(()=>{
|
|
|
+ setTimeout(() => {
|
|
|
this.setState({
|
|
|
showOK: false
|
|
|
})
|
|
|
@@ -177,7 +180,7 @@ class APIGroupCard extends Component {
|
|
|
});
|
|
|
this.props.stepByStep(2);
|
|
|
}
|
|
|
- setTimeout(()=>{
|
|
|
+ setTimeout(() => {
|
|
|
this.setState({
|
|
|
showOK: false
|
|
|
})
|
|
|
@@ -197,172 +200,198 @@ class APIGroupCard extends Component {
|
|
|
};
|
|
|
|
|
|
return (
|
|
|
- <div>
|
|
|
- <div style={{marginBottom: 10}}>
|
|
|
- <span className='vice-title'>
|
|
|
- {
|
|
|
- youMustFill['groupName']?
|
|
|
- <span style={{color: 'red', display: 'inline', marginRight: 10}}>*</span>
|
|
|
- :
|
|
|
- ''
|
|
|
- }
|
|
|
- <FormattedMessage id={valueToKey['groupName']}/>
|
|
|
-
|
|
|
- <Tooltip placement="top" title={toolTipTitle['groupName']}>
|
|
|
- <Icon type="question-circle"/>
|
|
|
- </Tooltip>
|
|
|
- </span>
|
|
|
- <Input value={this.state.groupName} style={{width: 400}}
|
|
|
- onChange={this.switchConfig('groupName')}/>
|
|
|
- </div>
|
|
|
+ <Query query={gql(GET_PROJECT)} variables={{id: this.props.projectID}}>
|
|
|
+ {
|
|
|
+ ({loading, error, data}) => {
|
|
|
+ if (loading) {
|
|
|
+ return <Spin style={{marginLeft: 3}}/>
|
|
|
+ }
|
|
|
+ if (error) {
|
|
|
+ return 'error!';
|
|
|
+ }
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ <div style={{marginBottom: 10}}>
|
|
|
+ <span className='vice-title'>
|
|
|
+ {
|
|
|
+ youMustFill['groupName'] ?
|
|
|
+ <span
|
|
|
+ style={{color: 'red', display: 'inline', marginRight: 10}}>*</span>
|
|
|
+ :
|
|
|
+ ''
|
|
|
+ }
|
|
|
+ <FormattedMessage id={valueToKey['groupName']}/>
|
|
|
+
|
|
|
+ <Tooltip placement="top" title={toolTipTitle['groupName']}>
|
|
|
+ <Icon type="question-circle"/>
|
|
|
+ </Tooltip>
|
|
|
+ </span>
|
|
|
+ <Input value={this.state.groupName} style={{width: 400}}
|
|
|
+ onChange={this.switchConfig('groupName')}/>
|
|
|
+ </div>
|
|
|
|
|
|
- <div style={{marginBottom: 10}}>
|
|
|
- <span className='vice-title'>
|
|
|
- {
|
|
|
- youMustFill['region']?
|
|
|
- <span style={{color: 'red', display: 'inline', marginRight: 10}}>*</span>
|
|
|
- :
|
|
|
- ''
|
|
|
- }
|
|
|
- <FormattedMessage id={valueToKey['region']}/>
|
|
|
-
|
|
|
- <Tooltip placement="top" title={toolTipTitle['region']}>
|
|
|
- <Icon type="question-circle"/>
|
|
|
- </Tooltip>
|
|
|
- </span>
|
|
|
- <Radio.Group onChange={(e)=>{
|
|
|
- // 如果不想一变所有都变,就将 onchange 改成
|
|
|
- // onChange={this.switchConfig('groupRegion')}
|
|
|
- this.props.switchRegion(e);
|
|
|
- }} value={removePrefix('ap-', this.state.groupRegion)} buttonStyle="solid">
|
|
|
- <Radio.Button value="guangzhou"><FormattedMessage id="Guangzhou"/></Radio.Button>
|
|
|
- <Radio.Button value="shanghai"><FormattedMessage id="Shanghai"/></Radio.Button>
|
|
|
- <Radio.Button value="beijing"><FormattedMessage id="Beijing"/></Radio.Button>
|
|
|
- <Radio.Button value="chengdu"><FormattedMessage id="Chengdu"/></Radio.Button>
|
|
|
- </Radio.Group>
|
|
|
- </div>
|
|
|
+ <div style={{marginBottom: 10}}>
|
|
|
+ <span className='vice-title'>
|
|
|
+ {
|
|
|
+ youMustFill['region'] ?
|
|
|
+ <span
|
|
|
+ style={{color: 'red', display: 'inline', marginRight: 10}}>*</span>
|
|
|
+ :
|
|
|
+ ''
|
|
|
+ }
|
|
|
+ <FormattedMessage id={valueToKey['region']}/>
|
|
|
+
|
|
|
+ <Tooltip placement="top" title={toolTipTitle['region']}>
|
|
|
+ <Icon type="question-circle"/>
|
|
|
+ </Tooltip>
|
|
|
+ </span>
|
|
|
+ <Radio.Group onChange={(e) => {
|
|
|
+ // 如果不想一变所有都变,就将 onchange 改成
|
|
|
+ // onChange={this.switchConfig('groupRegion')}
|
|
|
+ this.props.switchRegion(e);
|
|
|
+ }} value={removePrefix('ap-', this.state.groupRegion)} buttonStyle="solid">
|
|
|
+ <Radio.Button value="guangzhou"><FormattedMessage id="Guangzhou"/></Radio.Button>
|
|
|
+ <Radio.Button value="shanghai"><FormattedMessage id="Shanghai"/></Radio.Button>
|
|
|
+ <Radio.Button value="beijing"><FormattedMessage id="Beijing"/></Radio.Button>
|
|
|
+ <Radio.Button value="chengdu"><FormattedMessage id="Chengdu"/></Radio.Button>
|
|
|
+ </Radio.Group>
|
|
|
+ </div>
|
|
|
|
|
|
- <div style={{marginBottom: 10}}>
|
|
|
- <span className='vice-title'>
|
|
|
- {
|
|
|
- youMustFill['environmentName']?
|
|
|
- <span style={{color: 'red', display: 'inline', marginRight: 10}}>*</span>
|
|
|
- :
|
|
|
- ''
|
|
|
- }
|
|
|
- <FormattedMessage id={valueToKey['environmentName']}/>
|
|
|
-
|
|
|
- <Tooltip placement="top" title={toolTipTitle['environmentName']}>
|
|
|
- <Icon type="question-circle"/>
|
|
|
- </Tooltip>
|
|
|
- </span>
|
|
|
- <Radio.Group onChange={this.switchConfig('environmentName')} defaultValue={this.state.environmentName}
|
|
|
- buttonStyle="solid">
|
|
|
- <Radio.Button value="test"><FormattedMessage id="test"/></Radio.Button>
|
|
|
- <Radio.Button value="prepub"><FormattedMessage id="prepub"/></Radio.Button>
|
|
|
- <Radio.Button value="release"><FormattedMessage id="release"/></Radio.Button>
|
|
|
- </Radio.Group>
|
|
|
- </div>
|
|
|
- <Collapse bordered={false}>
|
|
|
- <Panel header=<FormattedMessage id="Want more options?"/> style={customPanelStyle}>
|
|
|
+ <div style={{marginBottom: 10}}>
|
|
|
+ <span className='vice-title'>
|
|
|
+ {
|
|
|
+ youMustFill['environmentName'] ?
|
|
|
+ <span
|
|
|
+ style={{color: 'red', display: 'inline', marginRight: 10}}>*</span>
|
|
|
+ :
|
|
|
+ ''
|
|
|
+ }
|
|
|
+ <FormattedMessage id={valueToKey['environmentName']}/>
|
|
|
+
|
|
|
+ <Tooltip placement="top" title={toolTipTitle['environmentName']}>
|
|
|
+ <Icon type="question-circle"/>
|
|
|
+ </Tooltip>
|
|
|
+ </span>
|
|
|
+ <Radio.Group onChange={this.switchConfig('environmentName')}
|
|
|
+ defaultValue={this.state.environmentName}
|
|
|
+ buttonStyle="solid">
|
|
|
+ <Radio.Button value="test"><FormattedMessage id="test"/></Radio.Button>
|
|
|
+ <Radio.Button value="prepub"><FormattedMessage id="prepub"/></Radio.Button>
|
|
|
+ <Radio.Button value="release"><FormattedMessage id="release"/></Radio.Button>
|
|
|
+ </Radio.Group>
|
|
|
+ </div>
|
|
|
+ <Collapse bordered={false}>
|
|
|
+ <Panel header={<FormattedMessage id="Want more options?"/>}
|
|
|
+ style={customPanelStyle}>
|
|
|
|
|
|
- <div style={{marginBottom: 10}}>
|
|
|
- <span className='vice-title'>
|
|
|
- {
|
|
|
- youMustFill['frontType']?
|
|
|
- <span style={{color: 'red', display: 'inline', marginRight: 10}}>*</span>
|
|
|
- :
|
|
|
- ''
|
|
|
- }
|
|
|
- <FormattedMessage id={valueToKey['frontType']}/>
|
|
|
-
|
|
|
- <Tooltip placement="top" title={toolTipTitle['frontType']}>
|
|
|
- <Icon type="question-circle"/>
|
|
|
- </Tooltip>
|
|
|
- </span>
|
|
|
- <Radio.Group onChange={this.switchConfig('frontType')} defaultValue={this.state.frontType}
|
|
|
- buttonStyle="solid">
|
|
|
- <Radio.Button value="http">http</Radio.Button>
|
|
|
- <Radio.Button value="https">https</Radio.Button>
|
|
|
- <Radio.Button value="http&https">http&https</Radio.Button>
|
|
|
- </Radio.Group>
|
|
|
- </div>
|
|
|
- {/*<div style={{marginBottom: 10}}>*/}
|
|
|
- {/*<span className='vice-title'>{valueToKey['defaultDomain']}*/}
|
|
|
- {/* */}
|
|
|
- {/*<Tooltip placement="top" title={toolTipTitle['defaultDomain']}>*/}
|
|
|
- {/*<Icon type="question-circle"/>*/}
|
|
|
- {/*</Tooltip>*/}
|
|
|
- {/*</span>*/}
|
|
|
- {/*<Input value={this.state.defaultDomain} style={{width: 400}} disabled/>*/}
|
|
|
- {/*</div>*/}
|
|
|
+ <div style={{marginBottom: 10}}>
|
|
|
+ <span className='vice-title'>
|
|
|
+ {
|
|
|
+ youMustFill['frontType'] ?
|
|
|
+ <span style={{
|
|
|
+ color: 'red',
|
|
|
+ display: 'inline',
|
|
|
+ marginRight: 10
|
|
|
+ }}>*</span>
|
|
|
+ :
|
|
|
+ ''
|
|
|
+ }
|
|
|
+ <FormattedMessage id={valueToKey['frontType']}/>
|
|
|
+
|
|
|
+ <Tooltip placement="top" title={toolTipTitle['frontType']}>
|
|
|
+ <Icon type="question-circle"/>
|
|
|
+ </Tooltip>
|
|
|
+ </span>
|
|
|
+ <Radio.Group onChange={this.switchConfig('frontType')}
|
|
|
+ defaultValue={this.state.frontType}
|
|
|
+ buttonStyle="solid">
|
|
|
+ <Radio.Button value="http">http</Radio.Button>
|
|
|
+ <Radio.Button value="https">https</Radio.Button>
|
|
|
+ <Radio.Button value="http&https">http&https</Radio.Button>
|
|
|
+ </Radio.Group>
|
|
|
+ </div>
|
|
|
+ {/*<div style={{marginBottom: 10}}>*/}
|
|
|
+ {/*<span className='vice-title'>{valueToKey['defaultDomain']}*/}
|
|
|
+ {/* */}
|
|
|
+ {/*<Tooltip placement="top" title={toolTipTitle['defaultDomain']}>*/}
|
|
|
+ {/*<Icon type="question-circle"/>*/}
|
|
|
+ {/*</Tooltip>*/}
|
|
|
+ {/*</span>*/}
|
|
|
+ {/*<Input value={this.state.defaultDomain} style={{width: 400}} disabled/>*/}
|
|
|
+ {/*</div>*/}
|
|
|
|
|
|
- <div style={{marginBottom: 10}}>
|
|
|
- <span className='vice-title'>
|
|
|
- {
|
|
|
- youMustFill['userDomain']?
|
|
|
- <span style={{color: 'red', display: 'inline', marginRight: 10}}>*</span>
|
|
|
- :
|
|
|
- ''
|
|
|
- }
|
|
|
- <FormattedMessage id={valueToKey['userDomain']}/>
|
|
|
-
|
|
|
- <Tooltip placement="top" title={toolTipTitle['userDomain']}>
|
|
|
- <Icon type="question-circle"/>
|
|
|
- </Tooltip>
|
|
|
- </span>
|
|
|
- <Input value={this.state.userDomain} style={{width: 400}}
|
|
|
- onChange={this.switchConfig('userDomain')}/>
|
|
|
- </div>
|
|
|
- {/*<div style={{marginBottom: 10}}>*/}
|
|
|
- {/*<span className='vice-title'>{valueToKey['userStatus']}*/}
|
|
|
- {/* */}
|
|
|
- {/*<Tooltip placement="top" title={toolTipTitle['userStatus']}>*/}
|
|
|
- {/*<Icon type="question-circle"/>*/}
|
|
|
- {/*</Tooltip>*/}
|
|
|
- {/*</span>*/}
|
|
|
- {/*<Radio.Group onChange={this.switchConfig('userStatus')} defaultValue={this.state.userStatus}*/}
|
|
|
- {/*buttonStyle="solid">*/}
|
|
|
- {/*<Radio.Button value="open">open</Radio.Button>*/}
|
|
|
- {/*<Radio.Button value="close">close</Radio.Button>*/}
|
|
|
- {/*</Radio.Group>*/}
|
|
|
- {/*</div>*/}
|
|
|
- </Panel>
|
|
|
- </Collapse>
|
|
|
- {
|
|
|
- manageUsers.includes(this.props.userID)?
|
|
|
- <div>
|
|
|
- <Button onClick={()=>{
|
|
|
- const id = idGen('group');
|
|
|
- this.ok(id);
|
|
|
- this.props.pass(id, 'group');
|
|
|
- }} type='primary'><FormattedMessage id="save"/></Button>
|
|
|
- {
|
|
|
- this.state.showOK === true?
|
|
|
- <Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/>
|
|
|
- :
|
|
|
- ''
|
|
|
- }
|
|
|
- </div>
|
|
|
- :
|
|
|
- this.props.trialcase?
|
|
|
- ''
|
|
|
- :
|
|
|
- <div>
|
|
|
- <Button onClick={()=>{
|
|
|
- const id = idGen('group');
|
|
|
- this.ok(id);
|
|
|
- this.props.pass(id, 'group');
|
|
|
- }} type='primary'><FormattedMessage id="save"/></Button>
|
|
|
+ <div style={{marginBottom: 10}}>
|
|
|
+ <span className='vice-title'>
|
|
|
+ {
|
|
|
+ youMustFill['userDomain'] ?
|
|
|
+ <span style={{color: 'red', display: 'inline', marginRight: 10}}>*</span>
|
|
|
+ :
|
|
|
+ ''
|
|
|
+ }
|
|
|
+ <FormattedMessage id={valueToKey['userDomain']}/>
|
|
|
+
|
|
|
+ <Tooltip placement="top" title={toolTipTitle['userDomain']}>
|
|
|
+ <Icon type="question-circle"/>
|
|
|
+ </Tooltip>
|
|
|
+ </span>
|
|
|
+ <Input value={this.state.userDomain} style={{width: 400}}
|
|
|
+ onChange={this.switchConfig('userDomain')}/>
|
|
|
+ </div>
|
|
|
+ {/*<div style={{marginBottom: 10}}>*/}
|
|
|
+ {/*<span className='vice-title'>{valueToKey['userStatus']}*/}
|
|
|
+ {/* */}
|
|
|
+ {/*<Tooltip placement="top" title={toolTipTitle['userStatus']}>*/}
|
|
|
+ {/*<Icon type="question-circle"/>*/}
|
|
|
+ {/*</Tooltip>*/}
|
|
|
+ {/*</span>*/}
|
|
|
+ {/*<Radio.Group onChange={this.switchConfig('userStatus')} defaultValue={this.state.userStatus}*/}
|
|
|
+ {/*buttonStyle="solid">*/}
|
|
|
+ {/*<Radio.Button value="open">open</Radio.Button>*/}
|
|
|
+ {/*<Radio.Button value="close">close</Radio.Button>*/}
|
|
|
+ {/*</Radio.Group>*/}
|
|
|
+ {/*</div>*/}
|
|
|
+ </Panel>
|
|
|
+ </Collapse>
|
|
|
{
|
|
|
- this.state.showOK === true?
|
|
|
- <Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/>
|
|
|
+ manageUsers.includes(this.props.userID) ?
|
|
|
+ <div>
|
|
|
+ <Button onClick={() => {
|
|
|
+ const id = idGen('group');
|
|
|
+ this.ok(id);
|
|
|
+ this.props.pass(id, 'group');
|
|
|
+ }} type='primary'><FormattedMessage id="save"/></Button>
|
|
|
+ {
|
|
|
+ this.state.showOK === true ?
|
|
|
+ <Icon type="check-circle" theme="twoTone" twoToneColor="#52c41a"/>
|
|
|
+ :
|
|
|
+ ''
|
|
|
+ }
|
|
|
+ </div>
|
|
|
:
|
|
|
- ''
|
|
|
+ this.props.trialcase ?
|
|
|
+ ''
|
|
|
+ :
|
|
|
+ <div>
|
|
|
+ <Button onClick={() => {
|
|
|
+ const id = idGen('group');
|
|
|
+ this.ok(id);
|
|
|
+ this.props.pass(id, 'group');
|
|
|
+ }} type='primary'><FormattedMessage id="save"/></Button>
|
|
|
+ {
|
|
|
+ this.state.showOK === true ?
|
|
|
+ <Icon type="check-circle" theme="twoTone"
|
|
|
+ twoToneColor="#52c41a"/>
|
|
|
+ :
|
|
|
+ ''
|
|
|
+ }
|
|
|
+ </div>
|
|
|
}
|
|
|
</div>
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
- </div>
|
|
|
+ </Query>
|
|
|
+
|
|
|
)
|
|
|
}
|
|
|
}
|