DeployCardFetch.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 DeployCardRender from "./DeployCardRender";
  7. import {removeSpace} from "../../../../../../func";
  8. const removePrefix = (prefix, value) => {
  9. let r = new RegExp(prefix);
  10. return value.replace(r, '');
  11. };
  12. const shiftPrefix = (prefix, value) => {
  13. value = removePrefix(prefix, value);
  14. return prefix + value;
  15. };
  16. class DeployCardFetch extends Component {
  17. constructor(props) {
  18. super(props);
  19. this.state = {
  20. }
  21. }
  22. render() {
  23. return (
  24. <Query query={gql(GET_PROJECT)} variables={{id: this.props.projectID}}>
  25. {
  26. ({loading, error, data}) => {
  27. if (loading) {
  28. return <Spin style={{marginLeft: 3}}/>
  29. }
  30. if (error) {
  31. return 'error!';
  32. }
  33. let deploy = '',
  34. cloudID = 'tencent_CloudID';
  35. let dataProject = data.project_by_id;
  36. let {cloud_id, deploy_id, projectName, projectStatus} = dataProject;
  37. if (cloud_id !== null && cloud_id.cloudName === 'tencent') {
  38. deploy = deploy_id;
  39. cloudID = cloud_id.id;
  40. }
  41. return (
  42. <DeployCardRender
  43. // props
  44. switchRegion={this.props.switchRegion}
  45. region={this.props.region}
  46. trialcase={this.props.trialcase}
  47. stepByStep={this.props.stepByStep}
  48. userID={this.props.userID}
  49. projectID={this.props.projectID}
  50. // query
  51. defalutName={removeSpace(projectName)}
  52. deploy={deploy}
  53. cloudID={cloudID}
  54. projectStatus={projectStatus}
  55. />
  56. )
  57. }
  58. }
  59. </Query>
  60. )
  61. }
  62. }
  63. export default DeployCardFetch;