refactor: clean all pages component (#2176)

Co-authored-by: himself65 <himself65@outlook.com>
This commit is contained in:
Whitewater
2023-05-04 20:59:16 -07:00
committed by GitHub
parent 2c49c774af
commit 84b36c1d35
32 changed files with 772 additions and 504 deletions

View File

@@ -56,6 +56,12 @@ export const AffineSharePage: FC<ShareMenuProps> = props => {
navigator.clipboard.writeText(sharingUrl);
toast(t['Copied link to clipboard']());
}, [sharingUrl, t]);
const onDisablePublic = useCallback(() => {
setIsPublic(false);
toast('Successfully disabled', {
portal: document.body,
});
}, [setIsPublic]);
return (
<div className={menuItemStyle}>
@@ -104,8 +110,8 @@ export const AffineSharePage: FC<ShareMenuProps> = props => {
{t['Disable Public Link']()}
</StyledDisableButton>
<PublicLinkDisableModal
page={props.currentPage}
open={showDisable}
onConfirmDisable={onDisablePublic}
onClose={() => {
setShowDisable(false);
}}

View File

@@ -1,9 +1,6 @@
import { useAFFiNEI18N } from '@affine/i18n/hooks';
import type { Page } from '@blocksuite/store';
import { useBlockSuiteWorkspacePageIsPublic } from '@toeverything/hooks/use-block-suite-workspace-page-is-public';
import { useCallback } from 'react';
import { Modal, ModalCloseButton, toast } from '../../..';
import { Modal, ModalCloseButton } from '../../..';
import {
StyledButton,
StyledButtonContent,
@@ -14,25 +11,17 @@ import {
} from './style';
export type PublicLinkDisableProps = {
page: Page;
open: boolean;
onConfirmDisable: () => void;
onClose: () => void;
};
export const PublicLinkDisableModal = ({
page,
open,
onConfirmDisable,
onClose,
}: PublicLinkDisableProps) => {
const t = useAFFiNEI18N();
const [, setIsPublic] = useBlockSuiteWorkspacePageIsPublic(page);
const handleDisable = useCallback(() => {
setIsPublic(false);
toast('Successfully disabled', {
portal: document.body,
});
onClose();
}, [onClose, setIsPublic]);
return (
<Modal open={open} onClose={onClose}>
<StyledModalWrapper>
@@ -47,7 +36,10 @@ export const PublicLinkDisableModal = ({
<StyledButton onClick={onClose}>{t['Cancel']()}</StyledButton>
<StyledDangerButton
data-testid="disable-public-link-confirm-button"
onClick={handleDisable}
onClick={() => {
onConfirmDisable();
onClose();
}}
style={{ marginLeft: '24px' }}
>
{t['Disable']()}