|
@@ -1,10 +1,22 @@
|
|
|
import React, {Component} from 'react';
|
|
import React, {Component} from 'react';
|
|
|
import {FormattedMessage} from 'react-intl';
|
|
import {FormattedMessage} from 'react-intl';
|
|
|
import {Switch, Input, Icon, Spin, Row, Col, message} from 'antd';
|
|
import {Switch, Input, Icon, Spin, Row, Col, message} from 'antd';
|
|
|
-import {GET_PROJECT, SHOW_APIGWPATH, UPDATE_APIGROUP} from "../../../gql";
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ DELETE_APIGWPATH,
|
|
|
|
|
+ DELETE_APIGROUP,
|
|
|
|
|
+ GET_PROJECT,
|
|
|
|
|
+ SHOW_APIGWPATH,
|
|
|
|
|
+ UPDATE_APIGROUP,
|
|
|
|
|
+ UPDATE_PROJECT_ONLY_STATUS
|
|
|
|
|
+} from "../../../gql";
|
|
|
|
|
+import {request} from 'graphql-request'
|
|
|
import gql from "graphql-tag";
|
|
import gql from "graphql-tag";
|
|
|
import {Query, Mutation} from "react-apollo";
|
|
import {Query, Mutation} from "react-apollo";
|
|
|
import copy from 'copy-to-clipboard';
|
|
import copy from 'copy-to-clipboard';
|
|
|
|
|
+import axios from 'axios';
|
|
|
|
|
+import {removeAPI, graphqlUrl} from "../../../config";
|
|
|
|
|
+
|
|
|
|
|
+axios.defaults.withCredentials = true;
|
|
|
|
|
|
|
|
class TencentResult extends Component {
|
|
class TencentResult extends Component {
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
@@ -13,7 +25,7 @@ class TencentResult extends Component {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
- let projectID = this.props.projectID ? this.props.projectID : 'ecommerce_projectID';
|
|
|
|
|
|
|
+ let projectID = this.props.projectID ? this.props.projectID : this.props.kind === 'graphql' ? 'ecommerce_projectID' : 'ecommerce_projectID_wx';
|
|
|
return (
|
|
return (
|
|
|
<Query query={gql(GET_PROJECT)} variables={{id: projectID}} fetchPolicy={'network-only'}>
|
|
<Query query={gql(GET_PROJECT)} variables={{id: projectID}} fetchPolicy={'network-only'}>
|
|
|
{
|
|
{
|
|
@@ -26,10 +38,12 @@ class TencentResult extends Component {
|
|
|
}
|
|
}
|
|
|
let group = data.project_by_id.apiGWGroup_id || {};
|
|
let group = data.project_by_id.apiGWGroup_id || {};
|
|
|
let projectType = data.project_by_id.projectType || 'graphql';
|
|
let projectType = data.project_by_id.projectType || 'graphql';
|
|
|
|
|
+ let projectStatus = data.project_by_id.projectStatus || 'created';
|
|
|
|
|
+ let cloudID = data.project_by_id.cloud_id || 'tencent_CloudID';
|
|
|
return (
|
|
return (
|
|
|
<div>
|
|
<div>
|
|
|
{
|
|
{
|
|
|
- Object.keys(group).length !== 0 ?
|
|
|
|
|
|
|
+ projectStatus === 'deployed'?
|
|
|
<div>
|
|
<div>
|
|
|
<div className={'schema-name'}><FormattedMessage id='service manage'/></div>
|
|
<div className={'schema-name'}><FormattedMessage id='service manage'/></div>
|
|
|
<div className={'schema-table-list-title'}>
|
|
<div className={'schema-table-list-title'}>
|
|
@@ -67,7 +81,18 @@ class TencentResult extends Component {
|
|
|
:
|
|
:
|
|
|
<SwitchStatus group={group}/>
|
|
<SwitchStatus group={group}/>
|
|
|
}
|
|
}
|
|
|
- {/*<span className={'schema-table-content name'}>删除</span>*/}
|
|
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ this.props.trialcase ?
|
|
|
|
|
+ ''
|
|
|
|
|
+ :
|
|
|
|
|
+ <DeleteGroupSpan
|
|
|
|
|
+ cloudID={cloudID}
|
|
|
|
|
+ groupID={group.id}
|
|
|
|
|
+ projectID={projectID}
|
|
|
|
|
+ userID={this.props.userID}
|
|
|
|
|
+ />
|
|
|
|
|
+ }
|
|
|
</span>
|
|
</span>
|
|
|
</Col>
|
|
</Col>
|
|
|
</Row>
|
|
</Row>
|
|
@@ -78,11 +103,18 @@ class TencentResult extends Component {
|
|
|
group={group}
|
|
group={group}
|
|
|
projectType={projectType}
|
|
projectType={projectType}
|
|
|
switchMenu={this.props.switchMenu}
|
|
switchMenu={this.props.switchMenu}
|
|
|
|
|
+ cloudID={cloudID}
|
|
|
|
|
+ projectID={projectID}
|
|
|
|
|
+ userID={this.props.userID}
|
|
|
|
|
+ trialcase={this.props.trialcase}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
:
|
|
:
|
|
|
- <FormattedMessage id='No deploy'/>
|
|
|
|
|
|
|
+ projectStatus === 'updated'?
|
|
|
|
|
+ <FormattedMessage id='deploy updated'/>
|
|
|
|
|
+ :
|
|
|
|
|
+ <FormattedMessage id='No deploy'/>
|
|
|
}
|
|
}
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|
|
@@ -159,7 +191,7 @@ class APIGWPathResult extends Component {
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
let {group, projectType} = this.props;
|
|
let {group, projectType} = this.props;
|
|
|
- let {id, frontType, defaultDomain, environmentName} = group;
|
|
|
|
|
|
|
+ let {id} = group;
|
|
|
return (
|
|
return (
|
|
|
<Query query={gql(SHOW_APIGWPATH)} variables={{apiGWGroup_id: id}} fetchPolicy={'network-only'}>
|
|
<Query query={gql(SHOW_APIGWPATH)} variables={{apiGWGroup_id: id}} fetchPolicy={'network-only'}>
|
|
|
{
|
|
{
|
|
@@ -202,8 +234,6 @@ class APIGWPathResult extends Component {
|
|
|
<span className={'schema-table-content'}>{path.apiGWDesc}</span>
|
|
<span className={'schema-table-content'}>{path.apiGWDesc}</span>
|
|
|
</Col>
|
|
</Col>
|
|
|
<Col span={3}>
|
|
<Col span={3}>
|
|
|
- {/*<span className={'schema-table-content name'}>删除</span>*/}
|
|
|
|
|
- {/* */}
|
|
|
|
|
{
|
|
{
|
|
|
projectType === 'graphql'?
|
|
projectType === 'graphql'?
|
|
|
<span className={'schema-table-content name'}
|
|
<span className={'schema-table-content name'}
|
|
@@ -215,6 +245,19 @@ class APIGWPathResult extends Component {
|
|
|
:
|
|
:
|
|
|
''
|
|
''
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ this.props.trialcase?
|
|
|
|
|
+ ''
|
|
|
|
|
+ :
|
|
|
|
|
+ <DeletePathSpan
|
|
|
|
|
+ cloudID={this.props.cloudID}
|
|
|
|
|
+ groupID={id}
|
|
|
|
|
+ path={path}
|
|
|
|
|
+ projectID={this.props.projectID}
|
|
|
|
|
+ userID={this.props.userID}
|
|
|
|
|
+ />
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
</Col>
|
|
</Col>
|
|
|
</Row>
|
|
</Row>
|
|
@@ -234,3 +277,127 @@ class APIGWPathResult extends Component {
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+class DeletePathSpan extends Component {
|
|
|
|
|
+ constructor(props) {
|
|
|
|
|
+ super(props);
|
|
|
|
|
+ this.state = {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ render() {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Mutation
|
|
|
|
|
+ mutation={gql(DELETE_APIGWPATH)}
|
|
|
|
|
+ refetchQueries={[{query: gql(SHOW_APIGWPATH), variables: {apiGWGroup_id: this.props.groupID}}]}
|
|
|
|
|
+ >
|
|
|
|
|
+ {(delete_apiGWPath, {loading, error}) => {
|
|
|
|
|
+ if (error)
|
|
|
|
|
+ return 'error';
|
|
|
|
|
+ if (loading)
|
|
|
|
|
+ return <Spin style={{marginLeft: 3}}/>;
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <span className={'schema-table-content name'} onClick={() => {
|
|
|
|
|
+ let _this = this;
|
|
|
|
|
+ axios.get(`${removeAPI}`, {
|
|
|
|
|
+ params: {
|
|
|
|
|
+ 'cloud-id': `${_this.props.cloudID}`,
|
|
|
|
|
+ 'group-id': `${_this.props.groupID}`,
|
|
|
|
|
+ 'api-id': `${_this.props.path.id}`
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ console.log('delete api');
|
|
|
|
|
+ if (res.data !== '') {
|
|
|
|
|
+
|
|
|
|
|
+ console.log('path id', _this.props.path.id, 'user id', _this.props.userID);
|
|
|
|
|
+
|
|
|
|
|
+ delete_apiGWPath({variables: {id:_this.props.path.id, user_id: _this.props.userID}});
|
|
|
|
|
+
|
|
|
|
|
+ // 写回 project 状态
|
|
|
|
|
+ request(graphqlUrl, UPDATE_PROJECT_ONLY_STATUS, {
|
|
|
|
|
+ id: this.props.projectID,
|
|
|
|
|
+ updatedAt: new Date().getTime(),
|
|
|
|
|
+ projectStatus: 'grouped'
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ console.log(res.data);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log('error');
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ console.log(err);
|
|
|
|
|
+ });
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ 删除
|
|
|
|
|
+ </span>
|
|
|
|
|
+ )
|
|
|
|
|
+ }}
|
|
|
|
|
+ </Mutation>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+class DeleteGroupSpan extends Component {
|
|
|
|
|
+ constructor(props) {
|
|
|
|
|
+ super(props);
|
|
|
|
|
+ this.state = {
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ render() {
|
|
|
|
|
+ let {projectID, cloudID, groupID, userID} = this.props;
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Mutation
|
|
|
|
|
+ mutation={gql(DELETE_APIGROUP)}
|
|
|
|
|
+ refetchQueries={[{query: gql(GET_PROJECT), variables: {id: projectID}}]}
|
|
|
|
|
+ >
|
|
|
|
|
+ {(delete_apiGWGroup, {loading, error}) => {
|
|
|
|
|
+ if (error)
|
|
|
|
|
+ return 'error';
|
|
|
|
|
+ if (loading)
|
|
|
|
|
+ return <Spin style={{marginLeft: 3}}/>;
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <span className={'schema-table-content name'} onClick={() => {
|
|
|
|
|
+ axios.get(`${removeAPI}`, {
|
|
|
|
|
+ params: {
|
|
|
|
|
+ 'cloud-id': `${cloudID}`,
|
|
|
|
|
+ 'group-id': `${groupID}`,
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ console.log('delete service');
|
|
|
|
|
+ if (res.data !== '') {
|
|
|
|
|
+
|
|
|
|
|
+ delete_apiGWGroup({variables: {id: groupID, user_id: userID}});
|
|
|
|
|
+
|
|
|
|
|
+ // 写回 project 状态
|
|
|
|
|
+ request(graphqlUrl, UPDATE_PROJECT_ONLY_STATUS, {
|
|
|
|
|
+ id: projectID,
|
|
|
|
|
+ updatedAt: new Date().getTime(),
|
|
|
|
|
+ projectStatus: 'functioned'
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ console.log(res.data);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log('error');
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ console.log(err);
|
|
|
|
|
+ });
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ 删除
|
|
|
|
|
+ </span>
|
|
|
|
|
+ )
|
|
|
|
|
+ }}
|
|
|
|
|
+ </Mutation>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+}
|