filter tool type version & fix unpublished version (#4803)

This commit is contained in:
heheer
2025-05-13 17:58:51 +08:00
committed by GitHub
parent 398d131bac
commit 3688842cc7
4 changed files with 57 additions and 54 deletions

View File

@@ -22,8 +22,7 @@ import {
import { type PluginRuntimeType } from '@fastgpt/global/core/plugin/type'; import { type PluginRuntimeType } from '@fastgpt/global/core/plugin/type';
import { MongoSystemPlugin } from './systemPluginSchema'; import { MongoSystemPlugin } from './systemPluginSchema';
import { PluginErrEnum } from '@fastgpt/global/common/error/code/plugin'; import { PluginErrEnum } from '@fastgpt/global/common/error/code/plugin';
import { MongoAppVersion } from '../version/schema'; import { Types } from 'mongoose';
import { i18nT } from '../../../../web/i18n/utils';
/* /*
plugin id rule: plugin id rule:
@@ -111,19 +110,13 @@ export async function getChildAppPreviewNode({
const version = await getAppVersionById({ appId, versionId, app: item }); const version = await getAppVersionById({ appId, versionId, app: item });
if (!version.versionId) return Promise.reject(i18nT('common:app_not_version')); const isLatest =
version.versionId && Types.ObjectId.isValid(version.versionId)
const versionData = await MongoAppVersion.findById( ? await checkIsLatestVersion({
version.versionId, appId,
'_id versionName appId time' versionId: version.versionId
).lean(); })
: true;
const isLatest = versionData
? await checkIsLatestVersion({
appId,
versionId: versionData._id
})
: true;
return { return {
id: String(item._id), id: String(item._id),
@@ -140,7 +133,7 @@ export async function getChildAppPreviewNode({
templateType: FlowNodeTemplateTypeEnum.teamApp, templateType: FlowNodeTemplateTypeEnum.teamApp,
version: version.versionId, version: version.versionId,
versionLabel: versionData?.versionName || '', versionLabel: version?.versionName || '',
isLatestVersion: isLatest, isLatestVersion: isLatest,
originCost: 0, originCost: 0,

View File

@@ -15,6 +15,7 @@ export const getAppLatestVersion = async (appId: string, app?: AppSchema) => {
if (version) { if (version) {
return { return {
versionId: version._id, versionId: version._id,
versionName: version.versionName,
nodes: version.nodes, nodes: version.nodes,
edges: version.edges, edges: version.edges,
chatConfig: version.chatConfig || app?.chatConfig || {} chatConfig: version.chatConfig || app?.chatConfig || {}
@@ -22,6 +23,7 @@ export const getAppLatestVersion = async (appId: string, app?: AppSchema) => {
} }
return { return {
versionId: app?.pluginData?.nodeVersion, versionId: app?.pluginData?.nodeVersion,
versionName: app?.name,
nodes: app?.modules || [], nodes: app?.modules || [],
edges: app?.edges || [], edges: app?.edges || [],
chatConfig: app?.chatConfig || {} chatConfig: app?.chatConfig || {}
@@ -47,6 +49,7 @@ export const getAppVersionById = async ({
if (version) { if (version) {
return { return {
versionId: version._id, versionId: version._id,
versionName: version.versionName,
nodes: version.nodes, nodes: version.nodes,
edges: version.edges, edges: version.edges,
chatConfig: version.chatConfig || app?.chatConfig || {} chatConfig: version.chatConfig || app?.chatConfig || {}

View File

@@ -24,6 +24,7 @@ import { useRequest2 } from '../../../hooks/useRequest';
import MyDivider from '../MyDivider'; import MyDivider from '../MyDivider';
import type { useScrollPagination } from '../../../hooks/useScrollPagination'; import type { useScrollPagination } from '../../../hooks/useScrollPagination';
import Avatar from '../Avatar'; import Avatar from '../Avatar';
import EmptyTip from '../EmptyTip';
/** 选择组件 Props 类型 /** 选择组件 Props 类型
* value: 选中的值 * value: 选中的值
@@ -141,43 +142,49 @@ const MySelect = <T = any,>(
const ListRender = useMemo(() => { const ListRender = useMemo(() => {
return ( return (
<> <>
{filterList.map((item, i) => ( {filterList.length > 0 ? (
<Box key={i}> filterList.map((item, i) => (
<MenuItem <Box key={i}>
{...menuItemStyles} <MenuItem
{...(value === item.value {...menuItemStyles}
? { {...(value === item.value
ref: SelectedItemRef, ? {
color: 'primary.700', ref: SelectedItemRef,
bg: 'myGray.100', color: 'primary.700',
fontWeight: '600' bg: 'myGray.100',
fontWeight: '600'
}
: {
color: 'myGray.900'
})}
onClick={() => {
if (value !== item.value) {
onClickChange(item.value);
} }
: { }}
color: 'myGray.900' whiteSpace={'pre-wrap'}
})} fontSize={'sm'}
onClick={() => { display={'block'}
if (value !== item.value) { mb={0.5}
onClickChange(item.value); >
} <Flex alignItems={'center'}>
}} {item.icon && (
whiteSpace={'pre-wrap'} <Avatar mr={2} src={item.icon as any} w={item.iconSize ?? '1rem'} />
fontSize={'sm'} )}
display={'block'} {item.label}
mb={0.5} </Flex>
> {item.description && (
<Flex alignItems={'center'}> <Box color={'myGray.500'} fontSize={'xs'}>
{item.icon && <Avatar mr={2} src={item.icon as any} w={item.iconSize ?? '1rem'} />} {item.description}
{item.label} </Box>
</Flex> )}
{item.description && ( </MenuItem>
<Box color={'myGray.500'} fontSize={'xs'}> {item.showBorder && <MyDivider my={2} />}
{item.description} </Box>
</Box> ))
)} ) : (
</MenuItem> <EmptyTip py={0} />
{item.showBorder && <MyDivider my={2} />} )}
</Box>
))}
</> </>
); );
}, [filterList, onClickChange, value]); }, [filterList, onClickChange, value]);

View File

@@ -104,8 +104,8 @@ const NodeCard = (props: Props) => {
const isAppNode = node && AppNodeFlowNodeTypeMap[node?.flowNodeType]; const isAppNode = node && AppNodeFlowNodeTypeMap[node?.flowNodeType];
const showVersion = useMemo(() => { const showVersion = useMemo(() => {
if (!isAppNode || !node?.pluginId) return false; if (!isAppNode || !node?.pluginId) return false;
const splitRes = node.pluginId.split('-'); if ([FlowNodeTypeEnum.tool, FlowNodeTypeEnum.toolSet].includes(node.flowNodeType)) return false;
if (splitRes.length > 1) { if (node.pluginId.split('-').length > 1) {
return false; return false;
} }
return true; return true;