mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 05:14:54 +00: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 type { SettingTab } from '@affine/core/modules/dialogs/constant';
|
||||
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 { useI18n } from '@affine/i18n';
|
||||
import {
|
||||
@@ -54,8 +54,8 @@ export const WorkspaceSetting = ({
|
||||
return <WorkspaceSettingLicense onCloseSetting={onCloseSetting} />;
|
||||
case 'workspace:integrations':
|
||||
return <IntegrationSetting />;
|
||||
case 'workspace:indexer-embedding':
|
||||
return <IndexerEmbeddingSettings />;
|
||||
case 'workspace:embedding':
|
||||
return <EmbeddingSettings />;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -110,10 +110,13 @@ export const useWorkspaceSettingList = (): SettingSidebarItem[] => {
|
||||
testId: 'workspace-setting:storage',
|
||||
},
|
||||
{
|
||||
key: 'workspace:indexer-embedding',
|
||||
title: t['Indexer & Embedding'](),
|
||||
key: 'workspace:embedding',
|
||||
title:
|
||||
t[
|
||||
'com.affine.settings.workspace.indexer-embedding.embedding.title'
|
||||
](),
|
||||
icon: <SettingsIcon />,
|
||||
testId: 'workspace-setting:indexer-embedding',
|
||||
testId: 'workspace-setting:embedding',
|
||||
},
|
||||
showBilling && {
|
||||
key: 'workspace:billing' as SettingTab,
|
||||
|
||||
@@ -14,7 +14,7 @@ export type SettingTab =
|
||||
| 'editor'
|
||||
| 'account'
|
||||
| '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 = {
|
||||
'create-workspace': (props: { serverId?: string }) => {
|
||||
|
||||
@@ -17,4 +17,4 @@ export function configureIndexerEmbeddingModule(framework: Framework) {
|
||||
.entity(Embedding, [WorkspaceService, EmbeddingStore]);
|
||||
}
|
||||
|
||||
export { IndexerEmbeddingSettings } from './view';
|
||||
export { EmbeddingSettings } from './view';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Button, Switch } from '@affine/component';
|
||||
import {
|
||||
SettingHeader,
|
||||
SettingRow,
|
||||
SettingWrapper,
|
||||
} from '@affine/component/setting-components';
|
||||
@@ -94,86 +95,85 @@ export const EmbeddingSettings: React.FC<EmbeddingSettingsProps> = () => {
|
||||
]);
|
||||
|
||||
return (
|
||||
<SettingWrapper
|
||||
title={t[
|
||||
'com.affine.settings.workspace.indexer-embedding.embedding.title'
|
||||
]()}
|
||||
testId="workspace-embedding-setting-wrapper"
|
||||
>
|
||||
<SettingRow
|
||||
name=""
|
||||
desc={t[
|
||||
<>
|
||||
<SettingHeader
|
||||
title={t[
|
||||
'com.affine.settings.workspace.indexer-embedding.embedding.title'
|
||||
]()}
|
||||
subtitle={t[
|
||||
'com.affine.settings.workspace.indexer-embedding.embedding.description'
|
||||
]()}
|
||||
></SettingRow>
|
||||
<SettingRow
|
||||
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'
|
||||
/>
|
||||
<SettingWrapper title={''} testId="workspace-embedding-setting-wrapper">
|
||||
<SettingRow
|
||||
name={t[
|
||||
'com.affine.settings.workspace.indexer-embedding.embedding.switch.title'
|
||||
]()}
|
||||
</Button>
|
||||
</SettingRow>
|
||||
desc={t[
|
||||
'com.affine.settings.workspace.indexer-embedding.embedding.switch.description'
|
||||
]()}
|
||||
>
|
||||
<Switch
|
||||
data-testid="workspace-embedding-setting-switch"
|
||||
checked={embeddingEnabled}
|
||||
onChange={handleEmbeddingToggle}
|
||||
/>
|
||||
</SettingRow>
|
||||
|
||||
{ignoredDocNodes.length > 0 && (
|
||||
<IgnoredDocs
|
||||
ignoredDocs={ignoredDocNodes}
|
||||
isLoading={isIgnoredDocsLoading}
|
||||
/>
|
||||
)}
|
||||
</SettingWrapper>
|
||||
<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>
|
||||
</SettingRow>
|
||||
|
||||
{ignoredDocNodes.length > 0 && (
|
||||
<IgnoredDocs
|
||||
ignoredDocs={ignoredDocNodes}
|
||||
isLoading={isIgnoredDocsLoading}
|
||||
/>
|
||||
)}
|
||||
</SettingWrapper>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,22 +1 @@
|
||||
import { SettingHeader } from '@affine/component/setting-components';
|
||||
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 />
|
||||
</>
|
||||
);
|
||||
};
|
||||
export { EmbeddingSettings } from './embedding-settings';
|
||||
|
||||
Reference in New Issue
Block a user