Skip to content

Commit

Permalink
Fix workflow detail (#3382)
Browse files Browse the repository at this point in the history
* fix: loop node init

* fix: workflow detail

* fix: point table

* add null check
  • Loading branch information
c121914yu authored Dec 12, 2024
1 parent 181b854 commit ddddd99
Show file tree
Hide file tree
Showing 34 changed files with 293 additions and 238 deletions.
12 changes: 12 additions & 0 deletions docSite/content/zh-cn/docs/development/upgrading/4815.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ curl --location --request POST 'https://{{host}}/api/admin/initv4815' \

会重置应用定时执行的字段,把 null 去掉,减少索引大小。

----

从任意终端,发起 1 个 HTTP 请求。其中 {{rootkey}} 替换成环境变量里的 `rootkey`;{{host}} 替换成**FastGPT 域名**

```bash
curl --location --request POST 'https://{{host}}/api/admin/refreshFreeUser' \
--header 'rootkey: {{rootkey}}' \
--header 'Content-Type: application/json'
```

重新计算一次免费版用户的时长,之前有版本升级时没有重新计算时间,导致会误发通知。


## 完整更新内容

Expand Down
7 changes: 6 additions & 1 deletion docSite/content/zh-cn/docs/development/upgrading/4816.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ weight: 808

1.
2. 新增 - 商业版支持 API 知识库和链接集合定时同步。
3. 修复 - 站点同步知识库,链接同步时未使用选择器。
3. 优化 - 工作流/简易模式变量初始化代码,去除监听初始化,避免因渲染顺序不一致导致的失败。
4. 修复 - 无法自动切换默认语言。增加分享链接,强制执行一次切换默认语言。
5. 修复 - 数组选择器自动兼容 4.8.13 以前的数据。
6. 修复 - 站点同步知识库,链接同步时未使用选择器。
7. 修复 - 简易模式转工作流,没有把系统配置项转化。
8. 修复 - 插件独立运行,变量初始值未赋上。
2 changes: 1 addition & 1 deletion packages/global/common/string/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const simpleText = (text = '') => {
replace {{variable}} to value
*/
export function replaceVariable(text: any, obj: Record<string, string | number>) {
if (!(typeof text === 'string')) return text;
if (typeof text !== 'string') return text;

for (const key in obj) {
const val = obj[key];
Expand Down
1 change: 1 addition & 0 deletions packages/global/core/workflow/runtime/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export const getReferenceVariableValue = ({
return variables[outputId];
}

// 避免 value 刚好就是二个元素的字符串数组
const node = nodes.find((node) => node.nodeId === sourceNodeId);
if (!node) {
return value;
Expand Down
16 changes: 14 additions & 2 deletions packages/web/components/common/MySelect/MultipleRowSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ export const MultipleRowArraySelect = ({
ref: ref,
handler: onClose
});
const onChange = useCallback(
(val: any[][]) => {
// Filter invalid value
const validList = val.filter((item) => {
const listItem = list.find((v) => v.value === item[0]);
if (!listItem) return false;
return listItem.children?.some((v) => v.value === item[1]);
});
onSelect(validList);
},
[onSelect]
);

const RenderList = useCallback(
({ index, list }: { index: number; list: MultipleSelectProps['list'] }) => {
Expand All @@ -213,9 +225,9 @@ export const MultipleRowArraySelect = ({
const newValue = [parentValue, item.value];

if (newValues.some((v) => v[0] === parentValue && v[1] === item.value)) {
onSelect(newValues.filter((v) => !(v[0] === parentValue && v[1] === item.value)));
onChange(newValues.filter((v) => !(v[0] === parentValue && v[1] === item.value)));
} else {
onSelect([...newValues, newValue]);
onChange([...newValues, newValue]);
}
}
};
Expand Down
8 changes: 5 additions & 3 deletions packages/web/hooks/useI18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ export const useI18nLng = () => {
setLang(lang);

await i18n?.changeLanguage?.(lang);
if (prevLang && prevLang !== lang) {

if (!i18n.hasResourceBundle(lang, 'common') && prevLang !== lang) {
window?.location?.reload?.();
}
};

const setUserDefaultLng = () => {
const setUserDefaultLng = (forceGetDefaultLng: boolean = false) => {
if (!navigator || !localStorage) return;
if (getLang()) return onChangeLng(getLang() as string);

if (getLang() && !forceGetDefaultLng) return onChangeLng(getLang() as string);

const lang = languageMap[navigator.language] || 'en';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useMemo } from 'react';
import React, { useEffect } from 'react';
import { Controller, UseFormReturn } from 'react-hook-form';
import { useTranslation } from 'next-i18next';
import { Box, Button, Card, Textarea } from '@chakra-ui/react';
Expand Down Expand Up @@ -121,21 +121,7 @@ const VariableInput = ({
const variablesForm = useContextSelector(ChatItemContext, (v) => v.variablesForm);
const variableList = useContextSelector(ChatBoxContext, (v) => v.variableList);

const { setValue, handleSubmit: handleSubmitChat } = variablesForm;

const defaultValues = useMemo(() => {
return variableList.reduce((acc: Record<string, any>, item) => {
acc[item.key] = item.defaultValue;
return acc;
}, {});
}, [variableList]);

useEffect(() => {
const values = variablesForm.getValues('variables');
// If form is not empty, do not reset the variables
if (Object.values(values).filter(Boolean).length > 0) return;
setValue('variables', defaultValues);
}, [defaultValues, setValue, variablesForm]);
const { handleSubmit: handleSubmitChat } = variablesForm;

return (
<Box py={3}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ const ChatBox = ({
setQuestionGuide([]);
setValue('chatStarted', false);
abortRequest('leave');
}, [abortRequest, setValue]);
}, [chatId, appId, abortRequest, setValue]);

// Add listener
useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,15 @@ const RenderInput = () => {
return;
}

const defaultFormValues = formatPluginInputs.reduce(
(acc, input) => {
acc[input.key] = input.defaultValue;
return acc;
},
{} as Record<string, any>
);

reset({
files: [],
variables: defaultFormValues
variables: formatPluginInputs.reduce(
(acc, input) => {
acc[input.key] = input.defaultValue;
return acc;
},
{} as Record<string, any>
)
});
return;
}
Expand Down Expand Up @@ -164,7 +162,7 @@ const RenderInput = () => {
files: historyFileList
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [histories]);
}, [histories, formatPluginInputs]);

const [uploading, setUploading] = useState(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ const RenderPluginInput = ({
return (
<Textarea
value={value}
defaultValue={input.defaultValue}
onChange={onChange}
isDisabled={isDisabled}
placeholder={t(input.placeholder as any)}
Expand All @@ -192,7 +191,6 @@ const RenderPluginInput = ({
isInvalid={isInvalid}
value={value}
onChange={onChange}
defaultValue={input.defaultValue}
/>
);
}
Expand All @@ -203,7 +201,6 @@ const RenderPluginInput = ({
onChange={onChange}
isDisabled={isDisabled}
isInvalid={isInvalid}
defaultChecked={!!input.defaultValue}
/>
);
}
Expand All @@ -216,7 +213,6 @@ const RenderPluginInput = ({
value={value}
onChange={onChange}
isInvalid={isInvalid}
defaultValue={input.defaultValue}
/>
);
})();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import { useSystemStore } from '@/web/common/system/useSystemStore';
import { StandardSubLevelEnum, SubModeEnum } from '@fastgpt/global/support/wallet/sub/constants';
import React, { useMemo } from 'react';
import { standardSubLevelMap } from '@fastgpt/global/support/wallet/sub/constants';
import { Box, Flex, Grid } from '@chakra-ui/react';
import { Box, Flex, Grid, useDisclosure } from '@chakra-ui/react';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router';
import { getAiPointUsageCardRoute } from '@/web/support/wallet/sub/constants';
import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip';
import dynamic from 'next/dynamic';

const AiPointsModal = dynamic(() =>
import('@/pages/price/components/Points').then((mod) => mod.AiPointsModal)
);

const StandardPlanContentList = ({
level,
Expand All @@ -18,7 +21,12 @@ const StandardPlanContentList = ({
}) => {
const { t } = useTranslation();
const { subPlans } = useSystemStore();
const router = useRouter();

const {
isOpen: isOpenAiPointsModal,
onClose: onCloseAiPointsModal,
onOpen: onOpenAiPointsModal
} = useDisclosure();

const planContent = useMemo(() => {
const plan = subPlans?.standard?.[level];
Expand Down Expand Up @@ -95,9 +103,7 @@ const StandardPlanContentList = ({
<QuestionTip
ml={1}
label={t('common:support.wallet.subscription.AI points click to read tip')}
onClick={() => {
router.push(getAiPointUsageCardRoute());
}}
onClick={onOpenAiPointsModal}
></QuestionTip>
</Flex>
</Flex>
Expand All @@ -121,6 +127,7 @@ const StandardPlanContentList = ({
<Box color={'myGray.600'}>{t('common:support.wallet.subscription.web_site_sync')}</Box>
</Flex>
)}
{isOpenAiPointsModal && <AiPointsModal onClose={onCloseAiPointsModal} />}
</Grid>
) : null;
};
Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/global/core/chat/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export type InitChatResponse = {
appId: string;
userAvatar?: string;
title?: string;
variables: Record<string, any>;
variables?: Record<string, any>;
app: {
chatConfig?: AppChatConfigType;
chatModels?: string[];
Expand Down
1 change: 1 addition & 0 deletions projects/app/src/pages/api/core/app/transitionWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ async function handler(
type: AppTypeEnum.workflow,
modules: app.modules,
edges: app.edges,
chatConfig: app.chatConfig,
teamId: app.teamId,
tmbId
});
Expand Down
3 changes: 1 addition & 2 deletions projects/app/src/pages/api/core/app/version/publish.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import type { NextApiResponse } from 'next';
import { NextAPI } from '@/service/middleware/entry';
import { authApp } from '@fastgpt/service/support/permission/app/auth';
import { MongoAppVersion } from '@fastgpt/service/core/app/version/schema';
Expand All @@ -10,7 +10,6 @@ import { PostPublishAppProps } from '@/global/core/app/api';
import { WritePermissionVal } from '@fastgpt/global/support/permission/constant';
import { ApiRequestProps } from '@fastgpt/service/type/next';
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
import { getScheduleTriggerApp } from '@/service/core/app/utils';

async function handler(
req: ApiRequestProps<PostPublishAppProps>,
Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/pages/api/core/chat/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async function handler(
appId,
title: chat?.title,
userAvatar: undefined,
variables: chat?.variables || {},
variables: chat?.variables,
app: {
chatConfig: getAppChatConfig({
chatConfig,
Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/pages/api/core/chat/outLink/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
title: chat?.title,
//@ts-ignore
userAvatar: tmb?.userId?.avatar,
variables: chat?.variables || {},
variables: chat?.variables,
app: {
chatConfig: getAppChatConfig({
chatConfig,
Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/pages/api/core/chat/team/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function handler(req: ApiRequestProps<InitTeamChatProps>, res: NextApiResp
appId,
title: chat?.title,
userAvatar: team?.avatar,
variables: chat?.variables || {},
variables: chat?.variables,
app: {
chatConfig: getAppChatConfig({
chatConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ const DetailLogsModal = ({ appId, chatId, onClose }: Props) => {

setChatBoxData(res);
resetVariables({
variables: res.variables
variables: res.variables,
variableList: res.app?.chatConfig?.variables
});

return res;
Expand Down
13 changes: 7 additions & 6 deletions projects/app/src/pages/app/detail/components/Logs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react';
import React, { useState } from 'react';
import {
Flex,
Box,
Expand Down Expand Up @@ -31,7 +31,8 @@ import { cardStyles } from '../constants';
import dynamic from 'next/dynamic';
import { useSystem } from '@fastgpt/web/hooks/useSystem';
import { useUserStore } from '@/web/support/user/useUserStore';
import Tag from '@fastgpt/web/components/common/Tag';
import { useMount } from 'ahooks';

const DetailLogsModal = dynamic(() => import('./DetailLogsModal'));

const Logs = () => {
Expand All @@ -41,9 +42,9 @@ const Logs = () => {
const appId = useContextSelector(AppContext, (v) => v.appId);
const { teamMembers, loadAndGetTeamMembers } = useUserStore();

useEffect(() => {
useMount(() => {
loadAndGetTeamMembers();
}, []);
});

const [dateRange, setDateRange] = useState<DateRangeType>({
from: addDays(new Date(), -7),
Expand Down Expand Up @@ -140,11 +141,11 @@ const Logs = () => {
) : (
<HStack>
<Avatar
src={teamMembers.find((v) => v.tmbId === item.tmbId)?.avatar}
src={teamMembers?.find((v) => v.tmbId === item.tmbId)?.avatar}
w="1.25rem"
/>
<Box fontSize={'sm'} ml={1}>
{teamMembers.find((v) => v.tmbId === item.tmbId)?.memberName}
{teamMembers?.find((v) => v.tmbId === item.tmbId)?.memberName}
</Box>
</HStack>
)}
Expand Down
Loading

0 comments on commit ddddd99

Please sign in to comment.