Skip to content

Commit

Permalink
fix: fix issue (#446)
Browse files Browse the repository at this point in the history
* fix: fix issue

* mod: code review
  • Loading branch information
hetao92 authored Feb 6, 2023
1 parent acec597 commit 89e2c06
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/pages/SketchModeling/Plugins/Tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Tooltip = observer(function Tooltip() {
const {
data: { type, name, properties = [], fill, strokeColor },
} = data;
if(!name && !properties.length) {
if(!container || (!name && !properties.length)) {
return null;
}
const { left, top } = tooltip;
Expand Down
29 changes: 14 additions & 15 deletions app/pages/SketchModeling/SketchConfigHeader/ApplySpacePopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,8 @@ const PopoverContent = (props: IContentProps) => {
}, []);

const switchSpaceAndApply = useCallback(async (space, schemaInfo) => {
const err = await schema.switchSpace(space, true);
if (!err) {
batchApplySchema(schemaInfo);
} else if (err && err.toLowerCase().includes('spacenotfound')) {
setTimeout(() => switchSpaceAndApply(space, schemaInfo), 1200);
} else {
setLoading(false);
return;
}
await schema.switchSpace(space);
batchApplySchema(space, schemaInfo);
}, []);

const handleConfirm = useCallback(() => {
Expand Down Expand Up @@ -117,7 +110,7 @@ const PopoverContent = (props: IContentProps) => {
return;
}
setLoading(true);
batchApplySchema(schemaInfo);
batchApplySchema(space, schemaInfo);
trackEvent('sketch', 'batch_apply_sketch');
}
});
Expand Down Expand Up @@ -171,16 +164,23 @@ const PopoverContent = (props: IContentProps) => {
return res;
}, []);

const batchApplySchema = useCallback(async (schema) => {
const batchApplySchema = useCallback(async (space, schema) => {
const { tags, edges } = schema;
const gql = tags.map(tag => getCreateGql(tag)).concat(edges.map(edge => getCreateGql(edge))).join(';');
const { code } = await sketchModel.batchApply(gql);
setLoading(false);
const { code, message: errMsg } = await sketchModel.batchApply(gql, space);
if(code === 0) {
setLoading(false);
message.success(intl.get('schema.createSuccess'));
setTimeout(() => {
history.push('/schema/tag/list');
}, 600);
return;
}
if (errMsg && errMsg.toLowerCase().includes('spacenotfound')) {
setTimeout(() => batchApplySchema(space, schema), 3000);
} else {
setLoading(false);
message.warning(errMsg);
}
}, []);
return (
Expand Down Expand Up @@ -215,7 +215,7 @@ const PopoverContent = (props: IContentProps) => {
</Form>
)}
<div className={styles.formFooter}>
<Button onClick={close}>{intl.get('common.cancel')}</Button>
<Button disabled={loading} onClick={close}>{intl.get('common.cancel')}</Button>
<Button type="primary" onClick={handleConfirm} loading={loading}>
{intl.get('common.confirm')}
</Button>
Expand Down Expand Up @@ -252,7 +252,6 @@ export default observer(function ApplySpacePopover() {
arrowPointAtCenter={true}
trigger="click"
open={open}
destroyTooltipOnHide={true}
onOpenChange={open => !open && setOpen(false)}
>
<Button type="primary" onClick={handleOpen} disabled={disabled}>
Expand Down
6 changes: 3 additions & 3 deletions app/stores/sketchModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@ export class SketchStore {
});
};

batchApply = async (gql) => {
const { code, data } = await service.execNGQL({ gql });
return { code, data };
batchApply = async (gql, space) => {
const { code, data, message } = await service.execNGQL({ gql, space }, { noTip: true });
return { code, data, message };
};

deleteElement = (type) => {
Expand Down

0 comments on commit 89e2c06

Please sign in to comment.