mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 05:42:30 +03:00
feat: modify delete workspace flow (#1408)
This commit is contained in:
parent
b3659d6a95
commit
31d2e522eb
@ -2,6 +2,7 @@ import { Button, Input, Modal, ModalCloseButton } from '@affine/component';
|
||||
import { Trans, useTranslation } from '@affine/i18n';
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
import { useBlockSuiteWorkspaceName } from '../../../../../../hooks/use-blocksuite-workspace-name';
|
||||
import {
|
||||
AffineOfficialWorkspace,
|
||||
RemWorkspaceFlavour,
|
||||
@ -28,8 +29,11 @@ export const WorkspaceDeleteModal = ({
|
||||
workspace,
|
||||
onDeleteWorkspace,
|
||||
}: WorkspaceDeleteProps) => {
|
||||
const [workspaceName] = useBlockSuiteWorkspaceName(
|
||||
workspace.blockSuiteWorkspace ?? null
|
||||
);
|
||||
const [deleteStr, setDeleteStr] = useState<string>('');
|
||||
const allowDelete = deleteStr.toLowerCase() === 'delete';
|
||||
const allowDelete = deleteStr === workspaceName;
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleDelete = useCallback(() => {
|
||||
@ -46,7 +50,7 @@ export const WorkspaceDeleteModal = ({
|
||||
<Trans i18nKey="Delete Workspace Description">
|
||||
Deleting (
|
||||
<StyledWorkspaceName>
|
||||
{{ workspace: workspace.blockSuiteWorkspace.meta.name } as any}
|
||||
{{ workspace: workspaceName } as any}
|
||||
</StyledWorkspaceName>
|
||||
) cannot be undone, please proceed with caution. All contents will
|
||||
be lost.
|
||||
@ -57,7 +61,7 @@ export const WorkspaceDeleteModal = ({
|
||||
<Trans i18nKey="Delete Workspace Description2">
|
||||
Deleting (
|
||||
<StyledWorkspaceName>
|
||||
{{ workspace: workspace.blockSuiteWorkspace.meta.name } as any}
|
||||
{{ workspace: workspaceName } as any}
|
||||
</StyledWorkspaceName>
|
||||
) will delete both local and cloud data, this operation cannot be
|
||||
undone, please proceed with caution.
|
||||
@ -68,11 +72,11 @@ export const WorkspaceDeleteModal = ({
|
||||
<Input
|
||||
onChange={setDeleteStr}
|
||||
data-testid="delete-workspace-input"
|
||||
placeholder={t('Delete Workspace placeholder')}
|
||||
placeholder={t('Placeholder of delete workspace')}
|
||||
value={deleteStr}
|
||||
width={284}
|
||||
width={315}
|
||||
height={42}
|
||||
></Input>
|
||||
/>
|
||||
</StyledInputContent>
|
||||
<StyledButtonContent>
|
||||
<Button shape="circle" onClick={onClose}>
|
||||
|
@ -121,7 +121,7 @@
|
||||
"Create Or Import": "Create or Import",
|
||||
"Delete Workspace": "Delete Workspace",
|
||||
"Delete Workspace Description2": "Deleting (<1>{{workspace}}</1>) will delete both local and cloud data, this operation cannot be undone, please proceed with caution.",
|
||||
"Delete Workspace placeholder": "Please type “Delete” to confirm",
|
||||
"Placeholder of delete workspace": "Please type workspace name to confirm",
|
||||
"Leave Workspace": "Leave Workspace",
|
||||
"Leave": "Leave",
|
||||
"Workspace Icon": "Workspace Icon",
|
||||
|
@ -12,7 +12,13 @@ test.describe('Local first delete workspace', () => {
|
||||
}) => {
|
||||
await clickSideBarSettingButton(page);
|
||||
await page.getByTestId('delete-workspace-button').click();
|
||||
await page.getByTestId('delete-workspace-input').type('delete');
|
||||
const workspaceNameDom = await page.getByTestId('workspace-name');
|
||||
const currentWorkspaceName = await workspaceNameDom.evaluate(
|
||||
node => node.textContent
|
||||
);
|
||||
await page
|
||||
.getByTestId('delete-workspace-input')
|
||||
.type(currentWorkspaceName as string);
|
||||
await page.getByTestId('delete-workspace-confirm-button').click();
|
||||
expect(await page.getByTestId('workspace-card').count()).toBe(0);
|
||||
await page.mouse.click(1, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user