|
@@ -76,7 +76,7 @@ const IndexTypeElement: FC<{
|
|
}> = ({ data, collectionName, cb }) => {
|
|
}> = ({ data, collectionName, cb }) => {
|
|
const classes = useStyles();
|
|
const classes = useStyles();
|
|
// set empty string as defalut status
|
|
// set empty string as defalut status
|
|
- const [status, setStatus] = useState<string>('');
|
|
|
|
|
|
+ const [status, setStatus] = useState<string>(IndexState.Default);
|
|
|
|
|
|
const { t: indexTrans } = useTranslation('index');
|
|
const { t: indexTrans } = useTranslation('index');
|
|
const { t: btnTrans } = useTranslation('btn');
|
|
const { t: btnTrans } = useTranslation('btn');
|
|
@@ -93,7 +93,7 @@ const IndexTypeElement: FC<{
|
|
|
|
|
|
const fetchStatus = useCallback(async () => {
|
|
const fetchStatus = useCallback(async () => {
|
|
// prevent delete index trigger fetching index status
|
|
// prevent delete index trigger fetching index status
|
|
- if (data._indexType !== '' && status !== 'delete') {
|
|
|
|
|
|
+ if (data._indexType !== '' && status !== IndexState.Delete) {
|
|
const { state: status } = await IndexHttp.getIndexStatus(
|
|
const { state: status } = await IndexHttp.getIndexStatus(
|
|
collectionName,
|
|
collectionName,
|
|
data._fieldName
|
|
data._fieldName
|
|
@@ -147,7 +147,7 @@ const IndexTypeElement: FC<{
|
|
};
|
|
};
|
|
await IndexHttp.createIndex(indexCreateParam);
|
|
await IndexHttp.createIndex(indexCreateParam);
|
|
// reset status to default empty string
|
|
// reset status to default empty string
|
|
- setStatus('');
|
|
|
|
|
|
+ setStatus(IndexState.Default);
|
|
handleCloseDialog();
|
|
handleCloseDialog();
|
|
openSnackBar(indexTrans('createSuccess'));
|
|
openSnackBar(indexTrans('createSuccess'));
|
|
cb(collectionName);
|
|
cb(collectionName);
|
|
@@ -178,7 +178,7 @@ const IndexTypeElement: FC<{
|
|
|
|
|
|
await IndexHttp.deleteIndex(indexDeleteParam);
|
|
await IndexHttp.deleteIndex(indexDeleteParam);
|
|
// use 'delete' as special status for whether fetching index status check
|
|
// use 'delete' as special status for whether fetching index status check
|
|
- setStatus('delete');
|
|
|
|
|
|
+ setStatus(IndexState.Delete);
|
|
cb(collectionName);
|
|
cb(collectionName);
|
|
handleCloseDialog();
|
|
handleCloseDialog();
|
|
openSnackBar(successTrans('delete', { name: indexTrans('index') }));
|
|
openSnackBar(successTrans('delete', { name: indexTrans('index') }));
|
|
@@ -229,7 +229,7 @@ const IndexTypeElement: FC<{
|
|
* empty string or 'delete' means fetching progress hasn't finished
|
|
* empty string or 'delete' means fetching progress hasn't finished
|
|
* show loading animation for such situations
|
|
* show loading animation for such situations
|
|
*/
|
|
*/
|
|
- if (status === '' || status === 'delete') {
|
|
|
|
|
|
+ if (status === IndexState.Default || status === IndexState.Delete) {
|
|
return <StatusIcon type={ChildrenStatusType.CREATING} />;
|
|
return <StatusIcon type={ChildrenStatusType.CREATING} />;
|
|
}
|
|
}
|
|
return status === IndexState.InProgress ? (
|
|
return status === IndexState.InProgress ? (
|