mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-08 20:57:08 +08:00
refactor(core): indexer & embedding -> embedding (#12387)
### TL;DR refactor: rename settings, indexer embedding -> embedding <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Unified naming in workspace settings from "Indexer & Embedding" to "Embedding" for improved clarity. - Updated sidebar labels, tab keys, and test IDs to reflect the new naming convention. - Streamlined the layout and organization of the embedding settings interface for a more consistent user experience. - Simplified the export and component structure for embedding settings. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -2,7 +2,7 @@ import { useWorkspaceInfo } from '@affine/core/components/hooks/use-workspace-in
|
|||||||
import { ServerService } from '@affine/core/modules/cloud';
|
import { ServerService } from '@affine/core/modules/cloud';
|
||||||
import type { SettingTab } from '@affine/core/modules/dialogs/constant';
|
import type { SettingTab } from '@affine/core/modules/dialogs/constant';
|
||||||
import { WorkspaceService } from '@affine/core/modules/workspace';
|
import { WorkspaceService } from '@affine/core/modules/workspace';
|
||||||
import { IndexerEmbeddingSettings } from '@affine/core/modules/workspace-indexer-embedding';
|
import { EmbeddingSettings } from '@affine/core/modules/workspace-indexer-embedding';
|
||||||
import { ServerDeploymentType } from '@affine/graphql';
|
import { ServerDeploymentType } from '@affine/graphql';
|
||||||
import { useI18n } from '@affine/i18n';
|
import { useI18n } from '@affine/i18n';
|
||||||
import {
|
import {
|
||||||
@@ -54,8 +54,8 @@ export const WorkspaceSetting = ({
|
|||||||
return <WorkspaceSettingLicense onCloseSetting={onCloseSetting} />;
|
return <WorkspaceSettingLicense onCloseSetting={onCloseSetting} />;
|
||||||
case 'workspace:integrations':
|
case 'workspace:integrations':
|
||||||
return <IntegrationSetting />;
|
return <IntegrationSetting />;
|
||||||
case 'workspace:indexer-embedding':
|
case 'workspace:embedding':
|
||||||
return <IndexerEmbeddingSettings />;
|
return <EmbeddingSettings />;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -110,10 +110,13 @@ export const useWorkspaceSettingList = (): SettingSidebarItem[] => {
|
|||||||
testId: 'workspace-setting:storage',
|
testId: 'workspace-setting:storage',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'workspace:indexer-embedding',
|
key: 'workspace:embedding',
|
||||||
title: t['Indexer & Embedding'](),
|
title:
|
||||||
|
t[
|
||||||
|
'com.affine.settings.workspace.indexer-embedding.embedding.title'
|
||||||
|
](),
|
||||||
icon: <SettingsIcon />,
|
icon: <SettingsIcon />,
|
||||||
testId: 'workspace-setting:indexer-embedding',
|
testId: 'workspace-setting:embedding',
|
||||||
},
|
},
|
||||||
showBilling && {
|
showBilling && {
|
||||||
key: 'workspace:billing' as SettingTab,
|
key: 'workspace:billing' as SettingTab,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export type SettingTab =
|
|||||||
| 'editor'
|
| 'editor'
|
||||||
| 'account'
|
| 'account'
|
||||||
| 'meetings'
|
| 'meetings'
|
||||||
| `workspace:${'preference' | 'properties' | 'members' | 'storage' | 'billing' | 'license' | 'integrations' | 'indexer-embedding' | 'search'}`;
|
| `workspace:${'preference' | 'properties' | 'members' | 'storage' | 'billing' | 'license' | 'integrations' | 'embedding' | 'search'}`;
|
||||||
|
|
||||||
export type GLOBAL_DIALOG_SCHEMA = {
|
export type GLOBAL_DIALOG_SCHEMA = {
|
||||||
'create-workspace': (props: { serverId?: string }) => {
|
'create-workspace': (props: { serverId?: string }) => {
|
||||||
|
|||||||
@@ -17,4 +17,4 @@ export function configureIndexerEmbeddingModule(framework: Framework) {
|
|||||||
.entity(Embedding, [WorkspaceService, EmbeddingStore]);
|
.entity(Embedding, [WorkspaceService, EmbeddingStore]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { IndexerEmbeddingSettings } from './view';
|
export { EmbeddingSettings } from './view';
|
||||||
|
|||||||
+77
-77
@@ -1,5 +1,6 @@
|
|||||||
import { Button, Switch } from '@affine/component';
|
import { Button, Switch } from '@affine/component';
|
||||||
import {
|
import {
|
||||||
|
SettingHeader,
|
||||||
SettingRow,
|
SettingRow,
|
||||||
SettingWrapper,
|
SettingWrapper,
|
||||||
} from '@affine/component/setting-components';
|
} from '@affine/component/setting-components';
|
||||||
@@ -94,86 +95,85 @@ export const EmbeddingSettings: React.FC<EmbeddingSettingsProps> = () => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingWrapper
|
<>
|
||||||
title={t[
|
<SettingHeader
|
||||||
'com.affine.settings.workspace.indexer-embedding.embedding.title'
|
title={t[
|
||||||
]()}
|
'com.affine.settings.workspace.indexer-embedding.embedding.title'
|
||||||
testId="workspace-embedding-setting-wrapper"
|
]()}
|
||||||
>
|
subtitle={t[
|
||||||
<SettingRow
|
|
||||||
name=""
|
|
||||||
desc={t[
|
|
||||||
'com.affine.settings.workspace.indexer-embedding.embedding.description'
|
'com.affine.settings.workspace.indexer-embedding.embedding.description'
|
||||||
]()}
|
]()}
|
||||||
></SettingRow>
|
/>
|
||||||
<SettingRow
|
<SettingWrapper title={''} testId="workspace-embedding-setting-wrapper">
|
||||||
name={t[
|
<SettingRow
|
||||||
'com.affine.settings.workspace.indexer-embedding.embedding.switch.title'
|
name={t[
|
||||||
]()}
|
'com.affine.settings.workspace.indexer-embedding.embedding.switch.title'
|
||||||
desc={t[
|
|
||||||
'com.affine.settings.workspace.indexer-embedding.embedding.switch.description'
|
|
||||||
]()}
|
|
||||||
>
|
|
||||||
<Switch
|
|
||||||
data-testid="workspace-embedding-setting-switch"
|
|
||||||
checked={embeddingEnabled}
|
|
||||||
onChange={handleEmbeddingToggle}
|
|
||||||
/>
|
|
||||||
</SettingRow>
|
|
||||||
|
|
||||||
<SettingRow
|
|
||||||
name={t[
|
|
||||||
'com.affine.settings.workspace.indexer-embedding.embedding.additional-attachments.title'
|
|
||||||
]()}
|
|
||||||
desc={t[
|
|
||||||
'com.affine.settings.workspace.indexer-embedding.embedding.additional-attachments.description'
|
|
||||||
]()}
|
|
||||||
>
|
|
||||||
<Upload fileChange={handleAttachmentUpload}>
|
|
||||||
<Button
|
|
||||||
data-testid="workspace-embedding-setting-upload-button"
|
|
||||||
variant="primary"
|
|
||||||
>
|
|
||||||
{t['Upload']()}
|
|
||||||
</Button>
|
|
||||||
</Upload>
|
|
||||||
</SettingRow>
|
|
||||||
|
|
||||||
{attachmentNodes.length > 0 && (
|
|
||||||
<Attachments
|
|
||||||
attachments={attachmentNodes}
|
|
||||||
isLoading={isAttachmentsLoading}
|
|
||||||
onDelete={handleAttachmentsDelete}
|
|
||||||
totalCount={attachments.totalCount}
|
|
||||||
onPageChange={handleAttachmentsPageChange}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<SettingRow
|
|
||||||
name={t[
|
|
||||||
'com.affine.settings.workspace.indexer-embedding.embedding.ignore-docs.title'
|
|
||||||
]()}
|
|
||||||
desc={t[
|
|
||||||
'com.affine.settings.workspace.indexer-embedding.embedding.ignore-docs.description'
|
|
||||||
]()}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
data-testid="workspace-embedding-setting-ignore-docs-button"
|
|
||||||
variant="primary"
|
|
||||||
onClick={handleSelectDoc}
|
|
||||||
>
|
|
||||||
{t[
|
|
||||||
'com.affine.settings.workspace.indexer-embedding.embedding.select-doc'
|
|
||||||
]()}
|
]()}
|
||||||
</Button>
|
desc={t[
|
||||||
</SettingRow>
|
'com.affine.settings.workspace.indexer-embedding.embedding.switch.description'
|
||||||
|
]()}
|
||||||
|
>
|
||||||
|
<Switch
|
||||||
|
data-testid="workspace-embedding-setting-switch"
|
||||||
|
checked={embeddingEnabled}
|
||||||
|
onChange={handleEmbeddingToggle}
|
||||||
|
/>
|
||||||
|
</SettingRow>
|
||||||
|
|
||||||
{ignoredDocNodes.length > 0 && (
|
<SettingRow
|
||||||
<IgnoredDocs
|
name={t[
|
||||||
ignoredDocs={ignoredDocNodes}
|
'com.affine.settings.workspace.indexer-embedding.embedding.additional-attachments.title'
|
||||||
isLoading={isIgnoredDocsLoading}
|
]()}
|
||||||
/>
|
desc={t[
|
||||||
)}
|
'com.affine.settings.workspace.indexer-embedding.embedding.additional-attachments.description'
|
||||||
</SettingWrapper>
|
]()}
|
||||||
|
>
|
||||||
|
<Upload fileChange={handleAttachmentUpload}>
|
||||||
|
<Button
|
||||||
|
data-testid="workspace-embedding-setting-upload-button"
|
||||||
|
variant="primary"
|
||||||
|
>
|
||||||
|
{t['Upload']()}
|
||||||
|
</Button>
|
||||||
|
</Upload>
|
||||||
|
</SettingRow>
|
||||||
|
|
||||||
|
{attachmentNodes.length > 0 && (
|
||||||
|
<Attachments
|
||||||
|
attachments={attachmentNodes}
|
||||||
|
isLoading={isAttachmentsLoading}
|
||||||
|
onDelete={handleAttachmentsDelete}
|
||||||
|
totalCount={attachments.totalCount}
|
||||||
|
onPageChange={handleAttachmentsPageChange}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<SettingRow
|
||||||
|
name={t[
|
||||||
|
'com.affine.settings.workspace.indexer-embedding.embedding.ignore-docs.title'
|
||||||
|
]()}
|
||||||
|
desc={t[
|
||||||
|
'com.affine.settings.workspace.indexer-embedding.embedding.ignore-docs.description'
|
||||||
|
]()}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
data-testid="workspace-embedding-setting-ignore-docs-button"
|
||||||
|
variant="primary"
|
||||||
|
onClick={handleSelectDoc}
|
||||||
|
>
|
||||||
|
{t[
|
||||||
|
'com.affine.settings.workspace.indexer-embedding.embedding.select-doc'
|
||||||
|
]()}
|
||||||
|
</Button>
|
||||||
|
</SettingRow>
|
||||||
|
|
||||||
|
{ignoredDocNodes.length > 0 && (
|
||||||
|
<IgnoredDocs
|
||||||
|
ignoredDocs={ignoredDocNodes}
|
||||||
|
isLoading={isIgnoredDocsLoading}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</SettingWrapper>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,22 +1 @@
|
|||||||
import { SettingHeader } from '@affine/component/setting-components';
|
export { EmbeddingSettings } from './embedding-settings';
|
||||||
import { useI18n } from '@affine/i18n';
|
|
||||||
import type React from 'react';
|
|
||||||
|
|
||||||
import { EmbeddingSettings } from './embedding-settings';
|
|
||||||
|
|
||||||
export const IndexerEmbeddingSettings: React.FC = () => {
|
|
||||||
const t = useI18n();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<SettingHeader
|
|
||||||
title={t['com.affine.settings.workspace.indexer-embedding.title']()}
|
|
||||||
subtitle={t[
|
|
||||||
'com.affine.settings.workspace.indexer-embedding.description'
|
|
||||||
]()}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<EmbeddingSettings />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ const WORKSPACE_EMBEDDING_SWITCH_TEST_ID = 'workspace-embedding-setting-switch';
|
|||||||
|
|
||||||
export class SettingsPanelUtils {
|
export class SettingsPanelUtils {
|
||||||
public static async openSettingsPanel(page: Page) {
|
public static async openSettingsPanel(page: Page) {
|
||||||
if (
|
if (await page.getByTestId('workspace-setting:embedding').isHidden()) {
|
||||||
await page.getByTestId('workspace-setting:indexer-embedding').isHidden()
|
|
||||||
) {
|
|
||||||
await page.getByTestId('slider-bar-workspace-setting-button').click();
|
await page.getByTestId('slider-bar-workspace-setting-button').click();
|
||||||
await page.getByTestId('workspace-setting:indexer-embedding').click();
|
await page.getByTestId('workspace-setting:embedding').click();
|
||||||
await page.getByTestId('workspace-embedding-setting-wrapper').waitFor({
|
await page.getByTestId('workspace-embedding-setting-wrapper').waitFor({
|
||||||
state: 'visible',
|
state: 'visible',
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user