-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add batch tag add / remove actions, minor dialog cleanup
- Loading branch information
Showing
29 changed files
with
1,088 additions
and
401 deletions.
There are no files selected for viewing
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
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,85 @@ | ||
import {WarningOutlineIcon} from '@sanity/icons' | ||
import {Box, Button, Dialog, Flex, Stack, Text} from '@sanity/ui' | ||
import {DialogConfirm} from '@types' | ||
import React, {FC, ReactNode} from 'react' | ||
import {useDispatch} from 'react-redux' | ||
|
||
import {dialogRemove} from '../../modules/dialog' | ||
|
||
type Props = { | ||
children?: ReactNode | ||
dialog: DialogConfirm | ||
} | ||
|
||
const DialogConfirm: FC<Props> = (props: Props) => { | ||
const {children, dialog} = props | ||
|
||
// Redux | ||
const dispatch = useDispatch() | ||
|
||
// Callbacks | ||
const handleClose = () => { | ||
dispatch(dialogRemove(dialog?.id)) | ||
} | ||
|
||
const handleConfirm = () => { | ||
// Close target dialog, if provided | ||
if (dialog?.closeDialogId) { | ||
dispatch(dialogRemove(dialog?.closeDialogId)) | ||
} | ||
|
||
if (dialog?.confirmCallbackAction) { | ||
dispatch(dialog.confirmCallbackAction) | ||
} | ||
|
||
// Close self | ||
handleClose() | ||
} | ||
|
||
const Footer = () => ( | ||
<Box padding={3}> | ||
<Flex justify="space-between"> | ||
<Button fontSize={1} mode="bleed" onClick={handleClose} text="Cancel" /> | ||
<Button | ||
fontSize={1} | ||
onClick={handleConfirm} | ||
text={dialog?.confirmText} | ||
tone={dialog?.tone} | ||
/> | ||
</Flex> | ||
</Box> | ||
) | ||
|
||
const Header = () => ( | ||
<Flex align="center"> | ||
<Box paddingX={1}> | ||
<WarningOutlineIcon /> | ||
</Box> | ||
<Box marginLeft={2}>{dialog?.title}</Box> | ||
</Flex> | ||
) | ||
|
||
return ( | ||
<Dialog | ||
footer={<Footer />} | ||
header={<Header />} | ||
id="confirm" | ||
onClose={handleClose} | ||
scheme="dark" | ||
width={1} | ||
> | ||
<Box paddingX={4} paddingY={4}> | ||
<Stack space={3}> | ||
{dialog?.description && <Text size={1}>{dialog.description}</Text>} | ||
<Text muted size={1}> | ||
<em>This operation cannot be reversed. Are you sure you want to continue?</em> | ||
</Text> | ||
</Stack> | ||
</Box> | ||
|
||
{children} | ||
</Dialog> | ||
) | ||
} | ||
|
||
export default DialogConfirm |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.