{
- onClick(key);
+ onWorkspaceSettingClick(key);
}}
- className={clsx(style.sidebarSelectSubItem, {
+ className={clsx(style.sidebarSelectItem, {
active: activeTab === key,
})}
key={key}
- >
- {t[title]()}
-
+ />
);
});
- }, [activeTab, onClick, showBilling, t]);
+ }, [activeTab, onWorkspaceSettingClick, showBilling, t]);
return (
- <>
-
diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/types.ts b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/types.ts
index 6604851b7..d5856e744 100644
--- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/types.ts
+++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/types.ts
@@ -1,9 +1,6 @@
-import type { WorkspaceMetadata } from '@affine/core/modules/workspace';
-
import type { SettingState } from '../../types';
export interface WorkspaceSettingDetailProps {
- workspaceMetadata: WorkspaceMetadata;
onCloseSetting: () => void;
onChangeSettingState: (settingState: SettingState) => void;
}
diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/properties/index.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/properties/index.tsx
index 04ceb3334..c1601fe3b 100644
--- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/properties/index.tsx
+++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/properties/index.tsx
@@ -4,13 +4,12 @@ import { DocPropertyManager } from '@affine/core/components/doc-properties/manag
import { CreatePropertyMenuItems } from '@affine/core/components/doc-properties/menu/create-doc-property';
import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-info';
import type { DocCustomPropertyInfo } from '@affine/core/modules/db';
-import type { WorkspaceMetadata } from '@affine/core/modules/workspace';
+import { WorkspaceService } from '@affine/core/modules/workspace';
import { Trans, useI18n } from '@affine/i18n';
import track from '@affine/track';
-import { FrameworkScope } from '@toeverything/infra';
+import { FrameworkScope, useService } from '@toeverything/infra';
import { useCallback } from 'react';
-import { useWorkspace } from '../../../../../components/hooks/use-workspace';
import * as styles from './styles.css';
const WorkspaceSettingPropertiesMain = () => {
@@ -47,14 +46,10 @@ const WorkspaceSettingPropertiesMain = () => {
);
};
-export const WorkspaceSettingProperties = ({
- workspaceMetadata,
-}: {
- workspaceMetadata: WorkspaceMetadata;
-}) => {
+export const WorkspaceSettingProperties = () => {
const t = useI18n();
- const workspace = useWorkspace(workspaceMetadata);
- const workspaceInfo = useWorkspaceInfo(workspaceMetadata);
+ const workspace = useService(WorkspaceService).workspace;
+ const workspaceInfo = useWorkspaceInfo(workspace);
const title = workspaceInfo?.name || 'untitled';
if (workspace === null) {
diff --git a/packages/frontend/core/src/modules/app-sidebar/views/index.tsx b/packages/frontend/core/src/modules/app-sidebar/views/index.tsx
index f7953a994..12d6d78c5 100644
--- a/packages/frontend/core/src/modules/app-sidebar/views/index.tsx
+++ b/packages/frontend/core/src/modules/app-sidebar/views/index.tsx
@@ -265,11 +265,7 @@ export function FallbackHeaderWithWorkspaceNavigator() {
return (
{currentWorkspace && navigate ? (
-
+
) : (
)}
diff --git a/packages/frontend/core/src/modules/cloud/index.ts b/packages/frontend/core/src/modules/cloud/index.ts
index a6cc96b44..9d6604ec4 100644
--- a/packages/frontend/core/src/modules/cloud/index.ts
+++ b/packages/frontend/core/src/modules/cloud/index.ts
@@ -35,7 +35,8 @@ export type { ServerConfig } from './types';
import { type Framework } from '@toeverything/infra';
-import { DocScope, DocService } from '../doc';
+import { DocScope } from '../doc/scopes/doc';
+import { DocService } from '../doc/services/doc';
import { GlobalCache, GlobalState, GlobalStateService } from '../storage';
import { UrlService } from '../url';
import { WorkspaceScope, WorkspaceService } from '../workspace';
diff --git a/packages/frontend/core/src/modules/db/index.ts b/packages/frontend/core/src/modules/db/index.ts
index 203fff902..5e8a13bc5 100644
--- a/packages/frontend/core/src/modules/db/index.ts
+++ b/packages/frontend/core/src/modules/db/index.ts
@@ -1,6 +1,6 @@
import type { Framework } from '@toeverything/infra';
-import { WorkspaceServerService } from '../cloud';
+import { WorkspaceServerService } from '../cloud/services/workspace-server';
import { WorkspaceScope, WorkspaceService } from '../workspace';
import { WorkspaceDB } from './entities/db';
import { WorkspaceDBTable } from './entities/table';
diff --git a/packages/frontend/core/src/modules/dialogs/constant.ts b/packages/frontend/core/src/modules/dialogs/constant.ts
index 9bb6503bc..caa3365e5 100644
--- a/packages/frontend/core/src/modules/dialogs/constant.ts
+++ b/packages/frontend/core/src/modules/dialogs/constant.ts
@@ -26,11 +26,7 @@ export type GLOBAL_DIALOG_SCHEMA = {
templateMode: DocMode;
snapshotUrl: string;
}) => void;
- setting: (props: {
- activeTab?: SettingTab;
- workspaceMetadata?: WorkspaceMetadata | null;
- scrollAnchor?: string;
- }) => void;
+ setting: (props: { activeTab?: SettingTab; scrollAnchor?: string }) => void;
'sign-in': (props: { server?: string; step?: string }) => void;
'change-password': (props: { server?: string }) => void;
'verify-email': (props: { server?: string; changeEmail?: boolean }) => void;
diff --git a/packages/frontend/core/src/modules/doc/index.ts b/packages/frontend/core/src/modules/doc/index.ts
index 27405acca..d1182d3da 100644
--- a/packages/frontend/core/src/modules/doc/index.ts
+++ b/packages/frontend/core/src/modules/doc/index.ts
@@ -8,7 +8,7 @@ export { DocsService } from './services/docs';
import type { Framework } from '@toeverything/infra';
-import { WorkspaceDBService } from '../db';
+import { WorkspaceDBService } from '../db/services/db';
import { WorkspaceScope, WorkspaceService } from '../workspace';
import { Doc } from './entities/doc';
import { DocPropertyList } from './entities/property-list';
diff --git a/tests/affine-cloud/e2e/workspace.spec.ts b/tests/affine-cloud/e2e/workspace.spec.ts
index b577cf629..86883e920 100644
--- a/tests/affine-cloud/e2e/workspace.spec.ts
+++ b/tests/affine-cloud/e2e/workspace.spec.ts
@@ -58,7 +58,7 @@ test('should have pagination in member list', async ({ page }) => {
);
await openSettingModal(page);
- await openWorkspaceSettingPanel(page, 'test');
+ await openWorkspaceSettingPanel(page);
await page.waitForTimeout(1000);
diff --git a/tests/affine-desktop/e2e/basic.spec.ts b/tests/affine-desktop/e2e/basic.spec.ts
index cf356925a..c0554a99a 100644
--- a/tests/affine-desktop/e2e/basic.spec.ts
+++ b/tests/affine-desktop/e2e/basic.spec.ts
@@ -121,7 +121,7 @@ test('delete workspace', async ({ page }) => {
// });
await page.waitForTimeout(1000);
await clickSideBarSettingButton(page);
- await page.getByTestId('current-workspace-label').click();
+ await page.getByTestId('workspace-list-item-workspace:preference').click();
await expect(page.getByTestId('workspace-name-input')).toHaveValue(
'Delete Me'
);
diff --git a/tests/affine-desktop/e2e/workspace.spec.ts b/tests/affine-desktop/e2e/workspace.spec.ts
index 3820c360c..36a8f596a 100644
--- a/tests/affine-desktop/e2e/workspace.spec.ts
+++ b/tests/affine-desktop/e2e/workspace.spec.ts
@@ -42,7 +42,7 @@ test('export then add', async ({ page, appInfo, workspace }) => {
const newWorkspaceName = 'new-test-name';
// goto workspace setting
- await page.getByTestId('workspace-list-item').click();
+ await page.getByTestId('workspace-list-item-workspace:preference').click();
const input = page.getByTestId('workspace-name-input');
await expect(input).toBeVisible();
diff --git a/tests/affine-local/e2e/local-first-avatar.spec.ts b/tests/affine-local/e2e/local-first-avatar.spec.ts
index 587ab051f..152355fa1 100644
--- a/tests/affine-local/e2e/local-first-avatar.spec.ts
+++ b/tests/affine-local/e2e/local-first-avatar.spec.ts
@@ -24,7 +24,7 @@ test('should create a page with a local first avatar and remove it', async ({
.nth(1)
.click({ position: { x: 10, y: 10 } });
await page.getByTestId('settings-modal-trigger').click();
- await page.getByTestId('current-workspace-label').click();
+ await page.getByTestId('workspace-list-item-workspace:preference').click();
await page
.getByTestId('upload-avatar')
.setInputFiles(ProjectRoot.join('tests', 'fixtures', 'blue.png').value);
@@ -61,7 +61,7 @@ test('should create a page with a local first avatar and remove it', async ({
// Click remove button to remove workspace avatar
await page.getByTestId('settings-modal-trigger').click();
- await page.getByTestId('current-workspace-label').click();
+ await page.getByTestId('workspace-list-item-workspace:preference').click();
await page.getByTestId('workspace-setting-avatar').hover();
await page.getByTestId('workspace-setting-remove-avatar-button').click();
await page.mouse.click(0, 0);
diff --git a/tests/affine-local/e2e/local-first-delete-workspace.spec.ts b/tests/affine-local/e2e/local-first-delete-workspace.spec.ts
index bf3e0c4bc..fffc79b0b 100644
--- a/tests/affine-local/e2e/local-first-delete-workspace.spec.ts
+++ b/tests/affine-local/e2e/local-first-delete-workspace.spec.ts
@@ -26,7 +26,7 @@ test('Create new workspace, then delete it', async ({ page, workspace }) => {
'Test Workspace'
);
await openSettingModal(page);
- await openWorkspaceSettingPanel(page, 'Test Workspace');
+ await openWorkspaceSettingPanel(page);
await page.getByTestId('delete-workspace-button').click();
await expect(
page.locator('.affine-notification-center').first()
@@ -64,7 +64,7 @@ test('Delete last workspace', async ({ page }) => {
node => node.textContent
);
await openSettingModal(page);
- await openWorkspaceSettingPanel(page, currentWorkspaceName as string);
+ await openWorkspaceSettingPanel(page);
await page.getByTestId('delete-workspace-button').click();
await page
.getByTestId('delete-workspace-input')
diff --git a/tests/affine-local/e2e/settings.spec.ts b/tests/affine-local/e2e/settings.spec.ts
index b381098d9..82645a4e2 100644
--- a/tests/affine-local/e2e/settings.spec.ts
+++ b/tests/affine-local/e2e/settings.spec.ts
@@ -10,7 +10,6 @@ import {
openSettingModal,
openShortcutsPanel,
} from '@affine-test/kit/utils/setting';
-import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
import { expect } from '@playwright/test';
test('Open settings modal', async ({ page }) => {
@@ -104,21 +103,3 @@ test('Open experimental features panel', async ({ page }) => {
const settings = page.getByTestId('experimental-settings');
await expect(settings).toBeVisible();
});
-
-test('Different workspace should have different name in the setting panel', async ({
- page,
-}) => {
- await openHomePage(page);
- await waitForEditorLoad(page);
- await createLocalWorkspace({ name: 'New Workspace 2' }, page);
- await createLocalWorkspace({ name: 'New Workspace 3' }, page);
- await openSettingModal(page);
- await page.getByTestId('current-workspace-label').click();
- await expect(page.getByTestId('workspace-name-input')).toHaveValue(
- 'New Workspace 3'
- );
- await page.getByText('New Workspace 2').click();
- await expect(page.getByTestId('workspace-name-input')).toHaveValue(
- 'New Workspace 2'
- );
-});
diff --git a/tests/kit/src/utils/cloud.ts b/tests/kit/src/utils/cloud.ts
index fea3a19bf..7c7992b9f 100644
--- a/tests/kit/src/utils/cloud.ts
+++ b/tests/kit/src/utils/cloud.ts
@@ -282,7 +282,7 @@ export async function loginUserDirectly(
export async function enableCloudWorkspace(page: Page) {
await clickSideBarSettingButton(page);
- await page.getByTestId('current-workspace-label').click();
+ await page.getByTestId('workspace-list-item-workspace:preference').click();
await page.getByTestId('publish-enable-affine-cloud-button').click();
await page.getByTestId('confirm-enable-affine-cloud-button').click();
// wait for upload and delete local workspace
diff --git a/tests/kit/src/utils/properties.ts b/tests/kit/src/utils/properties.ts
index 33cc05843..f5c76a8ca 100644
--- a/tests/kit/src/utils/properties.ts
+++ b/tests/kit/src/utils/properties.ts
@@ -149,9 +149,6 @@ export const expectPropertyOrdering = async (
export const openWorkspaceProperties = async (page: Page) => {
await page.getByTestId('slider-bar-workspace-setting-button').click();
- await page
- .locator('[data-testid="workspace-list-item"] .setting-name')
- .click();
await page.getByTestId('workspace-list-item-workspace:properties').click();
};
diff --git a/tests/kit/src/utils/setting.ts b/tests/kit/src/utils/setting.ts
index b3d4a254c..2fa9301b0 100644
--- a/tests/kit/src/utils/setting.ts
+++ b/tests/kit/src/utils/setting.ts
@@ -38,11 +38,11 @@ export async function confirmExperimentalPrompt(page: Page) {
await page.getByTestId('experimental-confirm-button').click();
}
-export async function openWorkspaceSettingPanel(
- page: Page,
- workspaceName: string
-) {
- await page.getByTestId('settings-sidebar').getByText(workspaceName).click();
+export async function openWorkspaceSettingPanel(page: Page) {
+ await page
+ .getByTestId('settings-sidebar')
+ .getByTestId('workspace-list-item-workspace:preference')
+ .click();
}
export async function clickUserInfoCard(page: Page) {