chore: replace all cn comments of fe to en version by volc api (#320)

This commit is contained in:
tecvan
2025-07-31 10:32:15 +08:00
committed by GitHub
parent 716ec0cba8
commit 71f6245a01
2960 changed files with 15545 additions and 15545 deletions

View File

@@ -37,7 +37,7 @@ interface AutoFillButtonProps {
onAutoFill?: (schemas: NodeFormSchema[]) => void;
}
/** AI生成节点数据的按钮 */
/** AI button to generate node data */
export function AutoFillButton({
className,
style,
@@ -79,7 +79,7 @@ export function AutoFillButton({
abortRef.current?.abort();
};
// 社区版暂不支持该功能
// The community edition does not support this function for the time being
if (!FLAGS['bot.devops.testset_auto_gen'] || !(IS_OVERSEA || IS_BOE)) {
return null;
}

View File

@@ -28,7 +28,7 @@ interface FormLabelProps {
style?: CSSProperties;
}
// 内置的FormLabel样式不支持 typeLabel所以简单自定义
// The built-in FormLabel style does not support typeLabel, so it is easy to customize
export function FormLabel({
label,
typeLabel,

View File

@@ -70,7 +70,7 @@ interface TestsetEditSideSheetProps extends TestsetEditState {
onClose?: () => void;
onSuccess?: (testset?: TestsetData) => void;
onCancel?: () => void;
/** 是否为多人协作模式 */
/** Is it a multiplayer collaboration mode? */
isExpertMode?: boolean;
}
@@ -78,10 +78,10 @@ const TESTSET_NAME_FIELD = '__TESTSET_NAME__';
const TESTSET_DESC_FIELD = '__TESTSET_DESC__';
/**
* 特化逻辑:表单项赋默认值
* - Boolean类型:`false` 因为undefined的表现上和false一样容易引发用户误解
* - Object类型:`{}`
* - Array类型: `[]`
* Specialized logic: list entries are assigned default values
* - Boolean type: 'false' because undefined behaves the same as false, which is easy to cause user misunderstandings
* - Object type: '{}'
* - Array type: '[]'
*/
function assignDefaultValue(ipt: FormItemSchema) {
if (!isNil(ipt.value)) {
@@ -140,7 +140,7 @@ export function TestsetEditSideSheet({
const remoteSchemas = toNodeFormSchemas(res.schemaJson);
if (localSchemas.length) {
// 编辑模式比对本地和远程schema并尝试赋值
// Edit schema: compare local and remote schemas and try to assign values
const localSchemaMap: Record<string, FormItemSchema | undefined> = {};
traverseNodeFormSchemas(
localSchemas,
@@ -156,7 +156,7 @@ export function TestsetEditSideSheet({
}
});
} else {
// 创建模式:赋默认值
// Creation mode: assigns default values
traverseNodeFormSchemas(remoteSchemas, (schema, ipt) => {
assignDefaultValue(ipt);
});
@@ -178,7 +178,7 @@ export function TestsetEditSideSheet({
});
}, [visible, testset]);
// 给节点表单设置值
// Set a value for the node form
useEffect(() => {
if (typeof nodeSchemas === 'undefined') {
return;
@@ -260,7 +260,7 @@ export function TestsetEditSideSheet({
}
};
// 提交表单
// Submit Form
const onSubmit = async () => {
setSubmitting(true);
try {
@@ -278,7 +278,7 @@ export function TestsetEditSideSheet({
ipt.value = val;
}
// 清除 object/array的空值,包括空字符串
// Clears null values of objects/arrays, including empty strings
if (
!val &&
(ipt.type === FormItemSchemaType.LIST ||
@@ -287,7 +287,7 @@ export function TestsetEditSideSheet({
ipt.value = undefined;
}
// bool 类型 需要将枚举转为布尔值
// Bool type, you need to convert the enumeration to a boolean
if (ipt.type === FormItemSchemaType.BOOLEAN) {
ipt.value = transBoolSelect2Bool(ipt.value as ValuesForBoolSelect);
}
@@ -330,7 +330,7 @@ export function TestsetEditSideSheet({
});
testsetFormApi.current?.setValues(formValues);
// 设置值之后再校验一次
// Check again after setting the value
testsetFormApi.current?.validate(validateFields);
};

View File

@@ -41,7 +41,7 @@ import s from './node-form-section.module.less';
interface NodeFormSectionProps {
schema: NodeFormSchema;
/** AI生成中 */
/** AI is being generated */
autoGenerating?: boolean;
className?: string;
style?: CSSProperties;
@@ -49,7 +49,7 @@ interface NodeFormSectionProps {
const { Section, InputNumber } = Form;
/** 整数类型表单精度 */
/** integer type form precision */
const INTEGER_PRECISION = 0.1;
export function NodeFormSection({
@@ -62,7 +62,7 @@ export function NodeFormSection({
const renderSectionTitle = () => {
let sectionName = schema.component_name;
// 目前只有start和variable两种节点
// Currently only two nodes are start and variable
switch (schema.component_type) {
case ComponentType.CozeStartNode:
sectionName = I18n.t('workflow_testset_start_node');

View File

@@ -28,7 +28,7 @@ function count(val: unknown) {
return val ? `${val}`.length : 0;
}
/** 需要后缀 & blur trim,扩展下原始的input */
/** The suffix & blur trim is required to expand the original input */
function InnerInput(props: InputProps) {
const onBlur = (evt: FocusEvent<HTMLInputElement>) => {
props.onChange?.(

View File

@@ -33,7 +33,7 @@ import {
} from '../../types';
let ajv: Ajv | undefined;
/** jsonStr转为节点表单schema简单的`JSON.parse` */
/** jsonStr converts to a node form schema (simply'JSON.parse ') */
export function toNodeFormSchemas(jsonStr?: string): NodeFormSchema[] {
if (!jsonStr) {
return [];
@@ -48,7 +48,7 @@ export function toNodeFormSchemas(jsonStr?: string): NodeFormSchema[] {
}
}
/** 空值判断,null/undefined/NaN */
/** Null value judgment, null/undefined/NaN */
export function isNil(val: unknown) {
return (
typeof val === 'undefined' ||
@@ -61,7 +61,7 @@ function isNumberType(t: string) {
return t === FormItemSchemaType.NUMBER || t === FormItemSchemaType.FLOAT;
}
/** 判断类型一致,**特化:**`number`和`float`视为同一类型 */
/** Determine that the type is consistent, ** specialization: ** 'number' and'float 'are regarded as the same type */
export function isSameType(t1?: string, t2?: string) {
if (typeof t1 === 'undefined' || typeof t2 === 'undefined') {
return false;
@@ -70,7 +70,7 @@ export function isSameType(t1?: string, t2?: string) {
return isNumberType(t1) ? isNumberType(t2) : t1 === t2;
}
/** 两层for遍历schema (经常需要遍历,单独抽一个的函数) */
/** Two layers for traversing schema (often need to traverse, draw a single function) */
export function traverseNodeFormSchemas(
schemas: NodeFormSchema[],
cb: (s: NodeFormSchema, ip: FormItemSchema) => any,
@@ -83,9 +83,9 @@ export function traverseNodeFormSchemas(
}
/**
* 校验名称格式(参考插件名称)
* - 海外:仅支持输入字母、数字、下划线或空格
* - 国内:仅支持输入中文、字母、数字、下划线或空格
* Verification name format (refer to plug-in name)
* - Overseas: Only support entering letters, numbers, underscores or spaces
* - Domestic: Only supports entering Chinese, letters, numbers, underscores or spaces
*/
function validateNamePattern(
name: string,
@@ -109,19 +109,19 @@ interface GetTestsetNameRulesProps {
bizCtx?: BizCtx;
/** bizComponentSubject */
bizComponentSubject?: ComponentSubject;
/** 原始值 */
/** raw value */
originVal?: string;
/** 是否为海外(海外不允许输入中文 与PluginName校验规则对齐 */
/** Whether it is overseas (overseas is not allowed to enter Chinese, it is aligned with the PluginName verification rule) */
isOversea?: boolean;
}
/**
* Testset名称表单校验规则
* TestSet Name Form Validation Rules
*
* @param param.bizCtx - bizCtx
* @param param.bizComponentSubject - bizComponentSubject
* @param param.originVal - 原始值
* @param param.isOversea - 是否为海外(海外不允许输入中文 与PluginName校验规则对齐
* @Param param.originVal - original value
* @Param param.isOverseas - whether it is overseas (overseas is not allowed to enter Chinese, it is aligned with the PluginName verification rule)
*/
export function getTestsetNameRules({
bizCtx,
@@ -143,12 +143,12 @@ export function getTestsetNameRules({
return;
}
// 编辑模式下,名称与原名相同时跳过
// In edit mode, skip when the name is the same as the original name
if (originVal && value === originVal) {
return;
}
// 中文、字母等等等等
// Chinese, letters, etc., etc
const formatMsg = validateNamePattern(value, isOversea);
if (formatMsg) {
@@ -156,7 +156,7 @@ export function getTestsetNameRules({
return;
}
// 检查重复
// Check for duplicates
try {
const { isPass } = await debuggerApi.CheckCaseDuplicate({
bizCtx,
@@ -179,9 +179,9 @@ export function getTestsetNameRules({
}
/**
* 表单label
* - bot选择你需要的Bot
* - 其他:字段名
* Form label
* - bot: choose the bot you need
* - Other: field names
*/
export function getLabel(formSchema: FormItemSchema) {
return formSchema.type === FormItemSchemaType.BOT
@@ -207,7 +207,7 @@ function getSubType(type: string) {
}
}
/** 类型标签 */
/** type label */
export function getTypeLabel(formSchema: FormItemSchema) {
switch (formSchema.type) {
case FormItemSchemaType.STRING:
@@ -230,8 +230,8 @@ export function getTypeLabel(formSchema: FormItemSchema) {
/**
* placeholder
* - bot:请选择bot
* - 其他xx必填
* - bot: Please select bot
* - Other: xx required
*/
export function getPlaceholder({ name, type }: FormItemSchema) {
if (type === FormItemSchemaType.BOT) {
@@ -245,7 +245,7 @@ export function getPlaceholder({ name, type }: FormItemSchema) {
});
}
/** 字段在表单中的唯一字段名 */
/** The unique field name of the field in the form */
export function getSubFieldName(
formSchema: NodeFormSchema,
itemSchema: FormItemSchema,
@@ -322,8 +322,8 @@ function validateByJsonSchema(val: any, jsonSchema: any) {
}
/**
* 自定义表单的额外参数
* 目前只对array和object表单加jsonSchema校验
* Customize the form's additional parameters
* Currently only jsonSchema validation is applied to array and object forms
*/
export function getCustomProps(formItemSchema: FormItemSchema) {
switch (formItemSchema.type) {
@@ -368,7 +368,7 @@ export enum ValuesForBoolSelect {
UNDEFINED = 'undefined',
}
/** 布尔类型选项 */
/** Boolean Type Options */
export const optionsForBoolSelect = [
{
value: ValuesForBoolSelect.TRUE,

View File

@@ -42,7 +42,7 @@
}
.semi-select-option-list {
/* stylelint-disable-next-line declaration-no-important -- semi-select-option-listmax-height写在了style上所以要important覆盖 */
/* stylelint-disable-next-line declaration-no-important -- semi-select-option-list max-height is written on style, so override important */
max-height: 208px !important;
&::-webkit-scrollbar-track {

View File

@@ -43,12 +43,12 @@ import {
import s from './index.module.less';
export interface TestsetSelectProps {
/** 当前testset */
/** Current testset */
testset: TestsetData | undefined;
placeholder?: string;
/** 是否有workflow编辑权限也挂放在外层的 TestsetManageProvider上组件上的editable优先级更高 */
/** Whether there is workflow editing permission, it is also hung on the outer TestsetManageProvider, and the editable priority on the component is higher */
editable?: boolean;
/** 编辑面板mask */
/** Edit panel mask */
editSideSheetMask?: boolean;
onSelect: (v?: TestsetData) => void;
className?: string;
@@ -57,7 +57,7 @@ export interface TestsetSelectProps {
const DEBOUNCE_DELAY = 200;
/** option key, 更新 nameincompatibleinput时都要重新渲染 */
/** Option key, re-render when updating name, incompatible, input */
function getOptionKey({ caseBase, schemaIncompatible }: TestsetData) {
return `${caseBase?.caseID}_${caseBase?.name}_${caseBase?.input}_${
schemaIncompatible ? 0 : 1
@@ -65,12 +65,12 @@ function getOptionKey({ caseBase, schemaIncompatible }: TestsetData) {
}
/**
* Testset下拉选择组件
* 需配合`TestsetManageProvider`一起使用
* TestSet drop-down selection component
* Should be used with TestsetManageProvider
* @example
* ``` tsx
* <TestsetManageProvider
* // 一些必填参数 bizCtx bizComponentSubject editable formRenders
* //Some required parameters bizCtx bizComponentSubject editable formRendersitable formRenders
* >
* <TestsetSideSheet visible={visible} onClose={() => setVisible(false)} />
* </TestsetManageProvider>
@@ -107,7 +107,7 @@ export function TestsetSelect({
{},
);
// 首次加载
// first load
useEffect(() => {
(async () => {
setPending(true);
@@ -153,7 +153,7 @@ export function TestsetSelect({
closeTestsetEdit();
};
// 选中Testset
// Select Testset
const onSelectTestset = (val: SelectProps['value']) => {
if (typeof val !== 'string' || editRef.current) {
return;
@@ -163,7 +163,7 @@ export function TestsetSelect({
op => op.caseBase?.caseID === val,
);
// 不兼容的不可选中
// Incompatible unselectable
if (!selectedTestset || selectedTestset.schemaIncompatible) {
return;
}
@@ -220,11 +220,11 @@ export function TestsetSelect({
}
};
// 自定义选中选项
// Custom selected options
const renderSelectedItem: RenderSingleSelectedItemFn = () =>
testset ? <SelectedTestsetOptionItem data={testset} /> : null;
// testset为空的时候不展示下拉选项对大部分来说可能不需要看到这个下拉
// When the testset is empty, the drop-down option is not displayed (for most people, you may not need to see this drop-down).
if (pending) {
return null;
}
@@ -258,8 +258,8 @@ export function TestsetSelect({
{optionsData.list.map(data => (
<Select.Option
value={data.caseBase?.caseID}
// disabledoption编辑/删除唤起其他浮层后select不会自动失焦
// 用样式模拟disabled并修改onSelect选中不兼容testset的逻辑
// Disabled option Edit/Delete to select without auto-out of focus after evoking other floating layers
// Simulate disabled with styles and modify the logic of onSelect selecting incompatible testsets
className={cls(data.schemaIncompatible && s['incompatible-option'])}
key={getOptionKey(data)}
>

View File

@@ -32,7 +32,7 @@ import s from './testset-option-item.module.less';
interface TestsetOptionItemProps {
className?: string;
data: TestsetData;
/** 有编辑权限 */
/** Have editing permission */
editable?: boolean;
onEdit?: (data: TestsetData) => void;
onDelete?: (data: TestsetData) => void;
@@ -40,7 +40,7 @@ interface TestsetOptionItemProps {
const { Text } = Typography;
/** 多行文本展示优化 */
/** multi-line text display optimization */
const MULTILINE_TOOLTIP_STYLE: CSSProperties = { wordBreak: 'break-word' };
export function TestsetOptionItem({
@@ -54,7 +54,7 @@ export function TestsetOptionItem({
const testsetName = data.caseBase?.name ?? '-';
const onOptionClick = (evt: MouseEvent<HTMLDivElement>) => {
// 非兼容时需要阻止冒泡
// Bubbling needs to be prevented when incompatible
if (incompatible) {
evt.preventDefault();
evt.stopPropagation();
@@ -123,7 +123,7 @@ export function TestsetOptionItem({
);
}
/** 选中的回填项 */
/** Selected backfill */
export function SelectedTestsetOptionItem({
data,
className,

View File

@@ -52,7 +52,7 @@ export interface TestsetSideSheetProps {
visible: boolean;
editable?: boolean;
onClose: () => void;
/** 是否为多人协作模式 */
/** Is it a multiplayer collaboration mode? */
isExpertMode?: boolean;
}
@@ -89,19 +89,19 @@ interface TestsetQueryResult {
const DEFAULT_PAGE_SIZE = 30;
/**
* Testset管理侧边面板
* 需配合`TestsetManageProvider`一起使用
* Testset Management Side Panel
* Should be used with TestsetManageProvider
*
* @example
* ``` tsx
* <TestsetManageProvider
* // 一些必填参数 bizCtx bizComponentSubject editable formRenders
* //Some required parameters bizCtx bizComponentSubject editable formRendersitable formRenders
* >
* <TestsetSideSheet visible={visible} onClose={() => setVisible(false)} />
* </TestsetManageProvider>
* ```
*/
// eslint-disable-next-line @coze-arch/max-line-per-function -- 大组件>150行只超了不到5行哈
// eslint-disable-next-line @coze-arch/max-line-per-function -- large components > 150 lines, only less than 5 lines
export function TestsetSideSheet({
visible,
onClose,
@@ -142,7 +142,7 @@ export function TestsetSideSheet({
if (visible) {
patchTestsetResp({ list: [] });
reloadTestsetList();
// 检查schema
// Check schema
checkSchema();
}
}, [visible]);
@@ -240,7 +240,7 @@ export function TestsetSideSheet({
return (
<>
{/* Testset管理侧边面板 */}
{/* Testset Management Side Panel */}
<SideSheet
className={s.sidesheet}
title={
@@ -267,7 +267,7 @@ export function TestsetSideSheet({
<AutoLoadMore noMore={noMore} loadingMore={loadingMore} />
</div>
</SideSheet>
{/* Testset创建/编辑侧边面板 */}
{/* Testset Create/Edit Side Panel */}
<TestsetEditSideSheet
{...testsetEditState}
mask={false}

View File

@@ -39,9 +39,9 @@ import s from './testset-list-item.module.less';
interface TestsetListItemProps {
data: TestsetData;
onEdit?: (data: TestsetData) => void;
/** 点击了删除 */
/** I clicked delete. */
onClickDelete?: () => void;
/** 确认删除 */
/** Confirm deletion */
onDelete?: (data: TestsetData) => Promise<void>;
}

View File

@@ -15,8 +15,8 @@
*/
export enum TestsetManageEventName {
/** 创建测试集成功 */
/** Created test set successfully */
CREATE_TESTSET_SUCCESS = 'create_testset_success',
/** 点击AI生成节点入参 */
/** Click AI to generate node imported parameters */
AIGC_PARAMS_CLICK = 'aigc_params_click',
}

View File

@@ -37,7 +37,7 @@ export enum SchemaError {
INVALID = 'invalid',
}
/** 变量命名校验规则(对齐workflow得参数名校验) */
/** Variable name verification rules (parameter name verification for aligned workflow) */
const PARAM_NAME_VALIDATION_RULE =
/^(?!.*\b(true|false|and|AND|or|OR|not|NOT|null|nil|If|Switch)\b)[a-zA-Z_][a-zA-Z_$0-9]*$/;
@@ -112,21 +112,21 @@ function checkArrayOrObjectField(field: FormItemSchema) {
}
function checkNodeFormSchema(schema: NodeFormSchema) {
// 节点参数为空
// Node parameter is empty
if (!schema.inputs.length) {
return false;
}
const nameSet = new Set<string>();
for (const ipt of schema.inputs) {
// 名称非法 or 重复
// Name illegal or duplicate
if (!validateParamName(ipt.name) || nameSet.has(ipt.name)) {
return false;
}
nameSet.add(ipt.name);
// 单独检测复杂类型
// Detect complex types individually
if (!checkArrayOrObjectField(ipt)) {
return false;
}
@@ -143,7 +143,7 @@ function validateSchema(json?: string) {
try {
const schemas = JSON.parse(json) as NodeFormSchema[];
// schema为空 or start节点的inputs为空
// Schema is empty or start node inputs are empty
const isEmpty =
schemas.length === 0 ||
(schemas[0].component_type === ComponentType.CozeStartNode &&
@@ -166,7 +166,7 @@ function validateSchema(json?: string) {
}
}
/** 检查workflow节点表单是否为空(schema为空 or start节点的inputs为空) */
/** Checks if the workflow node form is empty (schema is empty or start node inputs are empty) */
export function useCheckSchema() {
const { bizComponentSubject, bizCtx } = useTestsetManageStore(store => store);
const [schemaError, setSchemaError] = useState(SchemaError.OK);

View File

@@ -26,11 +26,11 @@ import { type TestsetManageEventName } from './events';
export interface TestsetManageState {
bizCtx?: BizCtx;
bizComponentSubject?: ComponentSubject;
/** 编辑权限 */
/** edit permission */
editable?: boolean;
/** 表单渲染组件 */
/** form rendering component */
formRenders?: Partial<Record<FormItemSchemaType, NodeFormItem>>;
/** 埋点事件上报 */
/** Event tracking event reporting */
reportEvent?: (
name: TestsetManageEventName,
params?: Record<string, unknown>,
@@ -38,7 +38,7 @@ export interface TestsetManageState {
}
export interface TestsetManageAction {
/** 更新状态 */
/** update status */
patch: (s: Partial<TestsetManageState>) => void;
}

View File

@@ -47,13 +47,13 @@ export type ObjectFieldSchema = {
}[];
export interface FormItemSchema {
// 扩展为枚举
// Expand to enumeration
type: string;
name: string;
description?: string;
required?: boolean;
value?: string | number | boolean;
/** object/array复杂类型有schema定义 */
/** Object/array complex types have schema definitions */
schema?: ArrayFieldSchema | ObjectFieldSchema;
}