|
|
@@ -10,7 +10,7 @@ import {
|
|
|
SHOW_TABLE,
|
|
|
UPDATE_SCHEMA,
|
|
|
UPDATE_SCHEMA_PROJECT_NAME,
|
|
|
- SEARCH_SCHEMA,
|
|
|
+ SEARCH_SCHEMA,ADD_PROJECT_AND_SCHEMA,
|
|
|
ADD_SCHEMA, SHOW_PROJECT
|
|
|
} from '../../../../gql'
|
|
|
import Table from "./Table";
|
|
|
@@ -385,6 +385,7 @@ class Schema extends Component {
|
|
|
<CopySchemaButton
|
|
|
userID={userID}
|
|
|
history={this.props.history}
|
|
|
+ schemaID={this.state.schemaID}
|
|
|
schemaName={this.state.schemaName}
|
|
|
/>
|
|
|
</div>
|
|
|
@@ -413,6 +414,7 @@ class Schema extends Component {
|
|
|
<CopySchemaButton
|
|
|
userID={userID}
|
|
|
history={this.props.history}
|
|
|
+ schemaID={this.state.schemaID}
|
|
|
schemaName={this.state.schemaName}
|
|
|
/>
|
|
|
</div>
|
|
|
@@ -503,47 +505,75 @@ class CopySchemaButton extends Component {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ handleOk = (userID, create_project_and_schema) => {
|
|
|
+ let {history,schemaName,schemaID} = this.props;
|
|
|
+ let projectName = schemaName + '_' + Math.random().toString().slice(-3) + Math.random().toString().slice(-4);
|
|
|
+ let schemaId = idGen('schema');
|
|
|
+ let projectId= idGen('project');
|
|
|
+ let createdAt = new Date().getTime();
|
|
|
+
|
|
|
+ let schemaVarObj = {
|
|
|
+ schemaId,
|
|
|
+ schemaName:projectName,
|
|
|
+ user_id: userID,
|
|
|
+ schemaCreatedAt: createdAt,
|
|
|
+ schemaUpdatedAt: '',
|
|
|
+ schemaState: 'copy',
|
|
|
+ schemaData: JSON.stringify([]),
|
|
|
+ reference: schemaID
|
|
|
+ };
|
|
|
+ let projectVarObj = {
|
|
|
+ projectCreatedAt: createdAt,
|
|
|
+ projectUpdatedAt: '',
|
|
|
+ database_id: '',
|
|
|
+ apiGWGroup_id: '',
|
|
|
+ projectName,
|
|
|
+ deploy_id: '',
|
|
|
+ projectId,
|
|
|
+ projectType: 'graphql',
|
|
|
+ cloud_id: '',
|
|
|
+ user_id: userID,
|
|
|
+ wxConfig_id: '',
|
|
|
+ schema_id: schemaId
|
|
|
+ };
|
|
|
+
|
|
|
+ create_project_and_schema({
|
|
|
+ variables: {...schemaVarObj,...projectVarObj},
|
|
|
+ refetchQueries:[{query: gql(SHOW_PROJECT), variables: {projectType:'graphql',user_id: userID}}]
|
|
|
+ });
|
|
|
+
|
|
|
+ history.push({
|
|
|
+ pathname: `/graphql-service/my-create/${schemaName}`,
|
|
|
+ state: {
|
|
|
+ schemaName,
|
|
|
+ schemaID:schemaId,
|
|
|
+ projectID: projectId,
|
|
|
+ copy: true,
|
|
|
+ reference: schemaID
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
render() {
|
|
|
- let userID = getCookie('user_id');
|
|
|
- let {history, schemaName} = this.props;
|
|
|
- let schemaID = schemaName + '_schemaID';
|
|
|
+ let {userID} = this.props;
|
|
|
+ // let schemaID = schemaName + '_schemaID';
|
|
|
return (
|
|
|
<div>
|
|
|
<Mutation
|
|
|
- mutation={gql(ADD_SCHEMA)}
|
|
|
- refetchQueries={[{query: gql(SHOW_SCHEMA), variables: {user_id: userID}}]}
|
|
|
+ mutation={gql(ADD_PROJECT_AND_SCHEMA)}
|
|
|
+ // refetchQueries={[{query: gql(SHOW_SCHEMA), variables: {user_id: userID}}]}
|
|
|
>
|
|
|
- {(create_schema, {loading, error}) => {
|
|
|
+ {(create_project_and_schema, {loading, error}) => {
|
|
|
if (loading)
|
|
|
return <Spin style={{marginLeft: 30, marginTop: 10}}/>;
|
|
|
if (error)
|
|
|
return 'error';
|
|
|
|
|
|
- let varObj = {
|
|
|
- id: idGen('schema'),
|
|
|
- user_id: userID,
|
|
|
- createdAt: new Date().getTime(),
|
|
|
- updatedAt: '',
|
|
|
- schemaState: 'copy',
|
|
|
- schemaData: JSON.stringify([]),
|
|
|
- reference: schemaID,
|
|
|
- schemaName: schemaName + '_' + Math.random().toString().slice(-3) + Math.random().toString().slice(-4)
|
|
|
- };
|
|
|
-
|
|
|
return (
|
|
|
<Button
|
|
|
type="primary"
|
|
|
onClick={() => {
|
|
|
- create_schema({variables: varObj});
|
|
|
- history.push({
|
|
|
- pathname: `/graphql-service/my-create/${varObj.schemaName}`,
|
|
|
- state: {
|
|
|
- schemaName: varObj.schemaName,
|
|
|
- schemaID: varObj.id,
|
|
|
- copy: true,
|
|
|
- reference: varObj.reference
|
|
|
- }
|
|
|
- });
|
|
|
+ this.handleOk(userID, create_project_and_schema);
|
|
|
}}
|
|
|
|
|
|
><FormattedMessage id="copy"/></Button>
|
|
|
@@ -708,6 +738,7 @@ class ModifySchemaNameInput extends Component {
|
|
|
render() {
|
|
|
let userID = this.props.userID;
|
|
|
let schemaName = this.props.schemaName;
|
|
|
+ console.log('schemaId',this.props.schemaID);
|
|
|
return (
|
|
|
<Mutation mutation={gql(UPDATE_SCHEMA_PROJECT_NAME)}>
|
|
|
{(update_schema_project_name, {loading, error}) => {
|