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