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

terminate a rebuilding index, fix #477 #511

Merged
merged 1 commit into from
May 24, 2024
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
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
Loading