APIGroupCardFetch.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import React, {Component} from 'react';
  2. import {Spin} from 'antd';
  3. import {GET_PROJECT} from "../../../../../gql";
  4. import {Query} from "react-apollo";
  5. import gql from "graphql-tag";
  6. import APIGroupCardRender from "./APIGroupCardRender";
  7. import {removeSpace} from "../../../../../func";
  8. class APIGroupCardFetch extends Component {
  9. constructor(props) {
  10. super(props);
  11. this.state = {
  12. }
  13. }
  14. render() {
  15. return (
  16. <Query query={gql(GET_PROJECT)} variables={{id: this.props.projectID}}>
  17. {
  18. ({loading, error, data}) => {
  19. if (loading) {
  20. return <Spin style={{marginLeft: 3}}/>
  21. }
  22. if (error) {
  23. return 'error!';
  24. }
  25. let group = '',
  26. cloudID = 'tencent_CloudID';
  27. let dataProject = data.project_by_id;
  28. let {cloud_id, apiGWGroup_id, projectName} = dataProject;
  29. if (cloud_id !== null && cloud_id.cloudName === 'tencent') {
  30. group = apiGWGroup_id;
  31. cloudID = cloud_id.id;
  32. }
  33. return (
  34. <APIGroupCardRender
  35. // props
  36. switchRegion={this.props.switchRegion}
  37. region={this.props.region}
  38. trialcase={this.props.trialcase}
  39. pass={this.props.pass}
  40. stepByStep={this.props.stepByStep}
  41. userID={this.props.userID}
  42. projectID={this.props.projectID}
  43. // this
  44. switchConfig={this.switchConfig}
  45. ok={this.ok}
  46. // query
  47. defalutName={removeSpace(projectName)}
  48. group={group}
  49. cloudID={cloudID}
  50. />
  51. )
  52. }
  53. }
  54. </Query>
  55. )
  56. }
  57. }
  58. export default APIGroupCardFetch;