Skip to content

Commit

Permalink
terminate a rebuilding index, fix #477 (#511)
Browse files Browse the repository at this point in the history
Signed-off-by: ryjiang <[email protected]>
  • Loading branch information
shanghaikid committed May 24, 2024
1 parent a7b9503 commit ac2285a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 27 deletions.
1 change: 1 addition & 0 deletions client/src/i18n/cn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const indexTrans = {
metric: '度量类型',
createSuccess: '开始创建索引',
deleteWarning: '您正在尝试删除一个索引。此操作无法撤销。',
cancelCreate: '取消创建索引',
};

export default indexTrans;
1 change: 1 addition & 0 deletions client/src/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const indexTrans = {
createSuccess: 'Start creating index',
deleteWarning:
'You are trying to delete an index. This action cannot be undone.',
cancelCreate: 'Cancel Index Creation',
};

export default indexTrans;
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,37 @@ const IndexTypeElement: FC<{
});
};

const chipComp = (
text = field.index.indexType,
icon = <Icons.delete classes={{ root: 'icon' }} />,
tooltip = ''
) => {
const IndexElem = () => (
<Chip
label={text}
classes={{ root: classes.chip, label: classes.chipLabel }}
deleteIcon={icon}
onDelete={handleDelete}
disabled={disabled}
onClick={e => {
e.stopPropagation();
handleDelete();
}}
size="small"
/>
);

return tooltip ? (
<Tooltip interactive arrow title={tooltip} placement="top">
<div>
<IndexElem />
</div>
</Tooltip>
) : (
<IndexElem />
);
};

const generateElement = () => {
if (
field.is_primary_key ||
Expand All @@ -176,38 +207,21 @@ const IndexTypeElement: FC<{
switch (field.index.indexType) {
default: {
if (field.index.state === IndexState.InProgress) {
return <StatusIcon type={LoadingType.CREATING} />;
return (
<>
{chipComp(
field.index.indexType,
<StatusIcon type={LoadingType.CREATING} />,
indexTrans('cancelCreate')
)}
</>
);
}

const chipComp = () => (
<Chip
label={field.index.indexType}
classes={{ root: classes.chip, label: classes.chipLabel }}
deleteIcon={<Icons.delete classes={{ root: 'icon' }} />}
onDelete={handleDelete}
disabled={disabled}
onClick={(e: MouseEvent<HTMLDivElement>) => {
e.stopPropagation();
handleDelete();
}}
size="small"
/>
);
/**
* if creating finished, show chip that contains index type
*/
return disabled ? (
<Tooltip
interactive
arrow
title={disabledTooltip ?? ''}
placement={'top'}
>
<div>{chipComp()}</div>
</Tooltip>
) : (
<div>{chipComp()}</div>
);
return chipComp(field.index.indexType);
}
}
};
Expand Down

0 comments on commit ac2285a

Please sign in to comment.