Commit bf5502c5 by DigHuang Committed by GitHub

feat(chat): show agent v2 in team app filters (#7274)

parent 2449f981
import React, { useRef } from 'react'; import React, { useMemo } from 'react';
import { AppTypeEnum } from '@fastgpt/global/core/app/constants'; import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
import MyIcon from '@fastgpt/web/components/common/Icon'; import MyIcon from '@fastgpt/web/components/common/Icon';
import { Box, Flex } from '@chakra-ui/react'; import { Box, Flex } from '@chakra-ui/react';
...@@ -7,55 +7,58 @@ import { useTranslation } from 'next-i18next'; ...@@ -7,55 +7,58 @@ import { useTranslation } from 'next-i18next';
const AppTypeTag = ({ type }: { type: AppTypeEnum }) => { const AppTypeTag = ({ type }: { type: AppTypeEnum }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const map = useRef({ const map = useMemo(
[AppTypeEnum.chatAgent]: { () => ({
label: 'Agent', [AppTypeEnum.chatAgent]: {
icon: 'core/app/type/simple', label: t('app:type.Chat_Agent_v2'),
bg: '#DBF3FF', icon: 'core/app/type/simple',
color: '#0884DD' bg: '#DBF3FF',
}, color: '#0884DD'
[AppTypeEnum.simple]: { },
label: t('app:type.Chat_Agent'), [AppTypeEnum.simple]: {
icon: 'core/app/type/simple', label: t('app:type.Chat_Agent'),
bg: '#DBF3FF', icon: 'core/app/type/simple',
color: '#0884DD' bg: '#DBF3FF',
}, color: '#0884DD'
[AppTypeEnum.workflow]: { },
label: t('app:type.Workflow bot'), [AppTypeEnum.workflow]: {
icon: 'core/app/type/workflow', label: t('app:type.Workflow bot'),
bg: '#E4E1FC', icon: 'core/app/type/workflow',
color: '#6F5DD7' bg: '#E4E1FC',
}, color: '#6F5DD7'
[AppTypeEnum.workflowTool]: { },
label: t('app:toolType_workflow'), [AppTypeEnum.workflowTool]: {
icon: 'core/app/type/plugin', label: t('app:toolType_workflow'),
bg: '#D0F5EE', icon: 'core/app/type/plugin',
color: '#007E7C' bg: '#D0F5EE',
}, color: '#007E7C'
[AppTypeEnum.httpPlugin]: { },
label: t('account_team:type.Http plugin'), [AppTypeEnum.httpPlugin]: {
icon: 'core/app/type/httpPlugin', label: t('account_team:type.Http plugin'),
bg: '#FFE4EE', icon: 'core/app/type/httpPlugin',
color: '#E82F72' bg: '#FFE4EE',
}, color: '#E82F72'
[AppTypeEnum.httpToolSet]: { },
label: t('app:toolType_http'), [AppTypeEnum.httpToolSet]: {
icon: 'core/app/type/httpPlugin', label: t('app:toolType_http'),
bg: '#FFE4EE', icon: 'core/app/type/httpPlugin',
color: '#E82F72' bg: '#FFE4EE',
}, color: '#E82F72'
[AppTypeEnum.mcpToolSet]: { },
label: t('app:toolType_mcp'), [AppTypeEnum.mcpToolSet]: {
icon: 'core/app/type/mcpTools', label: t('app:toolType_mcp'),
bg: '', icon: 'core/app/type/mcpTools',
color: '' bg: '',
}, color: ''
[AppTypeEnum.tool]: undefined, },
[AppTypeEnum.folder]: undefined, [AppTypeEnum.tool]: undefined,
[AppTypeEnum.hidden]: undefined [AppTypeEnum.folder]: undefined,
}); [AppTypeEnum.hidden]: undefined
}),
[t]
);
const data = map.current[type as keyof typeof map.current]; const data = map[type as keyof typeof map];
return data ? ( return data ? (
<Flex <Flex
...@@ -69,9 +72,7 @@ const AppTypeTag = ({ type }: { type: AppTypeEnum }) => { ...@@ -69,9 +72,7 @@ const AppTypeTag = ({ type }: { type: AppTypeEnum }) => {
whiteSpace={'nowrap'} whiteSpace={'nowrap'}
> >
<MyIcon name={data.icon as any} w={'0.8rem'} color={'myGray.500'} /> <MyIcon name={data.icon as any} w={'0.8rem'} color={'myGray.500'} />
<Box fontSize={'mini'}> <Box fontSize={'mini'}>{data.label}</Box>
{data.label}
</Box>
</Flex> </Flex>
) : null; ) : null;
}; };
......
...@@ -46,7 +46,7 @@ const MyApps = ({ hideMobileHeader = false, mobileSearchKey }: MyAppsProps) => { ...@@ -46,7 +46,7 @@ const MyApps = ({ hideMobileHeader = false, mobileSearchKey }: MyAppsProps) => {
const map = useMemo( const map = useMemo(
() => ({ () => ({
all: t('common:core.module.template.all_team_app'), all: t('common:core.module.template.all_team_app'),
[AppTypeEnum.chatAgent]: 'Agent', [AppTypeEnum.chatAgent]: t('app:type.Chat_Agent_v2'),
[AppTypeEnum.simple]: t('app:type.Chat_Agent'), [AppTypeEnum.simple]: t('app:type.Chat_Agent'),
[AppTypeEnum.workflow]: t('app:type.Workflow bot'), [AppTypeEnum.workflow]: t('app:type.Workflow bot'),
[AppTypeEnum.workflowTool]: t('app:toolType_workflow'), [AppTypeEnum.workflowTool]: t('app:toolType_workflow'),
...@@ -61,7 +61,13 @@ const MyApps = ({ hideMobileHeader = false, mobileSearchKey }: MyAppsProps) => { ...@@ -61,7 +61,13 @@ const MyApps = ({ hideMobileHeader = false, mobileSearchKey }: MyAppsProps) => {
); );
const [appType, setAppType] = useState<AppTypeEnum | 'all'>('all'); const [appType, setAppType] = useState<AppTypeEnum | 'all'>('all');
const tabs = ['all' as const, AppTypeEnum.simple, AppTypeEnum.workflow, AppTypeEnum.workflowTool]; const tabs = [
'all' as const,
AppTypeEnum.chatAgent,
AppTypeEnum.simple,
AppTypeEnum.workflow,
AppTypeEnum.workflowTool
];
return ( return (
<Flex flexDirection={'column'} h={'100%'}> <Flex flexDirection={'column'} h={'100%'}>
......
...@@ -35,6 +35,7 @@ export const resolveDashboardAppListTypes = ({ ...@@ -35,6 +35,7 @@ export const resolveDashboardAppListTypes = ({
return [ return [
AppTypeEnum.folder, AppTypeEnum.folder,
AppTypeEnum.toolFolder, AppTypeEnum.toolFolder,
AppTypeEnum.chatAgent,
AppTypeEnum.simple, AppTypeEnum.simple,
AppTypeEnum.workflow, AppTypeEnum.workflow,
AppTypeEnum.workflowTool AppTypeEnum.workflowTool
......
...@@ -35,4 +35,20 @@ describe('resolveDashboardAppListTypes', () => { ...@@ -35,4 +35,20 @@ describe('resolveDashboardAppListTypes', () => {
}) })
).toEqual([AppTypeEnum.folder, AppTypeEnum.workflow]); ).toEqual([AppTypeEnum.folder, AppTypeEnum.workflow]);
}); });
it('should include chat agent v2 apps in the chat app list', () => {
expect(
resolveDashboardAppListTypes({
pathname: '/chat',
type: 'all'
})
).toEqual([
AppTypeEnum.folder,
AppTypeEnum.toolFolder,
AppTypeEnum.chatAgent,
AppTypeEnum.simple,
AppTypeEnum.workflow,
AppTypeEnum.workflowTool
]);
});
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment