|
@@ -1,123 +0,0 @@
|
|
|
-import React, {Component} from 'react';
|
|
|
|
|
-
|
|
|
|
|
-import {Input, Select, Button, Row, Col, Spin} from 'antd';
|
|
|
|
|
-import TencentAPIPath from './TencentAPIPath';
|
|
|
|
|
-import {SHOW_APIGWPATH} from "../../../gql";
|
|
|
|
|
-import {Mutation, Query} from "react-apollo";
|
|
|
|
|
-
|
|
|
|
|
-const Option = Select.Option;
|
|
|
|
|
-
|
|
|
|
|
-class TencentAPIGroup extends Component {
|
|
|
|
|
- constructor(props) {
|
|
|
|
|
- super(props);
|
|
|
|
|
- this.state = {
|
|
|
|
|
- configs: ['groupName', 'region', 'frontType', 'defaultDomain', 'userDomain', 'userStatus'],
|
|
|
|
|
- id: props.apiGroup.id,
|
|
|
|
|
- groupName: props.apiGroup.groupName,
|
|
|
|
|
- region: props.apiGroup.region,
|
|
|
|
|
- frontType: props.apiGroup.frontType,
|
|
|
|
|
- defaultDomain: props.apiGroup.defaultDomain,
|
|
|
|
|
- userDomain: props.apiGroup.userDomain,
|
|
|
|
|
- userStatus: props.apiGroup.userStatus,
|
|
|
|
|
- show: 'all',
|
|
|
|
|
- apiPath: ''
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- findAPIPath = (id, data) => {
|
|
|
|
|
- return () => {
|
|
|
|
|
- this.setState({
|
|
|
|
|
- show: 'apiPath',
|
|
|
|
|
- apiPath: data.apiGWPath_by_props.find(apiPath => apiPath.id === id)
|
|
|
|
|
- })
|
|
|
|
|
- };
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- reDisplayChoosePath = () => {
|
|
|
|
|
- this.setState({
|
|
|
|
|
- show: 'all'
|
|
|
|
|
- })
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- switchConfig = (label) => {
|
|
|
|
|
- return (e) => {
|
|
|
|
|
- this.setState({
|
|
|
|
|
- [label]: e.target.value
|
|
|
|
|
- })
|
|
|
|
|
- };
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- componentWillReceiveProps(next) {
|
|
|
|
|
- this.setState({
|
|
|
|
|
- id: next.apiGroup.id,
|
|
|
|
|
- groupName: next.apiGroup.groupName,
|
|
|
|
|
- region: next.apiGroup.region,
|
|
|
|
|
- frontType: next.apiGroup.frontType,
|
|
|
|
|
- defaultDomain: next.apiGroup.defaultDomain,
|
|
|
|
|
- userDomain: next.apiGroup.userDomain,
|
|
|
|
|
- userStatus: next.apiGroup.userStatus,
|
|
|
|
|
- });
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- render() {
|
|
|
|
|
- return (
|
|
|
|
|
- <div style={{margin: 20}}>
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- <div onClick={this.props.reDisplayChoose} style={{marginBottom: 30}}> back to choose</div>
|
|
|
|
|
- <div>
|
|
|
|
|
- <span className='table-title'> API Group Config</span>
|
|
|
|
|
- {
|
|
|
|
|
- this.state.configs.map(config => (
|
|
|
|
|
- <div key={config} style={{marginBottom: 10}}>
|
|
|
|
|
- <span className='vice-title'>{config}: </span>
|
|
|
|
|
- <Input value={this.state[config]} style={{width: 200}}
|
|
|
|
|
- onChange={this.switchConfig(config)}/>
|
|
|
|
|
- </div>
|
|
|
|
|
- ))
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <div>
|
|
|
|
|
- <span className='table-title'> API Path Config</span>
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- this.state.show === 'all'?
|
|
|
|
|
- <Query query={SHOW_APIGWPATH} variables={{apiGWGroup_id: this.state.id}}>
|
|
|
|
|
- {
|
|
|
|
|
- ({loading, error, data}) => {
|
|
|
|
|
- if (loading) {
|
|
|
|
|
- return <Spin style={{marginLeft: 3}}/>
|
|
|
|
|
- }
|
|
|
|
|
- if (error) {
|
|
|
|
|
- return 'error!';
|
|
|
|
|
- }
|
|
|
|
|
- return (
|
|
|
|
|
- data.apiGWPath_by_props.map(apiPath => (
|
|
|
|
|
- <div key={apiPath.id}>
|
|
|
|
|
- <div>
|
|
|
|
|
- {apiPath.id} - {apiPath.apiGWName}
|
|
|
|
|
- <Button size="small"
|
|
|
|
|
- onClick={this.findAPIPath(apiPath.id, data)}
|
|
|
|
|
- type='primary'>Show
|
|
|
|
|
- me</Button>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- ))
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- </Query>
|
|
|
|
|
- :
|
|
|
|
|
- <TencentAPIPath apiPath={this.state.apiPath} reDisplayChoosePath={this.reDisplayChoosePath}/>
|
|
|
|
|
- }
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- </div>
|
|
|
|
|
- )
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-export default TencentAPIGroup;
|
|
|