chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -249,8 +249,8 @@ describe('useMockSetInSettingModalController', () => {
|
||||
|
||||
await waitForNextUpdate();
|
||||
|
||||
expect(result.current.isEnabled).toBeFalsy(); // 初始状态应该是不启用
|
||||
expect(result.current.mockSetData).toEqual([]); // 初始mockSetData应该是空数组
|
||||
expect(result.current.isEnabled).toBeFalsy(); // The initial state should be not enabled
|
||||
expect(result.current.mockSetData).toEqual([]); // The initial mockSetData should be an empty array
|
||||
});
|
||||
|
||||
it('should act export action', async () => {
|
||||
@@ -260,25 +260,25 @@ describe('useMockSetInSettingModalController', () => {
|
||||
|
||||
await waitForNextUpdate();
|
||||
|
||||
expect(result.current.isEnabled).toBeTruthy(); // 有选中的mock数据的前提下,会自动启用
|
||||
expect(result.current.mockSetData.length).toEqual(7); // mockSetData 数据是 7
|
||||
expect(result.current.isEnabled).toBeTruthy(); // If there is selected mock data, it will be automatically enabled
|
||||
expect(result.current.mockSetData.length).toEqual(7); // mockSetData is 7.
|
||||
|
||||
act(() => result.current.doSetCreateModal(true));
|
||||
expect(result.current.showCreateModal).toBeTruthy(); // 打开创建modal
|
||||
expect(result.current.showCreateModal).toBeTruthy(); // Open Create modal
|
||||
|
||||
act(() => result.current.doHandleView({ id: 'record-id' })); // 点击查看
|
||||
act(() => result.current.doHandleView({ id: 'record-id' })); // Click to view
|
||||
|
||||
act(() => result.current.doEnabled()); // 关闭
|
||||
expect(result.current.isEnabled).toBeFalsy(); // 禁用
|
||||
act(() => result.current.doEnabled()); // close
|
||||
expect(result.current.isEnabled).toBeFalsy(); // disable
|
||||
|
||||
act(() => result.current.doSetDeleteId('record-id')); // 删除
|
||||
act(() => result.current.doSetDeleteId('record-id')); // delete
|
||||
expect(result.current.deleteRenderTitle).toBe(
|
||||
'Translated: delete_the_mockset {}',
|
||||
); // 删除后应该显示删除的title
|
||||
); // The deleted title should be displayed after deletion.
|
||||
|
||||
act(() => result.current.doConfirmDelete()); // 确认删除
|
||||
act(() => result.current.doConfirmDelete()); // Confirm deletion
|
||||
|
||||
act(() => result.current.doChangeMock({ id: 'change-mock' })); // 修改mock
|
||||
expect(result.current.selectedMockSet).toStrictEqual({ id: 'change-mock' }); // 修改mock后应该显示新的mock
|
||||
act(() => result.current.doChangeMock({ id: 'change-mock' })); // Modify mock
|
||||
expect(result.current.selectedMockSet).toStrictEqual({ id: 'change-mock' }); // After modifying the mock, the new mock should be displayed.
|
||||
});
|
||||
});
|
||||
|
||||
@@ -92,7 +92,7 @@ describe('useSaveMockData', () => {
|
||||
|
||||
const { result } = renderHook(() =>
|
||||
useSaveMockData({
|
||||
mockSetId: undefined, // 测试没有mockSetId的情况
|
||||
mockSetId: undefined, // Test without mockSetId
|
||||
basicParams: {
|
||||
environment: 'environment',
|
||||
workspace_id: 'workspace_id',
|
||||
|
||||
@@ -53,8 +53,8 @@ vi.mock('@coze-arch/bot-tea', () => ({
|
||||
},
|
||||
ParamsTypeDefine: {},
|
||||
PluginMockDataGenerateMode: {
|
||||
MANUAL: 0, // 手动创建
|
||||
RANDOM: 1, // 随机生成
|
||||
MANUAL: 0, // create manually
|
||||
RANDOM: 1, // random generation
|
||||
LLM: 2,
|
||||
},
|
||||
}));
|
||||
@@ -62,21 +62,21 @@ vi.mock('@coze-arch/bot-tea', () => ({
|
||||
vi.mock('@coze-arch/bot-hooks', () => ({
|
||||
SceneType: {
|
||||
BOT__VIEW__WORKFLOW: 'botViewWorkflow',
|
||||
/** bot 详情页查看 workflow,或新建 workflow 但未发布,点击返回 */
|
||||
/** View the workflow on the bot details page, or create a new workflow but not published, click Return */
|
||||
WORKFLOW__BACK__BOT: 'workflowBackBot',
|
||||
/** bot 详情页创建 workflow,在 workflow 发布后返回 */
|
||||
/** The bot details page creates a workflow and returns it after the workflow is published */
|
||||
WORKFLOW_PUBLISHED__BACK__BOT: 'workflowPublishedBackBot',
|
||||
/** bot 详情页进入 mock data 页面 */
|
||||
/** Bot details page Enter the mock data page */
|
||||
BOT__TO__PLUGIN_MOCK_DATA: 'botToPluginMockData',
|
||||
/** workflow 详情页进入 mock data 页面 */
|
||||
/** Workflow details page Enter the mock data page */
|
||||
WORKFLOW__TO__PLUGIN_MOCK_DATA: 'workflowToPluginMockData',
|
||||
/** mock set 页进入 mock data 页面 */
|
||||
/** Mock set page Enter the mock data page */
|
||||
PLUGIN_MOCK_SET__TO__PLUGIN_MOCK_DATA: 'pluginMockSetToPluginMockData',
|
||||
/** bot 详情页进入 knowledge 页面 */
|
||||
/** Bot details page Enter the knowledge page */
|
||||
BOT__VIEW__KNOWLEDGE: 'botViewKnowledge',
|
||||
/** knowledge 页面点击退出返回 bot 详情页(未点击添加) */
|
||||
/** Knowledge page Click Exit to return to bot details page (not clicked Add) */
|
||||
KNOWLEDGE__BACK__BOT: 'knowledgeBackBot',
|
||||
/** knowledge 页面点击返回 bot 详情页,并添加到 bot */
|
||||
/** Knowledge page Click to return to bot details page and add to bot */
|
||||
KNOWLEDGE__ADD_TO__BOT: 'knowledgeAddToBot',
|
||||
},
|
||||
usePageJumpService: vi.fn().mockReturnValue({
|
||||
|
||||
@@ -23,7 +23,7 @@ export const REAL_DATA_MOCKSET = {
|
||||
name: I18n.t('real_data'),
|
||||
};
|
||||
|
||||
// 初始化仅有real_data
|
||||
// Initialization only real_data
|
||||
export const MOCK_OPTION_LIST = [REAL_DATA_MOCKSET];
|
||||
|
||||
export const POLLING_INTERVAL = 10000;
|
||||
|
||||
@@ -146,7 +146,7 @@ export const useInitialGetEnabledMockSet = ({
|
||||
}
|
||||
};
|
||||
|
||||
// 取消
|
||||
// cancel
|
||||
const cancel = () => {
|
||||
pollingTurnRef.current = undefined;
|
||||
cancelReq.current?.();
|
||||
|
||||
@@ -94,11 +94,11 @@
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
/** 创建框 **/
|
||||
/** Create box **/
|
||||
.mock-creation-modal {
|
||||
:global {
|
||||
.semi-modal-content .semi-modal-body {
|
||||
/** 保证内部 tooltip 不被遮盖 **/
|
||||
/** Make sure the internal tooltip is not covered **/
|
||||
overflow: unset
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
}
|
||||
|
||||
div.mock-creation-modal-editor {
|
||||
/** 兼容 modal 在小窗口下 body 高度不生效的问题 */
|
||||
/** Compatible modal body height does not take effect in small windows */
|
||||
height: calc(100vh - 316px);
|
||||
max-height: 500px;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ interface MockDataCardProps {
|
||||
bizCtx: infra.BizCtx;
|
||||
}
|
||||
|
||||
/** mock data 展示卡片 */
|
||||
/** Mock data display card */
|
||||
export function MockDataCard({
|
||||
mock,
|
||||
readOnly,
|
||||
|
||||
@@ -55,18 +55,18 @@ import { useSaveMockData } from '../hook/use-save-mock-data';
|
||||
import s from './index.module.less';
|
||||
|
||||
export enum CreationMode {
|
||||
/** 弹窗形式 */
|
||||
/** pop-up window */
|
||||
MODAL = 'modal',
|
||||
/** 嵌入页面 */
|
||||
/** embed page */
|
||||
CARD = 'card',
|
||||
}
|
||||
|
||||
interface MockDataCreateCardProps {
|
||||
mode: CreationMode;
|
||||
mockInfo?: MockDataInfo;
|
||||
// mode 为 modal 时生效
|
||||
// Effective when modal mode
|
||||
visible?: boolean;
|
||||
// mode 为 modal 时生效
|
||||
// Effective when modal mode
|
||||
onCancel?: () => void;
|
||||
onSuccess: (data?: mockset.MockRule[]) => void;
|
||||
bizCtx: infra.BizCtx;
|
||||
@@ -76,7 +76,7 @@ interface MockDataCreateCardProps {
|
||||
};
|
||||
}
|
||||
|
||||
/** 创建or编辑 mock data - */
|
||||
/** Create or edit mock data - */
|
||||
export function MockDataCreateCard({
|
||||
mode,
|
||||
mockInfo,
|
||||
@@ -96,7 +96,7 @@ export function MockDataCreateCard({
|
||||
useTransSchema(schema);
|
||||
const { mock_set_id, tool_id } = useParams<DynamicParams>();
|
||||
|
||||
// space信息
|
||||
// Space information
|
||||
const spaceType = useSpaceStore(store => store.space.space_type);
|
||||
const isPersonal = spaceType === SpaceType.Personal;
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ export const MockDataList = forwardRef(
|
||||
const [deleteModalVisible, setDeleteModalVisible] =
|
||||
useState<boolean>(false);
|
||||
const [deleting, setDeleting] = useState<boolean>(false);
|
||||
// 当前选中状态
|
||||
// Currently selected
|
||||
const [currentSelect, setCurrentSelect] = useState<
|
||||
MockDataInfo | undefined
|
||||
>();
|
||||
@@ -99,7 +99,7 @@ export const MockDataList = forwardRef(
|
||||
const routeResponse = usePageJumpResponse(PageType.PLUGIN_MOCK_DATA);
|
||||
|
||||
const { mock_set_id, space_id, tool_id } = useParams<DynamicParams>();
|
||||
// space信息
|
||||
// Space information
|
||||
const spaceType = useSpaceStore(store => store.space.space_type);
|
||||
const isPersonal = spaceType === SpaceType.Personal;
|
||||
|
||||
@@ -113,7 +113,7 @@ export const MockDataList = forwardRef(
|
||||
setDeleteModalVisible(true);
|
||||
};
|
||||
|
||||
// 获取当前 mock set 下的 mock data
|
||||
// Get the mock data under the current mock set
|
||||
const getMockData = async (needScrollToTop?: boolean) => {
|
||||
try {
|
||||
setLoading(true);
|
||||
@@ -181,11 +181,11 @@ export const MockDataList = forwardRef(
|
||||
}
|
||||
};
|
||||
|
||||
// 前端更新
|
||||
// frontend update
|
||||
const updateList = (data: MockRule, action: RuleActions) => {
|
||||
let len = 0;
|
||||
if (action === RuleActions.CREATE) {
|
||||
// 创建场景直接 force update
|
||||
// Create scenes to force updates directly
|
||||
getMockData(true);
|
||||
} else if (action === RuleActions.DELETE) {
|
||||
len = mockDataList.length - 1;
|
||||
@@ -228,7 +228,7 @@ export const MockDataList = forwardRef(
|
||||
|
||||
useEffect(() => {
|
||||
if (routeResponse?.generationMode) {
|
||||
// 清除跳转参数
|
||||
// Clear jump parameters
|
||||
const state = {
|
||||
...history.state,
|
||||
usr: { ...(history.state.usr || {}), generationMode: undefined },
|
||||
|
||||
@@ -42,12 +42,12 @@ export function MockSetPageBreadcrumb({
|
||||
}: MockSetPageBreadcrumbProps) {
|
||||
const routeResponse = usePageJumpResponse(PageType.PLUGIN_MOCK_DATA);
|
||||
|
||||
// 插件详情
|
||||
// plugin details
|
||||
const [pluginInfo, setPluginInfo] = useState<PluginMetaInfo>({
|
||||
name: routeResponse?.pluginName,
|
||||
});
|
||||
|
||||
// 获取当前 plugin 信息
|
||||
// Get current plugin information
|
||||
const getPluginInfo = async () => {
|
||||
try {
|
||||
const res = await DeveloperApi.GetPluginInfo(
|
||||
|
||||
@@ -162,7 +162,7 @@ const MockSetSelectComp = (
|
||||
const bizCtx: BizCtx = {
|
||||
...bizSceneCtx,
|
||||
connectorUID: uid,
|
||||
connectorID: CONNECTOR_ID, // 业务线为Coze
|
||||
connectorID: CONNECTOR_ID, // Business line for Coze
|
||||
};
|
||||
|
||||
const { jump } = usePageJumpService();
|
||||
@@ -449,7 +449,7 @@ const MockSetSelectComp = (
|
||||
content={getTooltipInfo()}
|
||||
visible={disabled && focused}
|
||||
position="left"
|
||||
style={{ display: disabled ? 'block' : 'none' }} // visible disabled不生效
|
||||
style={{ display: disabled ? 'block' : 'none' }} // Visible disabled not effective
|
||||
>
|
||||
<div
|
||||
style={style}
|
||||
|
||||
@@ -71,7 +71,7 @@ export const MockSetDeleteModal = ({
|
||||
} = mockSetInfo || {};
|
||||
const [mockSetRefCount, setMockSetRefCount] = useState(-1);
|
||||
|
||||
// space信息
|
||||
// Space information
|
||||
const spaceType = useSpaceStore(s => s.space.space_type);
|
||||
const isPersonal = spaceType === SpaceType.Personal;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ export enum BranchType {
|
||||
type BranchInfo = Record<
|
||||
string,
|
||||
| {
|
||||
// 纵向连接线
|
||||
// Longitudinal cable
|
||||
v: BranchType[];
|
||||
isLast: boolean;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ export function useGenTreeBranch(mockData?: MockDataWithStatus) {
|
||||
const [branchInfo, setBranchInfo] = useState<BranchInfo>({});
|
||||
const [pruned, setPruned] = useState<MockDataWithStatus>();
|
||||
|
||||
// 裁剪树枝
|
||||
// Cut branches
|
||||
// @ts-expect-error -- linter-disable-autofix
|
||||
const pruning = (data?: MockDataWithStatus) => {
|
||||
if (!data?.children) {
|
||||
|
||||
@@ -89,7 +89,7 @@ const useMockSetInSettingModalController = ({
|
||||
() => ({
|
||||
...bizSceneCtx,
|
||||
connectorUID: uid,
|
||||
connectorID: CONNECTOR_ID, // 业务线为Coze
|
||||
connectorID: CONNECTOR_ID, // Business line for Coze
|
||||
}),
|
||||
[bizSceneCtx, uid, CONNECTOR_ID],
|
||||
);
|
||||
|
||||
@@ -123,7 +123,7 @@ export function useSaveMockData({
|
||||
}
|
||||
|
||||
if (successRes.length === 0) {
|
||||
// 仅全部失败时认为失败,此时需要 toast 提示
|
||||
// Only if all fail, it is considered a failure, and a toast prompt is required at this time.
|
||||
Toast.error({
|
||||
content: withSlardarIdButton(
|
||||
failRes[0]?.error?.message || I18n.t('error'),
|
||||
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
|
||||
import { getMergedDataWithStatus } from '../util/utils';
|
||||
|
||||
/** 缓存最新一个解析结果 */
|
||||
/** cache the latest parsing result */
|
||||
const cache: {
|
||||
schema: string;
|
||||
result: MockDataWithStatus | undefined;
|
||||
@@ -92,7 +92,7 @@ export function useTransSchema(schema?: string, currentMock?: string) {
|
||||
}
|
||||
}, [result, currentMock]);
|
||||
|
||||
// 特殊字段需要单独处理:response_for_model 不能为空字符串
|
||||
// Special fields need to be handled separately: response_for_model cannot be an empty string
|
||||
const testValueValid = useCallback(
|
||||
(value: string) => {
|
||||
if (
|
||||
@@ -118,17 +118,17 @@ export function useTransSchema(schema?: string, currentMock?: string) {
|
||||
);
|
||||
|
||||
return {
|
||||
// 由 schema 生成的结构话数据,值为初始值
|
||||
// Structured data generated by schema with initial values
|
||||
result,
|
||||
// 合并模拟数据的结构话数据,全集
|
||||
// Structural session data that merges simulated data, complete set
|
||||
mergedResult,
|
||||
// mergedResult 转换的 object
|
||||
// mergedResult converted object
|
||||
mergedResultExample,
|
||||
// 格式化的数据
|
||||
// formatted data
|
||||
formattedResultExample,
|
||||
// 是否兼容
|
||||
// Is it compatible?
|
||||
incompatible,
|
||||
// 是否合并模拟数据
|
||||
// Whether to merge analog data
|
||||
isInit: currentMock === undefined,
|
||||
testValueValid,
|
||||
};
|
||||
|
||||
@@ -34,23 +34,23 @@ export enum MockDataStatus {
|
||||
export interface MockDataWithStatus {
|
||||
/** key */
|
||||
key: string;
|
||||
/** 字段名称 */
|
||||
/** field name */
|
||||
label: string;
|
||||
/** 字段值 */
|
||||
/** field value */
|
||||
realValue?: string | number | boolean;
|
||||
/** 展示使用 */
|
||||
/** display use */
|
||||
displayValue?: string;
|
||||
/** 描述 */
|
||||
/** describe */
|
||||
description?: string;
|
||||
/** 是否必填 */
|
||||
/** Is it required? */
|
||||
isRequired: boolean;
|
||||
/** 字段数据类型 */
|
||||
/** field data type */
|
||||
type: MockDataValueType;
|
||||
/** for array */
|
||||
childrenType?: MockDataValueType;
|
||||
/** 字段状态 */
|
||||
/** Field Status */
|
||||
status: MockDataStatus;
|
||||
/** 字段子节点 */
|
||||
/** Field sub-node */
|
||||
children?: MockDataWithStatus[];
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ export function transUpperCase(str?: string) {
|
||||
return str ? `${str.slice(0, 1).toUpperCase()}${str.slice(1)}` : '';
|
||||
}
|
||||
|
||||
// 仅开发中使用
|
||||
// Only used in development
|
||||
export function sleep(t = 1000) {
|
||||
return new Promise(r => {
|
||||
setTimeout(() => {
|
||||
@@ -46,7 +46,7 @@ export function safeJSONParse<T>(str: string, errCb?: () => T | undefined) {
|
||||
}
|
||||
}
|
||||
|
||||
// 根据 value 生成 displayValue
|
||||
// Generate displayValue from value
|
||||
function getTargetValue(
|
||||
type: MockDataValueType,
|
||||
value: string | number | boolean | undefined,
|
||||
@@ -58,10 +58,10 @@ function getTargetValue(
|
||||
});
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- plugin resp 的类型由用户定义,包含任何可能
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- The type of the plugin resp is user-defined and contains any possible
|
||||
type PluginRespType = any;
|
||||
|
||||
// 合并 schema 和 mock data
|
||||
// Merge schema and mock data
|
||||
export function getMergedDataWithStatus(
|
||||
schemaData?: MockDataWithStatus,
|
||||
currentMock?: string,
|
||||
@@ -84,12 +84,12 @@ export function getMergedDataWithStatus(
|
||||
? safeJSONParse<PluginRespType>(currentMock) || currentMock
|
||||
: currentMock;
|
||||
|
||||
// 将 mock 转换为 MockDataWithStatus 格式
|
||||
// Convert mock to MockDataWithStatus format
|
||||
const processedMock = transMockData2DataWithStatus(ROOT_KEY, mock, {
|
||||
defaultStatus: MockDataStatus.REMOVED,
|
||||
});
|
||||
|
||||
// 合并
|
||||
// merge
|
||||
const { merged, incompatible } = mergeDataWithStatus(
|
||||
schemaData.children,
|
||||
processedMock?.children,
|
||||
@@ -105,7 +105,7 @@ export function getMergedDataWithStatus(
|
||||
};
|
||||
}
|
||||
|
||||
// 解析当前 realValue 所属于的 MockDataValueType
|
||||
// Parse the MockDataValueType to which the current realValue belongs
|
||||
function getMockDataType(currentMock: PluginRespType) {
|
||||
let dataTypeName = typeof currentMock as MockDataValueType | undefined;
|
||||
if (currentMock instanceof Array) {
|
||||
@@ -118,7 +118,7 @@ function compareMockDataType(
|
||||
mockDataType?: MockDataValueType,
|
||||
initDataType?: MockDataValueType,
|
||||
) {
|
||||
// mock data 的类型是根据值识别出的,存在 Integer 类型被识别为 Number 的情况
|
||||
// The type of mock data is recognized by value, and there are cases where the Integer type is recognized as Number.
|
||||
if (mockDataType === MockDataValueType.NUMBER) {
|
||||
return (
|
||||
initDataType === MockDataValueType.NUMBER ||
|
||||
@@ -129,7 +129,7 @@ function compareMockDataType(
|
||||
}
|
||||
}
|
||||
|
||||
// 转换 Object 格式到 DataWithStatus 格式
|
||||
// Convert Object format to DataWithStatus format
|
||||
export function transMockData2DataWithStatus(
|
||||
label: string,
|
||||
currentMock: PluginRespType,
|
||||
@@ -262,8 +262,8 @@ function merge2DataList(
|
||||
}
|
||||
}
|
||||
|
||||
// 在合并 array 时,会出现 autoInitDataList(originData) 中只存在一个初始化数据,而 mockDataListWithStatus(appendData) 存在多个相同结构的数据
|
||||
// 需要将 mockDataListWithStatus 中剩余的数据进行合入
|
||||
// When combining arrays, it appears that only one initialization data exists in autoInitDataList (originData), while mockDataListWithStatus (appendData) has multiple data of the same structure
|
||||
// The remaining data in the mockDataListWithStatus needs to be incorporated
|
||||
if (appendData.length && isArrayType) {
|
||||
const target = autoInitDataList[0];
|
||||
appendData.forEach(item => {
|
||||
@@ -285,7 +285,7 @@ function merge2DataList(
|
||||
};
|
||||
}
|
||||
|
||||
// 合并两个 MockDataWithStatus 数组,以 autoInitDataList 顺序优先
|
||||
// Merge two MockDataWithStatus arrays, in autoInitDataList order first
|
||||
export function mergeDataWithStatus(
|
||||
autoInitDataList?: MockDataWithStatus[],
|
||||
mockDataListWithStatus?: MockDataWithStatus[],
|
||||
@@ -301,7 +301,7 @@ export function mergeDataWithStatus(
|
||||
};
|
||||
}
|
||||
|
||||
// 在合并 array 时,存在 mockDataListWithStatus 为空的情况,此时直接判断
|
||||
// When merging the array, there is a situation where the mockDataListWithStatus is empty. At this time, it is directly judged
|
||||
if (mockDataListWithStatus.length === 0 && isArrayType) {
|
||||
return {
|
||||
merged: [],
|
||||
|
||||
Reference in New Issue
Block a user