-
Notifications
You must be signed in to change notification settings - Fork 7.2k
fix: update pro modal titles in multiple languages for consistency #7107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule pro
updated
from 8c7626 to 336c7c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
projects/app/src/pageComponents/dataset/list/commercialDatasetTypes.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { DatasetTypeEnum } from '@fastgpt/global/core/dataset/constants'; | ||
| import type { CreateDatasetType } from './CreateModal'; | ||
|
|
||
| /** Web 站点与第三方知识库仅商业版可创建;社区版在新建入口点击后弹出 ProModal。 */ | ||
| export const commercialDatasetTypes: readonly CreateDatasetType[] = [ | ||
| DatasetTypeEnum.websiteDataset, | ||
| DatasetTypeEnum.apiDataset, | ||
| DatasetTypeEnum.feishu, | ||
| DatasetTypeEnum.yuque, | ||
| DatasetTypeEnum.dingtalk | ||
| ]; | ||
|
|
||
| /** 判断是否为商业版专属知识库类型。 */ | ||
| export const isCommercialDatasetType = (type: CreateDatasetType) => | ||
| commercialDatasetTypes.includes(type); | ||
|
|
||
| export type DatasetCreateAction = 'create' | 'proModal'; | ||
|
|
||
| /** | ||
| * 根据商业版状态与知识库类型,决定新建入口的下一步动作。 | ||
| * 社区版点击 Web/第三方类型时返回 proModal,其余情况进入创建弹窗。 | ||
| */ | ||
| export const resolveDatasetCreateAction = ( | ||
| type: CreateDatasetType, | ||
| isPlus?: boolean | ||
| ): DatasetCreateAction => { | ||
| if (!isPlus && isCommercialDatasetType(type)) { | ||
| return 'proModal'; | ||
| } | ||
| return 'create'; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,8 +26,8 @@ import { | |
| } from '@/web/core/dataset/api/collaborator'; | ||
| import { useSystem } from '@fastgpt/web/hooks/useSystem'; | ||
| import { type CreateDatasetType } from '@/pageComponents/dataset/list/CreateModal'; | ||
| import { resolveDatasetCreateAction } from '@/pageComponents/dataset/list/commercialDatasetTypes'; | ||
| import { DatasetTypeEnum } from '@fastgpt/global/core/dataset/constants'; | ||
| import { useToast } from '@fastgpt/web/hooks/useToast'; | ||
| import MyBox from '@fastgpt/web/components/common/MyBox'; | ||
| import { useSystemStore } from '@/web/common/system/useSystemStore'; | ||
| import { | ||
|
|
@@ -36,6 +36,7 @@ import { | |
| normalizeParentId | ||
| } from '@fastgpt/global/common/parentFolder/depth'; | ||
| import { ReadRoleVal } from '@fastgpt/global/support/permission/constant'; | ||
| import ProModal from '@/components/ProTip/ProModal'; | ||
|
|
||
| const EditFolderModal = dynamic( | ||
| () => import('@fastgpt/web/components/common/MyModal/EditFolderModal') | ||
|
|
@@ -67,22 +68,20 @@ const Dataset = () => { | |
| const { feConfigs } = useSystemStore(); | ||
| const maxFolderDepth = feConfigs?.limit?.maxFolderDepth ?? DEFAULT_MAX_FOLDER_DEPTH; | ||
| const canCreateFolder = canCreateSubFolder(parentId, paths, maxFolderDepth); | ||
| const folderDepthLimitTip = t('common:folder_depth_limit_tip'); | ||
| const { toast } = useToast(); | ||
|
|
||
| const [editFolderData, setEditFolderData] = useState<EditFolderFormType>(); | ||
| const [createDatasetType, setCreateDatasetType] = useState<CreateDatasetType>(); | ||
| const [proModalOpen, setProModalOpen] = useState(false); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. proModal 有全局的么,还是得每个地方单独挂载 |
||
|
|
||
| const onSelectDatasetType = useCallback( | ||
| (e: CreateDatasetType) => { | ||
| if (!feConfigs?.isPlus && [DatasetTypeEnum.websiteDataset].includes(e)) { | ||
| return toast({ | ||
| status: 'warning', | ||
| title: t('common:commercial_function_tip') | ||
| }); | ||
| (type: CreateDatasetType) => { | ||
| if (resolveDatasetCreateAction(type, feConfigs?.isPlus) === 'proModal') { | ||
| setProModalOpen(true); | ||
| return; | ||
| } | ||
| setCreateDatasetType(e); | ||
| setCreateDatasetType(type); | ||
| }, | ||
| [t, toast, feConfigs] | ||
| [feConfigs?.isPlus] | ||
| ); | ||
|
|
||
| const RenderSearchInput = useMemo( | ||
|
|
@@ -227,7 +226,7 @@ const Dataset = () => { | |
| icon: FolderIcon, | ||
| label: t('common:Folder'), | ||
| disabled: !canCreateFolder, | ||
| disabledTip: folderDepthLimitTip, | ||
| disabledTip: t('common:folder_depth_limit_tip'), | ||
| onClick: () => setEditFolderData({}) | ||
| } | ||
| ] | ||
|
|
@@ -333,6 +332,9 @@ const Dataset = () => { | |
| parentId={parentId || undefined} | ||
| /> | ||
| )} | ||
| {!feConfigs?.isPlus && ( | ||
| <ProModal isOpen={proModalOpen} onClose={() => setProModalOpen(false)} /> | ||
| )} | ||
| </MyBox> | ||
| ); | ||
| }; | ||
|
|
||
61 changes: 61 additions & 0 deletions
61
projects/app/test/pageComponents/dataset/list/commercialDatasetTypes.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { DatasetTypeEnum } from '@fastgpt/global/core/dataset/constants'; | ||
| import { | ||
| commercialDatasetTypes, | ||
| isCommercialDatasetType, | ||
| resolveDatasetCreateAction | ||
| } from '@/pageComponents/dataset/list/commercialDatasetTypes'; | ||
| import type { CreateDatasetType } from '@/pageComponents/dataset/list/CreateModal'; | ||
|
|
||
| const expectedCommercialTypes: CreateDatasetType[] = [ | ||
| DatasetTypeEnum.websiteDataset, | ||
| DatasetTypeEnum.apiDataset, | ||
| DatasetTypeEnum.feishu, | ||
| DatasetTypeEnum.yuque, | ||
| DatasetTypeEnum.dingtalk | ||
| ]; | ||
|
|
||
| describe('commercialDatasetTypes', () => { | ||
| it('should include all commercial-only dataset create types', () => { | ||
| expect([...commercialDatasetTypes]).toEqual(expectedCommercialTypes); | ||
| }); | ||
| }); | ||
|
|
||
| describe('isCommercialDatasetType', () => { | ||
| it.each(expectedCommercialTypes)('should mark %s as commercial-only', (type) => { | ||
| expect(isCommercialDatasetType(type)).toBe(true); | ||
| }); | ||
|
|
||
| it('should not mark normal dataset as commercial-only', () => { | ||
| expect(isCommercialDatasetType(DatasetTypeEnum.dataset)).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe('resolveDatasetCreateAction', () => { | ||
| it.each(expectedCommercialTypes)( | ||
| 'should open ProModal for %s when team is not commercial edition', | ||
| (type) => { | ||
| expect(resolveDatasetCreateAction(type, false)).toBe('proModal'); | ||
| } | ||
| ); | ||
|
|
||
| it.each(expectedCommercialTypes)( | ||
| 'should treat missing commercial edition flag as community edition for %s', | ||
| (type) => { | ||
| expect(resolveDatasetCreateAction(type, undefined)).toBe('proModal'); | ||
| } | ||
| ); | ||
|
|
||
| it.each(expectedCommercialTypes)( | ||
| 'should allow creating %s when team is commercial edition', | ||
| (type) => { | ||
| expect(resolveDatasetCreateAction(type, true)).toBe('create'); | ||
| } | ||
| ); | ||
|
|
||
| it('should always allow creating normal dataset', () => { | ||
| expect(resolveDatasetCreateAction(DatasetTypeEnum.dataset, false)).toBe('create'); | ||
| expect(resolveDatasetCreateAction(DatasetTypeEnum.dataset, true)).toBe('create'); | ||
| expect(resolveDatasetCreateAction(DatasetTypeEnum.dataset, undefined)).toBe('create'); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确认下,UI 是否需要变更,要跟设计对效果