TrialCase.jsx 3.4 KB

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