mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
refactor: clean all pages component (#2176)
Co-authored-by: himself65 <himself65@outlook.com>
This commit is contained in:
@@ -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);
|
||||
}}
|
||||
|
||||
@@ -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']()}
|
||||
|
||||
Reference in New Issue
Block a user