Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix ddl get error #349

Merged
merged 2 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/pages/Schema/SchemaConfig/DDLButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const DDLButton = (props: IProps) => {
<Button
key="confirm"
type="primary"
disabled={!ddl}
onClick={handleDownload}
>
{intl.get('schema.downloadNGQL')}
Expand All @@ -101,7 +102,7 @@ const DDLButton = (props: IProps) => {
>
<Spin spinning={loading}>
{!loading && <div className={styles.modalItem}>
<CopyToClipboard key={1} text={ddl} onCopy={handleCopy}>
<CopyToClipboard key={1} text={ddl} onCopy={handleCopy} disabled={!ddl}>
<Button className={styles.duplicateBtn} key="confirm" icon={<Icon type="icon-Duplicate" />}>
{intl.get('common.duplicate')}
</Button>
Expand Down
19 changes: 18 additions & 1 deletion app/stores/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ import {
} from '@app/utils/gql';
import { message } from 'antd';

const initialSchemaData = {
edgeTypes: [],
tagsFields: [],
edgesFields: [],
indexes: [],
tags: [],
tagIndexTree: [],
edgeIndexTree: [],
tagList: [],
edgeList: [],
indexList: [],
} as Partial<SchemaStore>;
export class SchemaStore {
spaces: string[] = [];
currentSpace: string = sessionStorage.getItem('currentSpace') || '';
Expand Down Expand Up @@ -59,6 +71,7 @@ export class SchemaStore {
this.update({
currentSpace: '',
spaces: [],
...initialSchemaData,
});
sessionStorage.removeItem('currentSpace');
};
Expand Down Expand Up @@ -94,6 +107,7 @@ export class SchemaStore {
if (code === 0) {
this.update({
currentSpace: space,
...initialSchemaData
});
sessionStorage.setItem('currentSpace', space);
this.updateVidType(space);
Expand Down Expand Up @@ -758,7 +772,10 @@ export class SchemaStore {
indexes: [],
};
try {
await this.switchSpace(space);
const errMsg = await this.switchSpace(space);
if(errMsg) {
throw new Error(errMsg);
}
const spaceGql = await this.getSpaceCreateGQL(space);
ddlMap.space = spaceGql;
await this.switchSpace(space);
Expand Down