mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-19 15:26:59 +08:00
fix: remove workspace not working (#3140)
(cherry picked from commit ddb2931f38)
This commit is contained in:
@@ -149,3 +149,35 @@ test('windows only check', async ({ page }) => {
|
|||||||
await expect(windowOnlyUI).not.toBeVisible();
|
await expect(windowOnlyUI).not.toBeVisible();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('delete workspace', async ({ page }) => {
|
||||||
|
await page.getByTestId('current-workspace').click();
|
||||||
|
await page.getByTestId('add-or-new-workspace').click();
|
||||||
|
await page.getByTestId('new-workspace').click();
|
||||||
|
await page.getByTestId('create-workspace-default-location-button').click();
|
||||||
|
await page.getByTestId('create-workspace-input').type('Delete Me');
|
||||||
|
await page.getByTestId('create-workspace-create-button').click();
|
||||||
|
await page.getByTestId('create-workspace-continue-button').click();
|
||||||
|
await page.getByTestId('slider-bar-workspace-setting-button').click();
|
||||||
|
await page.getByTestId('current-workspace-label').click();
|
||||||
|
expect(await page.getByTestId('workspace-name-input').inputValue()).toBe(
|
||||||
|
'Delete Me'
|
||||||
|
);
|
||||||
|
const contentElement = await page.getByTestId('setting-modal-content');
|
||||||
|
const boundingBox = await contentElement.boundingBox();
|
||||||
|
if (!boundingBox) {
|
||||||
|
throw new Error('boundingBox is null');
|
||||||
|
}
|
||||||
|
await page.mouse.move(
|
||||||
|
boundingBox.x + boundingBox.width / 2,
|
||||||
|
boundingBox.y + boundingBox.height / 2
|
||||||
|
);
|
||||||
|
await page.mouse.wheel(0, 500);
|
||||||
|
await page.getByTestId('delete-workspace-button').click();
|
||||||
|
await page.getByTestId('delete-workspace-input').type('Delete Me');
|
||||||
|
await page.getByTestId('delete-workspace-confirm-button').click();
|
||||||
|
await page.waitForTimeout(1000);
|
||||||
|
expect(await page.getByTestId('workspace-name').textContent()).toBe(
|
||||||
|
'Demo Workspace'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ export const SettingModal: React.FC<SettingModalProps & SettingProps> = ({
|
|||||||
onAccountSettingClick={onAccountSettingClick}
|
onAccountSettingClick={onAccountSettingClick}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className={settingContent}>
|
<div data-testid="setting-modal-content" className={settingContent}>
|
||||||
<div className="wrapper">
|
<div className="wrapper">
|
||||||
<div className="content">
|
<div className="content">
|
||||||
{activeTab === 'workspace' && workspaceId ? (
|
{activeTab === 'workspace' && workspaceId ? (
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { usePassiveWorkspaceEffect } from '@toeverything/hooks/use-block-suite-workspace';
|
import { usePassiveWorkspaceEffect } from '@toeverything/hooks/use-block-suite-workspace';
|
||||||
|
import { useSetAtom } from 'jotai';
|
||||||
import { Suspense, useCallback } from 'react';
|
import { Suspense, useCallback } from 'react';
|
||||||
|
|
||||||
import { getUIAdapter } from '../../../../adapters/workspace';
|
import { getUIAdapter } from '../../../../adapters/workspace';
|
||||||
|
import { openSettingModalAtom } from '../../../../atoms';
|
||||||
import { useOnTransformWorkspace } from '../../../../hooks/root/use-on-transform-workspace';
|
import { useOnTransformWorkspace } from '../../../../hooks/root/use-on-transform-workspace';
|
||||||
import { useWorkspace } from '../../../../hooks/use-workspace';
|
import { useWorkspace } from '../../../../hooks/use-workspace';
|
||||||
import { useAppHelper } from '../../../../hooks/use-workspaces';
|
import { useAppHelper } from '../../../../hooks/use-workspaces';
|
||||||
@@ -9,15 +11,17 @@ import { useAppHelper } from '../../../../hooks/use-workspaces';
|
|||||||
export const WorkspaceSetting = ({ workspaceId }: { workspaceId: string }) => {
|
export const WorkspaceSetting = ({ workspaceId }: { workspaceId: string }) => {
|
||||||
const workspace = useWorkspace(workspaceId);
|
const workspace = useWorkspace(workspaceId);
|
||||||
usePassiveWorkspaceEffect(workspace.blockSuiteWorkspace);
|
usePassiveWorkspaceEffect(workspace.blockSuiteWorkspace);
|
||||||
|
const setSettingModal = useSetAtom(openSettingModalAtom);
|
||||||
const helper = useAppHelper();
|
const helper = useAppHelper();
|
||||||
|
|
||||||
const { NewSettingsDetail } = getUIAdapter(workspace.flavour);
|
const { NewSettingsDetail } = getUIAdapter(workspace.flavour);
|
||||||
|
|
||||||
const onDeleteWorkspace = useCallback(
|
const onDeleteWorkspace = useCallback(
|
||||||
async (id: string) => {
|
async (id: string) => {
|
||||||
return helper.deleteWorkspace(id);
|
await helper.deleteWorkspace(id);
|
||||||
|
setSettingModal(prev => ({ ...prev, open: false, workspaceId: null }));
|
||||||
},
|
},
|
||||||
[helper]
|
[setSettingModal, helper]
|
||||||
);
|
);
|
||||||
const onTransformWorkspace = useOnTransformWorkspace();
|
const onTransformWorkspace = useOnTransformWorkspace();
|
||||||
|
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ export const WorkspaceLayoutInner: FC<PropsWithChildren> = ({ children }) => {
|
|||||||
setOpenQuickSearchModalAtom(true);
|
setOpenQuickSearchModalAtom(true);
|
||||||
}, [setOpenQuickSearchModalAtom]);
|
}, [setOpenQuickSearchModalAtom]);
|
||||||
|
|
||||||
const [, setOpenSettingModalAtom] = useAtom(openSettingModalAtom);
|
const setOpenSettingModalAtom = useSetAtom(openSettingModalAtom);
|
||||||
|
|
||||||
const handleOpenSettingModal = useCallback(() => {
|
const handleOpenSettingModal = useCallback(() => {
|
||||||
setOpenSettingModalAtom({
|
setOpenSettingModalAtom({
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { WorkspaceSubPath } from '@affine/env/workspace';
|
import { WorkspaceSubPath } from '@affine/env/workspace';
|
||||||
import {
|
import {
|
||||||
|
rootCurrentPageIdAtom,
|
||||||
rootCurrentWorkspaceIdAtom,
|
rootCurrentWorkspaceIdAtom,
|
||||||
rootWorkspacesMetadataAtom,
|
rootWorkspacesMetadataAtom,
|
||||||
} from '@affine/workspace/atom';
|
} from '@affine/workspace/atom';
|
||||||
@@ -124,6 +125,7 @@ export const AllWorkspaceModals = (): ReactElement => {
|
|||||||
const [currentWorkspaceId, setCurrentWorkspaceId] = useAtom(
|
const [currentWorkspaceId, setCurrentWorkspaceId] = useAtom(
|
||||||
rootCurrentWorkspaceIdAtom
|
rootCurrentWorkspaceIdAtom
|
||||||
);
|
);
|
||||||
|
const setCurrentPageId = useSetAtom(rootCurrentPageIdAtom);
|
||||||
const [transitioning, transition] = useTransition();
|
const [transitioning, transition] = useTransition();
|
||||||
const [, setOpenSettingModalAtom] = useAtom(openSettingModalAtom);
|
const [, setOpenSettingModalAtom] = useAtom(openSettingModalAtom);
|
||||||
|
|
||||||
@@ -169,11 +171,17 @@ export const AllWorkspaceModals = (): ReactElement => {
|
|||||||
workspaceId => {
|
workspaceId => {
|
||||||
setOpenWorkspacesModal(false);
|
setOpenWorkspacesModal(false);
|
||||||
setCurrentWorkspaceId(workspaceId);
|
setCurrentWorkspaceId(workspaceId);
|
||||||
|
setCurrentPageId(null);
|
||||||
jumpToSubPath(workspaceId, WorkspaceSubPath.ALL).catch(error => {
|
jumpToSubPath(workspaceId, WorkspaceSubPath.ALL).catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[jumpToSubPath, setCurrentWorkspaceId, setOpenWorkspacesModal]
|
[
|
||||||
|
jumpToSubPath,
|
||||||
|
setCurrentPageId,
|
||||||
|
setCurrentWorkspaceId,
|
||||||
|
setOpenWorkspacesModal,
|
||||||
|
]
|
||||||
)}
|
)}
|
||||||
onClickWorkspaceSetting={handleOpenSettingModal}
|
onClickWorkspaceSetting={handleOpenSettingModal}
|
||||||
onNewWorkspace={useCallback(() => {
|
onNewWorkspace={useCallback(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user