|
|
@@ -1,11 +1,9 @@
|
|
|
import React, {Component} from 'react';
|
|
|
import {withRouter} from "react-router-dom";
|
|
|
-import {Modal, Row, Col, Input, Icon, Button, Spin} from 'antd';
|
|
|
-
|
|
|
-import {Mutation, Query} from "react-apollo";
|
|
|
+import {Modal, Input, notification, Spin} from 'antd';
|
|
|
+import {Mutation} from "react-apollo";
|
|
|
import gql from "graphql-tag";
|
|
|
-
|
|
|
-import {ADD_PROJECT_AND_SCHEMA,SHOW_PROJECT} from '../../../../gql'
|
|
|
+import {ADD_PROJECT_AND_SCHEMA, SHOW_PROJECT} from '../../../../gql'
|
|
|
import './index.css';
|
|
|
import {getCookie} from "../../../../cookie";
|
|
|
import {idGen, removeSpace} from "../../../../func";
|
|
|
@@ -37,7 +35,7 @@ class Create extends Component {
|
|
|
|
|
|
handleOk = (userID, create_project_and_schema) => {
|
|
|
let schemaId = idGen('schema');
|
|
|
- let projectId= idGen('project');
|
|
|
+ let projectId = idGen('project');
|
|
|
let schemaName = this.state.schemaName;
|
|
|
let createdAt = new Date().getTime();
|
|
|
|
|
|
@@ -71,8 +69,8 @@ class Create extends Component {
|
|
|
});
|
|
|
|
|
|
create_project_and_schema({
|
|
|
- variables: {...schemaVarObj,...projectVarObj},
|
|
|
- refetchQueries:[{query: gql(SHOW_PROJECT), variables: {projectType:'graphql',user_id: userID}}]
|
|
|
+ variables: {...schemaVarObj, ...projectVarObj},
|
|
|
+ refetchQueries: [{query: gql(SHOW_PROJECT), variables: {projectType: 'graphql', user_id: userID}}]
|
|
|
});
|
|
|
setTimeout(() => {
|
|
|
this.setState({
|
|
|
@@ -86,7 +84,7 @@ class Create extends Component {
|
|
|
pathname: `/graphql-service/my-create/${schemaName}`,
|
|
|
state: {
|
|
|
schemaName,
|
|
|
- schemaID:schemaId,
|
|
|
+ schemaID: schemaId,
|
|
|
projectID: projectId,
|
|
|
create: true
|
|
|
}
|
|
|
@@ -113,7 +111,10 @@ class Create extends Component {
|
|
|
<Modal title={msg}
|
|
|
centered
|
|
|
visible={visible}
|
|
|
- onOk={() => this.handleOk(userID, create_project_and_schema)}
|
|
|
+ onOk={() => {
|
|
|
+ if (userID !== '' && userID !== undefined)
|
|
|
+ this.handleOk(userID, create_project_and_schema)
|
|
|
+ }}
|
|
|
confirmLoading={confirmLoading}
|
|
|
onCancel={() => {
|
|
|
this.props.hideModal();
|
|
|
@@ -123,25 +124,28 @@ class Create extends Component {
|
|
|
<p><FormattedMessage id="schema name"/></p>
|
|
|
<FormattedMessage id="input schema name">
|
|
|
{(msg) => (
|
|
|
- <Input
|
|
|
- className='add-input'
|
|
|
- placeholder={msg}
|
|
|
- onChange={e => {
|
|
|
- e.persist();
|
|
|
+ <Input
|
|
|
+ className='add-input'
|
|
|
+ placeholder={msg}
|
|
|
+ onChange={e => {
|
|
|
+ e.persist();
|
|
|
+ if (userID === '' || undefined) {
|
|
|
+ notification.open({
|
|
|
+ message: '提醒',
|
|
|
+ description: '需要登录.',
|
|
|
+ });
|
|
|
+ this.redirectToLogin();
|
|
|
+ this.props.hideModal();
|
|
|
+ } else {
|
|
|
this.setState({
|
|
|
schemaName: e.target.value,
|
|
|
});
|
|
|
- if (userID === '' || undefined) {
|
|
|
- this.redirectToLogin();
|
|
|
- this.props.hideModal();
|
|
|
- }
|
|
|
- }}
|
|
|
- />
|
|
|
- )
|
|
|
- }
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ )}
|
|
|
|
|
|
</FormattedMessage>
|
|
|
-
|
|
|
</div>
|
|
|
</Modal>
|
|
|
)}
|