diff --git a/src/filterRules/__tests__/filterRules.test.tsx b/src/filterRules/__tests__/filterRules.test.tsx index 5d8693740..c02057d66 100644 --- a/src/filterRules/__tests__/filterRules.test.tsx +++ b/src/filterRules/__tests__/filterRules.test.tsx @@ -10,6 +10,7 @@ const MyInput = ({ rowValues: { input }, rowKey, onChange }: IComponentProps onChange?.(rowKey, { input: e.target.value })} /> ); +jest.mock('remark-gfm', () => () => {}); describe('FilterRules', () => { test('should support FilterRules success render', () => { const wrapper = render( diff --git a/src/filterRules/index.tsx b/src/filterRules/index.tsx index 12f25def7..17a510838 100644 --- a/src/filterRules/index.tsx +++ b/src/filterRules/index.tsx @@ -11,10 +11,6 @@ export enum ROW_PERMISSION_RELATION { AND = 1, OR = 2, } -export const ROW_PERMISSION_RELATION_TEXT = { - [ROW_PERMISSION_RELATION.AND]: '且', - [ROW_PERMISSION_RELATION.OR]: '或', -}; export interface IComponentProps { rowKey: string; // 当前节点的唯一标识 diff --git a/src/filterRules/ruleController/index.tsx b/src/filterRules/ruleController/index.tsx index 60af663d1..bc3cf544b 100644 --- a/src/filterRules/ruleController/index.tsx +++ b/src/filterRules/ruleController/index.tsx @@ -3,12 +3,8 @@ import { MinusCircleOutlined, PlusCircleOutlined } from '@dtinsight/react-icons' import { InternalNamePath } from 'antd/lib/form/interface'; import classnames from 'classnames'; -import { - IComponentProps, - IFilterValue, - ROW_PERMISSION_RELATION, - ROW_PERMISSION_RELATION_TEXT, -} from '..'; +import useLocale from '../../locale/useLocale'; +import { IComponentProps, IFilterValue, ROW_PERMISSION_RELATION } from '..'; import './index.scss'; interface IProps { @@ -46,6 +42,13 @@ export const RulesController = (props: IProps) => { onChangeRowValues, } = props; + const locale = useLocale('FilterRules'); + + const ROW_PERMISSION_RELATION_TEXT = { + [ROW_PERMISSION_RELATION.AND]: locale.and, + [ROW_PERMISSION_RELATION.OR]: locale.or, + }; + const isCondition = (item: IFilterValue) => item?.type && [ROW_PERMISSION_RELATION.AND, ROW_PERMISSION_RELATION.OR].includes(item?.type); diff --git a/src/locale/en-US.ts b/src/locale/en-US.ts index 6f44cbf28..710db3f96 100644 --- a/src/locale/en-US.ts +++ b/src/locale/en-US.ts @@ -27,6 +27,8 @@ const localeValues: Locale = { }, FilterRules: { message: 'Must have one data item', + and: 'And', + or: 'Or', }, Fullscreen: { exitFull: 'Exit Full Screen', diff --git a/src/locale/useLocale.tsx b/src/locale/useLocale.tsx index 9d57f29e2..d61c050e0 100644 --- a/src/locale/useLocale.tsx +++ b/src/locale/useLocale.tsx @@ -21,6 +21,8 @@ export interface Locale { }; FilterRules: { message: string; + and: string; + or: string; }; Fullscreen: { exitFull: string; full: string }; GlobalLoading: { loading: string }; diff --git a/src/locale/zh-CN.ts b/src/locale/zh-CN.ts index 6e3e55449..a5f00b461 100644 --- a/src/locale/zh-CN.ts +++ b/src/locale/zh-CN.ts @@ -28,6 +28,8 @@ const localeValues: Locale = { }, FilterRules: { message: '必须有一条数据', + and: '且', + or: '或', }, Fullscreen: { exitFull: '退出全屏',