UserCreate.jsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import React, {Component} from 'react';
  2. import {Layout, Menu} from 'antd';
  3. import GenerateJs from "./component/generateJs/GenerateJs";
  4. import Deploy from '../common/deploy/Deploy';
  5. import Schema from './component/schema/Schema';
  6. import Graphql from "./component/graphql/Graphql";
  7. import CaseMetabase from "./component/caseMetabase/CaseMetabase";
  8. import axios from 'axios';
  9. import {getIdUrl} from "../../config";
  10. import {FormattedMessage} from 'react-intl';
  11. axios.defaults.withCredentials = true;
  12. const {Content} = Layout;
  13. class UserCreate extends Component {
  14. constructor(props) {
  15. super(props);
  16. this.state = {
  17. menuLevel2: "schema",
  18. userID: "",
  19. }
  20. }
  21. componentWillMount() {
  22. let _this = this;
  23. axios.get(getIdUrl)
  24. .then((res) => {
  25. if (res.data !== '') {
  26. _this.setState({
  27. userID: res.data
  28. })
  29. }
  30. })
  31. .catch(function (err) {
  32. console.log(err);
  33. });
  34. }
  35. switchMenu = (menuName, e) => {
  36. this.setState({
  37. [menuName]: e.key,
  38. });
  39. };
  40. render() {
  41. let schemaID = this.props.history.location.state ? this.props.history.location.state.schemaID : "ecommerce_schemaID";
  42. let schemaName = this.props.history.location.state ? this.props.history.location.state.schemaName : "ecommerce";
  43. return (
  44. <div>
  45. <Menu
  46. mode="horizontal"
  47. defaultSelectedKeys={['schema']}
  48. style={{padding: '0 24px', position: 'fixed', width: '100%', zIndex: '5',lineHeight:'50px',fontWeight:600}}
  49. onClick={(e) => this.switchMenu('menuLevel2', e)}
  50. selectedKeys={[this.state.menuLevel2]}
  51. >
  52. <Menu.Item key="schema"><FormattedMessage id="schema"/></Menu.Item>
  53. <Menu.Item key="deploy"><FormattedMessage id="deploy"/></Menu.Item>
  54. <Menu.Item key="graphiql"><FormattedMessage id="graphql IDE"/></Menu.Item>
  55. <Menu.Item key="template"><FormattedMessage id="template"/></Menu.Item>
  56. <Menu.Item key="metabase"><FormattedMessage id="metabase"/></Menu.Item>
  57. </Menu>
  58. <Layout style={{padding: '24px', zIndex: '0'}}>
  59. <Content style={{padding: '24px', minHeight: 280, background: '#fff', marginTop: '48px'}}>
  60. {
  61. (() => {
  62. switch (this.state.menuLevel2) {
  63. case 'schema':
  64. return <Schema trialcase={false} userID={this.state.userID} schemaName={schemaName} schemaID={schemaID} history={this.props.history} location={this.props.location}/>;
  65. case 'deploy':
  66. return <Deploy trialcase={false} userID={this.state.userID} schemaID={schemaID}/>;
  67. case 'graphiql':
  68. return <Graphql/>;
  69. case 'template':
  70. return <GenerateJs/>;
  71. case 'metabase':
  72. return <CaseMetabase/>;
  73. default:
  74. return <Graphql/>;
  75. }
  76. })()
  77. }
  78. </Content>
  79. </Layout>
  80. </div>
  81. )
  82. }
  83. }
  84. export default UserCreate;