Ver código fonte

Merge branch 'master' of http://gogs.ioobot.com:6680/xy/online

xy 7 anos atrás
pai
commit
497289f4f0

+ 18 - 14
src/app/App.jsx

@@ -463,6 +463,7 @@ class WxConfigSiderbar extends Component {
             <Query query={gql(CASE_WXCONFIG_AND_PROJECT)} variables={{projectType:'wx',user_id: this.state.userID}}>
                 {
                     ({loading, error, data}) => {
+                        console.log('CASE_WXCONFIG_AND_PROJECT data', data);
                         if (loading) return <Spin style={{marginLeft: 3}}/>;
                         if (error) return 'error!';
                         return (
@@ -516,20 +517,23 @@ class WxConfigSiderbar extends Component {
                                     <span><FormattedMessage id="My Create"/></span>
                                 </span>}>
                                     {
-                                        data.project.map((project) =>{
-                                            let appName = project.wxConfig_id.appName;
-                                            let configID = project.wxConfig_id.id;
-                                            return (
-                                                <Menu.Item key={appName}>
-                                                    <Link to={{
-                                                        pathname: `/wechat-service/my-create/${appName}`,
-                                                        state: {
-                                                            appName,
-                                                            configID
-                                                        }
-                                                    }}>{appName}</Link>
-                                                </Menu.Item>
-                                            )
+                                        data.project.map((project) => {
+                                            if(project){
+                                                let appName = project.wxConfig_id.appName;
+                                                let configID = project.wxConfig_id.id;
+                                                return (
+                                                    <Menu.Item key={appName}>
+                                                        <Link to={{
+                                                            pathname: `/wechat-service/my-create/${appName}`,
+                                                            state: {
+                                                                appName,
+                                                                configID
+                                                            }
+                                                        }}>{appName}</Link>
+                                                    </Menu.Item>
+                                                )
+                                            }
+                                            return false;
                                         })
                                     }
                                 </SubMenu>

+ 1 - 1
src/app/graphqlService/TrialCase.jsx

@@ -78,7 +78,7 @@ class TrialCase extends Component {
                             (() => {
                                 switch (this.state.menuLevel2) {
                                     case 'schema':
-                                        return <Schema trialcase={true} userID={this.state.userID} schemaName={schemaName} schemaID={schemaID} history={this.props.history} location={this.props.location}/>;
+                                        return <Schema trialcase={true} userID={this.state.userID} projectID={projectID} schemaName={schemaName} schemaID={schemaID} history={this.props.history} location={this.props.location}/>;
                                     case 'deploy':
                                         return <Deploy trialcase={true} userID={this.state.userID} projectID={projectID}/>;
                                     case 'manage':

+ 15 - 18
src/app/graphqlService/component/schema/Schema.jsx

@@ -5,7 +5,7 @@ import './index.css';
 import {Mutation, Query} from "react-apollo";
 import gql from "graphql-tag";
 import {
-    DELETE_PROJECT_AND_SCHEMA,
+    DELETE_PROJECT,
     SHOW_SCHEMA,
     SHOW_TABLE,
     UPDATE_SCHEMA,
@@ -33,6 +33,7 @@ class Schema extends Component {
             // default schemaID and schemaName
             schemaID: props.location.state === undefined ? props.schemaID : props.location.state.schemaID,
             schemaName: props.location.state === undefined ? props.schemaName : props.location.state.schemaName,
+            projectID: props.location.state === undefined ? props.projectID : props.location.state.projectID,
             editSchemaName: '',
             allData: '',
             data: '',
@@ -391,20 +392,18 @@ class Schema extends Component {
                                                                         </div>
                                                                         <div style={{display: 'inline-block'}}
                                                                              className={'delete-schema'}>
-                                                                            <DeleteSchemaButton
+                                                                            <DeleteProjectButton
                                                                                 userID={userID}
-                                                                                schemaID={this.state.schemaID}
-                                                                                schemaName={this.state.schemaName}
+                                                                                projectID={this.state.projectID}
                                                                                 history={this.props.history}
                                                                             />
                                                                         </div>
                                                                     </div>
                                                                     :
                                                                     <div className={'delete-schema'}>
-                                                                        <DeleteSchemaButton
+                                                                        <DeleteProjectButton
                                                                             userID={userID}
-                                                                            schemaID={this.state.schemaID}
-                                                                            schemaName={this.state.schemaName}
+                                                                            projectID={this.state.projectID}
                                                                             history={this.props.history}
                                                                         />
                                                                     </div>
@@ -420,10 +419,9 @@ class Schema extends Component {
                                                                     </div>
                                                                     :
                                                                     <div className={'delete-schema'}>
-                                                                        <DeleteSchemaButton
+                                                                        <DeleteProjectButton
                                                                             userID={userID}
-                                                                            schemaID={this.state.schemaID}
-                                                                            schemaName={this.state.schemaName}
+                                                                            projectID={this.state.projectID}
                                                                             history={this.props.history}
                                                                         />
                                                                     </div>
@@ -585,22 +583,21 @@ class CopySchemaButton extends Component {
     }
 }
 
-class DeleteSchemaButton extends Component {
+class DeleteProjectButton extends Component {
     constructor(props) {
         super(props);
         this.state = {
-            schemaName: props.schemaName,
-            schemaId:props.schemaID
+            projectID:props.projectID
         }
     }
 
-    showConfirm = (delete_project_and_schema, schemaId, userID) => {
+    showConfirm = (delete_project_and_schema, projectID, userID) => {
         let _this = this;
         confirm({
             title: 'Do you want to delete this schema?',
             content: 'It cannot be found back!',
             onOk() {
-                delete_project_and_schema({variables: {schemaId, user_id: userID}});
+                delete_project_and_schema({variables: {id:projectID, user_id: userID}});
                 _this.props.history.push({
                     pathname: '/graphql-service',
                 });
@@ -612,11 +609,11 @@ class DeleteSchemaButton extends Component {
 
     render() {
         let userID = this.props.userID;
-        let {schemaName,schemaId} = this.state;
+        let {projectID} = this.state;
 
         return (
             <Mutation
-                mutation={gql(DELETE_PROJECT_AND_SCHEMA)}
+                mutation={gql(DELETE_PROJECT)}
                 refetchQueries={[{query: gql(SHOW_PROJECT), variables: {projectType:'graphql',user_id: userID}}]}
                 // update={(cache) => {
                 //     let data = cache.readQuery({query: gql(SHOW_PROJECT), variables: {projectType:"graphql",user_id: userID}});
@@ -638,7 +635,7 @@ class DeleteSchemaButton extends Component {
                         <Button
                             type="danger"
                             onClick={() => {
-                                this.showConfirm(delete_project_and_schema, schemaId, userID);
+                                this.showConfirm(delete_project_and_schema, projectID, userID);
                             }}
                         >
                             <FormattedMessage id="delete"/>

+ 3 - 2
src/app/wechatService/wxCreate/WxCreate.js

@@ -5,7 +5,7 @@ import {Modal, Row, Col, Input, Icon, Button, Spin} from 'antd';
 import {Mutation, Query} from "react-apollo";
 import gql from "graphql-tag";
 
-import {ADD_WXCONFIG,ADD_PROJECT_AND_WX, SHOW_WXCONFIG} from '../../../gql'
+import {ADD_WXCONFIG,ADD_PROJECT_AND_WX, SHOW_PROJECT,SHOW_WXCONFIG} from '../../../gql'
 import './index.css';
 import {getCookie} from "../../../cookie";
 import {idGen} from "../../../func";
@@ -92,7 +92,8 @@ class WxCreate extends Component {
             variables: {
                 ...wxConfigVarObj,
                 ...projectVarObj
-            }
+            },
+            refetchQueries:[{query: gql(SHOW_PROJECT), variables: {projectType:'wx',user_id: userID}}]
         });
 
         setTimeout(() => {

+ 4 - 5
src/gql.js

@@ -460,10 +460,9 @@ const SHOW_PROJECT = `
              }
          `;
 
-const DELETE_PROJECT_AND_SCHEMA = `
-            mutation DELETE_PROJECT_AND_SCHEMA($schemaId: ID, $user_id: ID) {
-                delete_schema(id: $schemaId, user_id: $user_id)
-                delete_project(schema_id: $schemaId, user_id: $user_id)
+const DELETE_PROJECT = `
+            mutation DELETE_PROJECT($id: ID, $user_id: ID) {
+                delete_project(id: $id, user_id: $user_id)
             }
         `;
 
@@ -968,7 +967,7 @@ export {
     UPDATE_SCHEMA,
     UPDATE_SCHEMA_PROJECT_NAME,
     DELETE_SCHEMA,
-    DELETE_PROJECT_AND_SCHEMA,
+    DELETE_PROJECT,
     SHOW_TABLE,
     ADD_PROJECT_AND_SCHEMA,
     CASE_SCHEMA_AND_PROJECT,