@@ -36,14 +36,14 @@ async function handler(
|
||||
.limit(pageSize)
|
||||
.lean();
|
||||
|
||||
return (
|
||||
await addSourceMember({
|
||||
list: versions
|
||||
})
|
||||
).map((item) => ({
|
||||
...item,
|
||||
isPublish: !!item.isPublish
|
||||
}));
|
||||
return addSourceMember({
|
||||
list: versions
|
||||
}).then((list) =>
|
||||
list.map((item) => ({
|
||||
...item,
|
||||
isPublish: !!item.isPublish
|
||||
}))
|
||||
);
|
||||
})(),
|
||||
MongoAppVersion.countDocuments({ appId })
|
||||
]);
|
||||
|
||||
@@ -164,6 +164,10 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
|
||||
runningAppInfo: {
|
||||
id: appId,
|
||||
teamId: app.teamId,
|
||||
tmbId: app.tmbId
|
||||
},
|
||||
runningUserInfo: {
|
||||
teamId,
|
||||
tmbId
|
||||
},
|
||||
|
||||
@@ -18,6 +18,7 @@ import { getGroupsByTmbId } from '@fastgpt/service/support/permission/memberGrou
|
||||
import { concatPer } from '@fastgpt/service/support/permission/controller';
|
||||
import { getOrgIdSetWithParentByTmbId } from '@fastgpt/service/support/permission/org/controllers';
|
||||
import { addSourceMember } from '@fastgpt/service/support/user/utils';
|
||||
import { getVectorModel } from '@fastgpt/service/core/ai/model';
|
||||
|
||||
export type GetDatasetListBody = {
|
||||
parentId: ParentIdType;
|
||||
@@ -166,7 +167,15 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
|
||||
})();
|
||||
|
||||
return {
|
||||
...dataset,
|
||||
_id: dataset._id,
|
||||
avatar: dataset.avatar,
|
||||
name: dataset.name,
|
||||
intro: dataset.intro,
|
||||
type: dataset.type,
|
||||
vectorModel: getVectorModel(dataset.vectorModel),
|
||||
inheritPermission: dataset.inheritPermission,
|
||||
tmbId: dataset.tmbId,
|
||||
updateTime: dataset.updateTime,
|
||||
permission: Per,
|
||||
privateDataset
|
||||
};
|
||||
@@ -174,8 +183,7 @@ async function handler(req: ApiRequestProps<GetDatasetListBody>) {
|
||||
.filter((app) => app.permission.hasReadPer);
|
||||
|
||||
return addSourceMember({
|
||||
list: formatDatasets,
|
||||
teamId
|
||||
list: formatDatasets
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,11 @@ async function handler(
|
||||
requestOrigin: req.headers.origin,
|
||||
mode: 'debug',
|
||||
runningAppInfo: {
|
||||
id: appId,
|
||||
id: app._id,
|
||||
teamId: app.teamId,
|
||||
tmbId: app.tmbId
|
||||
},
|
||||
runningUserInfo: {
|
||||
teamId,
|
||||
tmbId
|
||||
},
|
||||
|
||||
@@ -280,6 +280,10 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
teamId: String(app.teamId),
|
||||
tmbId: String(app.tmbId)
|
||||
},
|
||||
runningUserInfo: {
|
||||
teamId,
|
||||
tmbId
|
||||
},
|
||||
uid: String(outLinkUserId || tmbId),
|
||||
|
||||
chatId,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io.d';
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import React, { useCallback } from 'react';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { Box, Flex } from '@chakra-ui/react';
|
||||
|
||||
@@ -10,14 +10,14 @@ import { useContextSelector } from 'use-context-selector';
|
||||
import { WorkflowContext } from '@/pages/app/detail/components/WorkflowComponents/context';
|
||||
import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip';
|
||||
import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel';
|
||||
import VariableTip from '@/components/common/Textarea/MyTextarea/VariableTip';
|
||||
|
||||
type Props = {
|
||||
nodeId: string;
|
||||
input: FlowNodeInputItemType;
|
||||
RightComponent?: React.JSX.Element;
|
||||
};
|
||||
|
||||
const InputLabel = ({ nodeId, input }: Props) => {
|
||||
const InputLabel = ({ nodeId, input, RightComponent }: Props) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const onChangeNode = useContextSelector(WorkflowContext, (v) => v.onChangeNode);
|
||||
@@ -68,11 +68,11 @@ const InputLabel = ({ nodeId, input }: Props) => {
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Variable picker tip */}
|
||||
{input.renderTypeList[input.selectedTypeIndex ?? 0] === FlowNodeInputTypeEnum.textarea && (
|
||||
{/* Right Component */}
|
||||
{RightComponent && (
|
||||
<>
|
||||
<Box flex={1} />
|
||||
<VariableTip transform={'translateY(2px)'} />
|
||||
<Box flex={'1'} />
|
||||
{RightComponent}
|
||||
</>
|
||||
)}
|
||||
</Flex>
|
||||
|
||||
@@ -8,71 +8,72 @@ import InputLabel from './Label';
|
||||
import type { RenderInputProps } from './type';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
|
||||
const RenderList: {
|
||||
types: FlowNodeInputTypeEnum[];
|
||||
Component: React.ComponentType<RenderInputProps>;
|
||||
}[] = [
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.reference],
|
||||
const RenderList: Record<
|
||||
FlowNodeInputTypeEnum,
|
||||
| {
|
||||
Component: React.ComponentType<RenderInputProps>;
|
||||
LableRightComponent?: React.ComponentType<RenderInputProps>;
|
||||
}
|
||||
| undefined
|
||||
> = {
|
||||
[FlowNodeInputTypeEnum.reference]: {
|
||||
Component: dynamic(() => import('./templates/Reference'))
|
||||
},
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.fileSelect],
|
||||
[FlowNodeInputTypeEnum.fileSelect]: {
|
||||
Component: dynamic(() => import('./templates/Reference'))
|
||||
},
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.select],
|
||||
[FlowNodeInputTypeEnum.select]: {
|
||||
Component: dynamic(() => import('./templates/Select'))
|
||||
},
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.numberInput],
|
||||
[FlowNodeInputTypeEnum.numberInput]: {
|
||||
Component: dynamic(() => import('./templates/NumberInput'))
|
||||
},
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.switch],
|
||||
[FlowNodeInputTypeEnum.switch]: {
|
||||
Component: dynamic(() => import('./templates/Switch'))
|
||||
},
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.selectApp],
|
||||
[FlowNodeInputTypeEnum.selectApp]: {
|
||||
Component: dynamic(() => import('./templates/SelectApp'))
|
||||
},
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.selectLLMModel],
|
||||
[FlowNodeInputTypeEnum.selectLLMModel]: {
|
||||
Component: dynamic(() => import('./templates/SelectLLMModel'))
|
||||
},
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.settingLLMModel],
|
||||
[FlowNodeInputTypeEnum.settingLLMModel]: {
|
||||
Component: dynamic(() => import('./templates/SettingLLMModel'))
|
||||
},
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.selectDataset],
|
||||
Component: dynamic(() => import('./templates/SelectDataset'))
|
||||
[FlowNodeInputTypeEnum.selectDataset]: {
|
||||
Component: dynamic(() =>
|
||||
import('./templates/SelectDataset').then((mod) => mod.SelectDatasetRender)
|
||||
),
|
||||
LableRightComponent: dynamic(() =>
|
||||
import('./templates/SelectDataset').then((mod) => mod.SwitchAuthTmb)
|
||||
)
|
||||
},
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.selectDatasetParamsModal],
|
||||
[FlowNodeInputTypeEnum.selectDatasetParamsModal]: {
|
||||
Component: dynamic(() => import('./templates/SelectDatasetParams'))
|
||||
},
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.addInputParam],
|
||||
[FlowNodeInputTypeEnum.addInputParam]: {
|
||||
Component: dynamic(() => import('./templates/DynamicInputs/index'))
|
||||
},
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.JSONEditor],
|
||||
[FlowNodeInputTypeEnum.JSONEditor]: {
|
||||
Component: dynamic(() => import('./templates/JsonEditor'))
|
||||
},
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.settingDatasetQuotePrompt],
|
||||
[FlowNodeInputTypeEnum.settingDatasetQuotePrompt]: {
|
||||
Component: dynamic(() => import('./templates/SettingQuotePrompt'))
|
||||
},
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.input],
|
||||
[FlowNodeInputTypeEnum.input]: {
|
||||
Component: dynamic(() => import('./templates/TextInput'))
|
||||
},
|
||||
{
|
||||
types: [FlowNodeInputTypeEnum.textarea],
|
||||
Component: dynamic(() => import('./templates/Textarea'))
|
||||
}
|
||||
];
|
||||
[FlowNodeInputTypeEnum.textarea]: {
|
||||
Component: dynamic(() => import('./templates/Textarea')),
|
||||
LableRightComponent: dynamic(() =>
|
||||
import('./templates/Textarea').then((mod) => mod.TextareaRightComponent)
|
||||
)
|
||||
},
|
||||
|
||||
[FlowNodeInputTypeEnum.customVariable]: undefined,
|
||||
[FlowNodeInputTypeEnum.hidden]: undefined,
|
||||
[FlowNodeInputTypeEnum.custom]: undefined
|
||||
};
|
||||
|
||||
const hideLabelTypeList = [FlowNodeInputTypeEnum.addInputParam];
|
||||
|
||||
@@ -101,7 +102,7 @@ const RenderInput = ({ flowInputList, nodeId, CustomComponent, mb = 5 }: Props)
|
||||
|
||||
return true;
|
||||
});
|
||||
}, [feConfigs?.isPlus, flowInputList]);
|
||||
}, [filterProInputs]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -110,23 +111,41 @@ const RenderInput = ({ flowInputList, nodeId, CustomComponent, mb = 5 }: Props)
|
||||
|
||||
const RenderComponent = (() => {
|
||||
if (renderType === FlowNodeInputTypeEnum.custom && CustomComponent?.[input.key]) {
|
||||
return <>{CustomComponent?.[input.key]({ ...input })}</>;
|
||||
return {
|
||||
Component: <>{CustomComponent?.[input.key]({ ...input })}</>
|
||||
};
|
||||
}
|
||||
|
||||
const Component = RenderList.find((item) => item.types.includes(renderType))?.Component;
|
||||
const RenderItem = RenderList[renderType];
|
||||
|
||||
if (!Component) return null;
|
||||
return <Component inputs={filterProInputs} item={input} nodeId={nodeId} />;
|
||||
if (!RenderItem) return null;
|
||||
|
||||
return {
|
||||
Component: (
|
||||
<RenderItem.Component inputs={filterProInputs} item={input} nodeId={nodeId} />
|
||||
),
|
||||
LableRightComponent: RenderItem.LableRightComponent ? (
|
||||
<RenderItem.LableRightComponent
|
||||
inputs={filterProInputs}
|
||||
item={input}
|
||||
nodeId={nodeId}
|
||||
/>
|
||||
) : undefined
|
||||
};
|
||||
})();
|
||||
|
||||
return (
|
||||
<Box key={input.key} _notLast={{ mb }} position={'relative'}>
|
||||
{!!input.label && !hideLabelTypeList.includes(renderType) && (
|
||||
<InputLabel nodeId={nodeId} input={input} />
|
||||
<InputLabel
|
||||
nodeId={nodeId}
|
||||
input={input}
|
||||
RightComponent={RenderComponent?.LableRightComponent}
|
||||
/>
|
||||
)}
|
||||
{!!RenderComponent && (
|
||||
<Box mt={2} className={'nodrag'}>
|
||||
{RenderComponent}
|
||||
{RenderComponent.Component}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import type { RenderInputProps } from '../type';
|
||||
import { Box, Button, Flex, Grid, useDisclosure, useTheme } from '@chakra-ui/react';
|
||||
import { Box, Button, Flex, Grid, Switch, useDisclosure, useTheme } from '@chakra-ui/react';
|
||||
import { useDatasetStore } from '@/web/core/dataset/store/dataset';
|
||||
import { SelectedDatasetType } from '@fastgpt/global/core/workflow/api';
|
||||
import Avatar from '@fastgpt/web/components/common/Avatar';
|
||||
@@ -12,12 +12,17 @@ import dynamic from 'next/dynamic';
|
||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { WorkflowContext } from '@/pages/app/detail/components/WorkflowComponents/context';
|
||||
import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip';
|
||||
import { NodeInputKeyEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
|
||||
const DatasetSelectModal = dynamic(() => import('@/components/core/app/DatasetSelectModal'));
|
||||
|
||||
const SelectDatasetRender = ({ inputs = [], item, nodeId }: RenderInputProps) => {
|
||||
export const SelectDatasetRender = React.memo(function SelectDatasetRender({
|
||||
inputs = [],
|
||||
item,
|
||||
nodeId
|
||||
}: RenderInputProps) {
|
||||
const { t } = useTranslation();
|
||||
const theme = useTheme();
|
||||
const onChangeNode = useContextSelector(WorkflowContext, (v) => v.onChangeNode);
|
||||
|
||||
const [data, setData] = useState({
|
||||
@@ -80,8 +85,9 @@ const SelectDatasetRender = ({ inputs = [], item, nodeId }: RenderInputProps) =>
|
||||
key={item._id}
|
||||
alignItems={'center'}
|
||||
h={10}
|
||||
border={theme.borders.base}
|
||||
borderColor={'myGray.200'}
|
||||
boxShadow={'sm'}
|
||||
bg={'white'}
|
||||
border={'base'}
|
||||
px={2}
|
||||
borderRadius={'md'}
|
||||
>
|
||||
@@ -128,11 +134,49 @@ const SelectDatasetRender = ({ inputs = [], item, nodeId }: RenderInputProps) =>
|
||||
onOpenDatasetSelect,
|
||||
selectedDatasets,
|
||||
selectedDatasetsValue,
|
||||
t,
|
||||
theme.borders.base
|
||||
t
|
||||
]);
|
||||
|
||||
return Render;
|
||||
};
|
||||
});
|
||||
|
||||
export default React.memo(SelectDatasetRender);
|
||||
export const SwitchAuthTmb = React.memo(function SwitchAuthTmb({
|
||||
inputs = [],
|
||||
item,
|
||||
nodeId
|
||||
}: RenderInputProps) {
|
||||
const { t } = useTranslation();
|
||||
const onChangeNode = useContextSelector(WorkflowContext, (v) => v.onChangeNode);
|
||||
|
||||
const authTmbIdInput = useMemo(
|
||||
() => inputs.find((v) => v.key === NodeInputKeyEnum.authTmbId),
|
||||
[inputs]
|
||||
);
|
||||
|
||||
console.log(authTmbIdInput, '--');
|
||||
|
||||
return authTmbIdInput ? (
|
||||
<Flex alignItems={'center'}>
|
||||
<Box fontSize={'sm'}>{t('workflow:auth_tmb_id')}</Box>
|
||||
<QuestionTip label={t('workflow:auth_tmb_id_tip')} />
|
||||
<Switch
|
||||
ml={1}
|
||||
size={'sm'}
|
||||
isChecked={!!authTmbIdInput.value}
|
||||
onChange={(e) => {
|
||||
onChangeNode({
|
||||
nodeId,
|
||||
key: NodeInputKeyEnum.authTmbId,
|
||||
type: 'updateInput',
|
||||
value: {
|
||||
...authTmbIdInput,
|
||||
value: e.target.checked
|
||||
}
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Flex>
|
||||
) : null;
|
||||
});
|
||||
|
||||
export default SelectDatasetRender;
|
||||
|
||||
@@ -9,6 +9,7 @@ import { AppContext } from '@/pages/app/detail/components/context';
|
||||
import { getEditorVariables } from '../../../../../utils';
|
||||
import { WorkflowNodeEdgeContext } from '../../../../../context/workflowInitContext';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import VariableTip from '@/components/common/Textarea/MyTextarea/VariableTip';
|
||||
|
||||
const TextareaRender = ({ item, nodeId }: RenderInputProps) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -84,3 +85,10 @@ const TextareaRender = ({ item, nodeId }: RenderInputProps) => {
|
||||
};
|
||||
|
||||
export default React.memo(TextareaRender);
|
||||
|
||||
export const TextareaRightComponent = React.memo(function TextareaRightComponent({
|
||||
item,
|
||||
nodeId
|
||||
}: RenderInputProps) {
|
||||
return <VariableTip transform={'translateY(2px)'} />;
|
||||
});
|
||||
|
||||
@@ -65,6 +65,10 @@ export const getScheduleTriggerApp = async () => {
|
||||
teamId: String(app.teamId),
|
||||
tmbId: String(app.tmbId)
|
||||
},
|
||||
runningUserInfo: {
|
||||
teamId: String(app.teamId),
|
||||
tmbId: String(app.tmbId)
|
||||
},
|
||||
uid: String(app.tmbId),
|
||||
runtimeNodes: storeNodes2RuntimeNodes(nodes, getWorkflowEntryNodeIds(nodes)),
|
||||
runtimeEdges: initWorkflowEdgeStatus(edges),
|
||||
|
||||
Reference in New Issue
Block a user