Jelajahi Sumber

add table confirm modal

Csy817 7 tahun lalu
induk
melakukan
077e9f3b2a

+ 11 - 2
src/components/app/App.jsx

@@ -74,6 +74,15 @@ class App extends Component {
         });
     };
 
+    switchMenuTab = (menuName, e) => {
+        this.setState({
+            [menuName]: e.key,
+        });
+        if(e.key === "graphql-service"){
+            this.setState({sideBar: "ecommerce"});
+        }
+    };
+
     switchSidebar = (value) => {
         this.setState({
             sideBar:value,
@@ -127,7 +136,7 @@ class App extends Component {
             <Router>
                 <Layout style={{minHeight: '100vh'}}>
                     <Header className="header" style={{position: 'fixed', zIndex: 1, width: '100%'}}>
-                        <Link to="/"   onClick={() => this.switchMenuLevel('menuLevel1', "graphql-service")}>
+                        <Link to="/"   onClick={() => this.setState({menuLevel1:"graphql-service",sideBar:"ecommerce"})}>
                             <div className="logo-wrapper">
                                 <div className='logo'/>
                             </div>
@@ -138,7 +147,7 @@ class App extends Component {
                             // defaultSelectedKeys={['graphql-service']}
                             selectedKeys={[this.state.menuLevel1]}
                             style={{lineHeight: '64px'}}
-                            onClick={(e) => this.switchMenu('menuLevel1', e)}
+                            onClick={(e) => this.switchMenuTab('menuLevel1', e)}
                         >
                             <Menu.Item key="graphql-service">
                                 <Link to="/graphql-service/trial-case/index"><FormattedMessage id="Graphql Service"/></Link>

+ 0 - 58
src/components/cloudFunction/CloudFunction.jsx

@@ -1,58 +0,0 @@
-import React, {Component} from 'react';
-
-import {Layout, Menu  } from 'antd';
-
-import Deploy from '../common/deploy/Deploy';
-import Api from "./api/Api";
-
-const { Content } = Layout;
-
-class CloudFunction extends Component {
-    constructor() {
-        super();
-        this.state = {
-            menuLevel2: "deploy",
-        }
-    }
-
-    switchMenu = (menuName, e) => {
-        // console.log('menuName', menuName, 'e', e);
-        this.setState({
-            [menuName]: e.key,
-        });
-    };
-
-    render() {
-        return (
-            <div>
-                <Menu
-                    mode="horizontal"
-                    defaultSelectedKeys={['deploy']}
-                    style={{padding: '0 24px', position: 'fixed', width: '100%', zIndex: '1'}}
-                    onClick={(e) => this.switchMenu('menuLevel2', e)}
-                    selectedKeys={[this.state.menuLevel2]}
-                >
-                    <Menu.Item key="deploy">deploy</Menu.Item>
-                    <Menu.Item key="api">API</Menu.Item>
-                </Menu>
-
-                <Layout style={{ padding: '24px', zIndex: '0'}}>
-                    <Content style={{ padding: '24px', minHeight: 280, background: '#fff',marginTop: '48px'  }}>
-                        {(() => {
-                            switch (this.state.menuLevel2) {
-                                case 'deploy':
-                                    return <Deploy />;
-                                case 'api':
-                                    return <Api />;
-                                default:
-                                    return <Deploy />
-                            }
-                        })()}
-                    </Content>
-                </Layout>
-            </div>
-        )
-    }
-}
-
-export default CloudFunction;

+ 0 - 23
src/components/cloudFunction/api/Api.jsx

@@ -1,23 +0,0 @@
-import React, {Component} from 'react';
-
-import {  Pagination } from 'antd';
-
-export default class Api extends Component {
-    constructor() {
-        super();
-        this.state = {
-            locale: null,
-        };
-    }
-
-    render() {
-        return (
-            <div className="locale-components">
-                <div className="example">
-                    antd ui 组件中英切换
-                    <Pagination defaultCurrent={1} total={50} showSizeChanger />
-                </div>
-            </div>
-        );
-    }
-}

+ 0 - 0
src/components/cloudFunction/cloudDeploy/CloudDeploy.jsx


+ 45 - 11
src/components/common/schema/Table.js

@@ -1,6 +1,6 @@
 import React, {Component} from 'react';
 
-import {Layout, Select, Input, Icon, Button, notification, Spin} from 'antd';
+import {Layout, Select, Input, Icon, Button, notification, Spin, Modal} from 'antd';
 import {UPDATE_SCHEMA, SHOW_SCHEMA, SHOW_TABLE} from "../../gql";
 import gql from "graphql-tag";
 
@@ -9,6 +9,7 @@ import {getCookie} from "../../cookie";
 
 const Option = Select.Option;
 const {Content} = Layout;
+const confirm = Modal.confirm;
 
 class Table extends Component {
     constructor(props) {
@@ -261,8 +262,40 @@ class UpdateTableButton extends Component {
 
     }
 
+    showConfirm = (schemaName,schemaID) => {
+        let _this = this;
+
+        if(this.props.add !== 'add') {
+            this.props.history.push({
+                pathname: `/graphql-service/my-create/${schemaName}`,
+                state:{
+                    schemaName,
+                    schemaID
+                }
+            });
+        }else{
+            confirm({
+                title: '添加成功',
+                content: '继续添加数据表?',
+                onOk() {
+                    console.log('继续添加');
+                },
+                onCancel() {
+                    _this.props.history.push({
+                        pathname: `/graphql-service/my-create/${schemaName}`,
+                        state:{
+                            schemaName,
+                            schemaID
+                        }
+                    });
+                }
+            });
+        }
+    };
+
     render() {
         let schemaID = this.props.schemaID;
+        let schemaName = this.props.schemaName;
         let userID = this.props.userID;
 
         let varobj = {
@@ -289,6 +322,7 @@ class UpdateTableButton extends Component {
                         return (
                             <Mutation
                                 mutation={gql(UPDATE_SCHEMA)}
+                                onCompleted={()=>this.showConfirm(schemaName,schemaID)}
                                 refetchQueries={[{query: gql(SHOW_TABLE), variables: {schema_id: schemaID}}]}
                             >
 
@@ -349,16 +383,16 @@ class UpdateTableButton extends Component {
                                                         schemaData: JSON.stringify(schemaCols)
                                                     }
                                                 });
-                                                this.props.showTablePagination(this.props.page, this.props.pageSize, schemaCols)
-                                                if(this.props.add !== 'add') {
-                                                    this.props.history.push({
-                                                        pathname: `/graphql-service/my-create/${this.props.schemaName}`,
-                                                        state:{
-                                                            schemaName:this.props.schemaName,
-                                                            schemaID:this.props.schemaID
-                                                        }
-                                                    });
-                                                }
+                                                this.props.showTablePagination(this.props.page, this.props.pageSize, schemaCols);
+                                                // if(this.props.add !== 'add') {
+                                                //     this.props.history.push({
+                                                //         pathname: `/graphql-service/my-create/${this.props.schemaName}`,
+                                                //         state:{
+                                                //             schemaName:this.props.schemaName,
+                                                //             schemaID:this.props.schemaID
+                                                //         }
+                                                //     });
+                                                // }
                                             }}>
                                                 save
                                             </Button>

+ 0 - 62
src/components/monitorNotify/MonitorNotify.jsx

@@ -1,62 +0,0 @@
-import React, {Component} from 'react';
-
-import {Layout, Menu} from 'antd';
-import CaseNotification from "../common/caseNotification/CaseNotification";
-import Notification from "./notification/Notification";
-import GraphqlTrigger from "./graphqlTrigger/GraphqlTrigger";
-import StockSignal from "./stockSignal/StockSignal";
-
-const { Content } = Layout;
-
-class MonitorNotify extends Component {
-    constructor() {
-        super();
-        this.state = {
-            menuLevel2: "notification",
-        }
-    }
-
-    switchMenu = (menuName, e) => {
-        // console.log('menuName', menuName, 'e', e);
-        this.setState({
-            [menuName]: e.key,
-        });
-    };
-
-    render() {
-        return (
-            <div>
-                <Menu
-                    mode="horizontal"
-                    defaultSelectedKeys={['notification']}
-                    style={{padding: '0 24px', position: 'fixed', width: '100%', zIndex: '1'}}
-                    onClick={(e) => this.switchMenu('menuLevel2', e)}
-                    selectedKeys={[this.state.menuLevel2]}
-                >
-                    <Menu.Item key="notification">notification</Menu.Item>
-                    <Menu.Item key="graphql-trigger">graphql trigger</Menu.Item>
-                    <Menu.Item key="stock-signal">stock signal</Menu.Item>
-                </Menu>
-
-                <Layout style={{ padding: '24px', zIndex: '0'}}>
-                    <Content style={{ padding: '24px', minHeight: 280, background: '#fff',marginTop: '48px'  }}>
-                        {(() => {
-                            switch (this.state.menuLevel2) {
-                                case 'notification':
-                                    return <Notification />;
-                                case 'graphql-trigger':
-                                    return <GraphqlTrigger />;
-                                case 'stock-signal':
-                                    return <StockSignal />;
-                                default:
-                                    return <Notification />
-                            }
-                        })()}
-                    </Content>
-                </Layout>
-            </div>
-        )
-    }
-}
-
-export default MonitorNotify;

+ 0 - 15
src/components/monitorNotify/graphqlTrigger/GraphqlTrigger.jsx

@@ -1,15 +0,0 @@
-import React, {Component} from 'react';
-
-class GraphqlTrigger extends Component {
-
-
-    render() {
-        return (
-            <div>
-                Graphql Trigger
-            </div>
-        )
-    }
-}
-
-export default GraphqlTrigger;

+ 0 - 15
src/components/monitorNotify/notification/Notification.jsx

@@ -1,15 +0,0 @@
-import React, {Component} from 'react';
-
-class Notification extends Component {
-
-
-    render() {
-        return (
-            <div>
-                <p>Notification</p>
-            </div>
-        )
-    }
-}
-
-export default Notification;

+ 0 - 14
src/components/monitorNotify/stockSignal/StockSignal.jsx

@@ -1,14 +0,0 @@
-import React, {Component} from 'react';
-
-class StockSignal extends Component {
-
-    render() {
-        return (
-            <div>
-                Stock Signal
-            </div>
-        )
-    }
-}
-
-export default StockSignal;