|
@@ -5,13 +5,13 @@ import './index.css';
|
|
|
import {Mutation, Query} from "react-apollo";
|
|
import {Mutation, Query} from "react-apollo";
|
|
|
import gql from "graphql-tag";
|
|
import gql from "graphql-tag";
|
|
|
import {
|
|
import {
|
|
|
- DELETE_SCHEMA,
|
|
|
|
|
|
|
+ DELETE_PROJECT_AND_SCHEMA,
|
|
|
SHOW_SCHEMA,
|
|
SHOW_SCHEMA,
|
|
|
SHOW_TABLE,
|
|
SHOW_TABLE,
|
|
|
UPDATE_SCHEMA,
|
|
UPDATE_SCHEMA,
|
|
|
- UPDATE_SCHEMA_NAME,
|
|
|
|
|
|
|
+ UPDATE_SCHEMA_PROJECT_NAME,
|
|
|
SEARCH_SCHEMA,
|
|
SEARCH_SCHEMA,
|
|
|
- ADD_SCHEMA
|
|
|
|
|
|
|
+ ADD_SCHEMA, SHOW_PROJECT
|
|
|
} from '../../../../gql'
|
|
} from '../../../../gql'
|
|
|
import Table from "./Table";
|
|
import Table from "./Table";
|
|
|
import {request} from 'graphql-request'
|
|
import {request} from 'graphql-request'
|
|
@@ -392,6 +392,7 @@ class Schema extends Component {
|
|
|
className={'delete-schema'}>
|
|
className={'delete-schema'}>
|
|
|
<DeleteSchemaButton
|
|
<DeleteSchemaButton
|
|
|
userID={userID}
|
|
userID={userID}
|
|
|
|
|
+ schemaID={this.state.schemaID}
|
|
|
schemaName={this.state.schemaName}
|
|
schemaName={this.state.schemaName}
|
|
|
history={this.props.history}
|
|
history={this.props.history}
|
|
|
/>
|
|
/>
|
|
@@ -401,6 +402,7 @@ class Schema extends Component {
|
|
|
<div className={'delete-schema'}>
|
|
<div className={'delete-schema'}>
|
|
|
<DeleteSchemaButton
|
|
<DeleteSchemaButton
|
|
|
userID={userID}
|
|
userID={userID}
|
|
|
|
|
+ schemaID={this.state.schemaID}
|
|
|
schemaName={this.state.schemaName}
|
|
schemaName={this.state.schemaName}
|
|
|
history={this.props.history}
|
|
history={this.props.history}
|
|
|
/>
|
|
/>
|
|
@@ -418,6 +420,7 @@ class Schema extends Component {
|
|
|
<div className={'delete-schema'}>
|
|
<div className={'delete-schema'}>
|
|
|
<DeleteSchemaButton
|
|
<DeleteSchemaButton
|
|
|
userID={userID}
|
|
userID={userID}
|
|
|
|
|
+ schemaID={this.state.schemaID}
|
|
|
schemaName={this.state.schemaName}
|
|
schemaName={this.state.schemaName}
|
|
|
history={this.props.history}
|
|
history={this.props.history}
|
|
|
/>
|
|
/>
|
|
@@ -556,17 +559,18 @@ class DeleteSchemaButton extends Component {
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
|
super(props);
|
|
super(props);
|
|
|
this.state = {
|
|
this.state = {
|
|
|
- schemaName: props.schemaName
|
|
|
|
|
|
|
+ schemaName: props.schemaName,
|
|
|
|
|
+ schemaId:props.schemaID
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- showConfirm = (delete_schema, schemaName, userID) => {
|
|
|
|
|
|
|
+ showConfirm = (delete_project_and_schema, schemaId, userID) => {
|
|
|
let _this = this;
|
|
let _this = this;
|
|
|
confirm({
|
|
confirm({
|
|
|
title: 'Do you want to delete this schema?',
|
|
title: 'Do you want to delete this schema?',
|
|
|
content: 'It cannot be found back!',
|
|
content: 'It cannot be found back!',
|
|
|
onOk() {
|
|
onOk() {
|
|
|
- delete_schema({variables: {schemaName, user_id: userID}});
|
|
|
|
|
|
|
+ delete_project_and_schema({variables: {schemaId, user_id: userID}});
|
|
|
_this.props.history.push({
|
|
_this.props.history.push({
|
|
|
pathname: '/graphql-service',
|
|
pathname: '/graphql-service',
|
|
|
});
|
|
});
|
|
@@ -578,22 +582,24 @@ class DeleteSchemaButton extends Component {
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
let userID = this.props.userID;
|
|
let userID = this.props.userID;
|
|
|
- let schemaName = this.props.schemaName;
|
|
|
|
|
|
|
+ let {schemaName,schemaId} = this.state;
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<Mutation
|
|
<Mutation
|
|
|
- mutation={gql(DELETE_SCHEMA)}
|
|
|
|
|
- update={(cache) => {
|
|
|
|
|
- let data = cache.readQuery({query: gql(SHOW_SCHEMA), variables: {user_id: userID}});
|
|
|
|
|
-
|
|
|
|
|
- data.schema_by_props.splice(data.schema_by_props.findIndex(obj => obj.schemaName === this.state.schemaName), 1);
|
|
|
|
|
- cache.writeQuery({
|
|
|
|
|
- query: gql(SHOW_SCHEMA),
|
|
|
|
|
- variables: {user_id: userID},
|
|
|
|
|
- data
|
|
|
|
|
- });
|
|
|
|
|
- }}
|
|
|
|
|
|
|
+ mutation={gql(DELETE_PROJECT_AND_SCHEMA)}
|
|
|
|
|
+ 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}});
|
|
|
|
|
+ //
|
|
|
|
|
+ // data.project.splice(data.project.findIndex(obj => obj.projectName === schemaName), 1);
|
|
|
|
|
+ // cache.writeQuery({
|
|
|
|
|
+ // query: gql(SHOW_PROJECT),
|
|
|
|
|
+ // variables: {projectType:"graphql",user_id: userID},
|
|
|
|
|
+ // data
|
|
|
|
|
+ // });
|
|
|
|
|
+ // }}
|
|
|
>
|
|
>
|
|
|
- {(delete_schema, {loading, error}) => {
|
|
|
|
|
|
|
+ {(delete_project_and_schema, {loading, error}) => {
|
|
|
if (error)
|
|
if (error)
|
|
|
return 'error';
|
|
return 'error';
|
|
|
if (loading)
|
|
if (loading)
|
|
@@ -602,7 +608,7 @@ class DeleteSchemaButton extends Component {
|
|
|
<Button
|
|
<Button
|
|
|
type="danger"
|
|
type="danger"
|
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
- this.showConfirm(delete_schema, schemaName, userID);
|
|
|
|
|
|
|
+ this.showConfirm(delete_project_and_schema, schemaId, userID);
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
<FormattedMessage id="delete"/>
|
|
<FormattedMessage id="delete"/>
|
|
@@ -703,8 +709,8 @@ class ModifySchemaNameInput extends Component {
|
|
|
let userID = this.props.userID;
|
|
let userID = this.props.userID;
|
|
|
let schemaName = this.props.schemaName;
|
|
let schemaName = this.props.schemaName;
|
|
|
return (
|
|
return (
|
|
|
- <Mutation mutation={gql(UPDATE_SCHEMA_NAME)}>
|
|
|
|
|
- {(update_schema, {loading, error}) => {
|
|
|
|
|
|
|
+ <Mutation mutation={gql(UPDATE_SCHEMA_PROJECT_NAME)}>
|
|
|
|
|
+ {(update_schema_project_name, {loading, error}) => {
|
|
|
if (error)
|
|
if (error)
|
|
|
return 'error';
|
|
return 'error';
|
|
|
if (loading)
|
|
if (loading)
|
|
@@ -720,12 +726,14 @@ class ModifySchemaNameInput extends Component {
|
|
|
size="large"
|
|
size="large"
|
|
|
onChange={this.props.changeEditSchemaName}
|
|
onChange={this.props.changeEditSchemaName}
|
|
|
onSearch={value => {
|
|
onSearch={value => {
|
|
|
- update_schema({
|
|
|
|
|
|
|
+ update_schema_project_name({
|
|
|
variables: {
|
|
variables: {
|
|
|
id: this.props.schemaID,
|
|
id: this.props.schemaID,
|
|
|
schemaName: value,
|
|
schemaName: value,
|
|
|
updateAt: new Date().getTime()
|
|
updateAt: new Date().getTime()
|
|
|
}
|
|
}
|
|
|
|
|
+ }).then((res)=>{
|
|
|
|
|
+ console.log('update_schema_project_name res',res)
|
|
|
});
|
|
});
|
|
|
this.props.history.push({
|
|
this.props.history.push({
|
|
|
pathname: `/graphql-service/my-create/${value}`,
|
|
pathname: `/graphql-service/my-create/${value}`,
|