-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from zilliztech/compact
add compact dialog
- Loading branch information
Showing
9 changed files
with
120 additions
and
8 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,5 @@ export type IconsType = | |
| 'source' | ||
| 'edit' | ||
| 'database' | ||
| 'uploadFile'; | ||
| 'uploadFile' | ||
| 'compact'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { FC, useContext } from 'react'; | ||
import { Typography, makeStyles, Theme } from '@material-ui/core'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { rootContext } from '@/context'; | ||
import DialogTemplate from '@/components/customDialog/DialogTemplate'; | ||
import { CompactDialogProps } from './Types'; | ||
import { CollectionHttp } from '@/http'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => ({ | ||
desc: { | ||
margin: '8px 0 16px 0', | ||
maxWidth: '500px' | ||
}, | ||
dialog: {}, | ||
})); | ||
|
||
const CompactDialog: FC<CompactDialogProps> = props => { | ||
const { cb, collectionName } = props; | ||
|
||
const classes = useStyles(); | ||
|
||
const { handleCloseDialog } = useContext(rootContext); | ||
const { t: dialogTrans } = useTranslation('dialog'); | ||
const { t: warningTrans } = useTranslation('warning'); | ||
const { t: collectionTrans } = useTranslation('collection'); | ||
const { t: btnTrans } = useTranslation('btn'); | ||
|
||
const handleConfirm = async () => { | ||
await CollectionHttp.compact(collectionName); | ||
|
||
handleCloseDialog(); | ||
cb && cb(); | ||
}; | ||
|
||
const disabled = false; | ||
|
||
return ( | ||
<DialogTemplate | ||
dialogClass={classes.dialog} | ||
title={dialogTrans('compact', { | ||
type: collectionName, | ||
})} | ||
handleClose={handleCloseDialog} | ||
children={ | ||
<> | ||
<Typography variant="body1" component="p" className={classes.desc} dangerouslySetInnerHTML={{ | ||
__html: collectionTrans('compactDialogInfo'), | ||
}}> | ||
</Typography> | ||
</> | ||
} | ||
confirmLabel={btnTrans('confirm')} | ||
handleConfirm={handleConfirm} | ||
confirmDisabled={disabled} | ||
/> | ||
); | ||
}; | ||
|
||
export default CompactDialog; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters