Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/filterRules/__tests__/filterRules.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const MyInput = ({ rowValues: { input }, rowKey, onChange }: IComponentProps<IRo
<Input value={input} onChange={(e) => onChange?.(rowKey, { input: e.target.value })} />
);

jest.mock('remark-gfm', () => () => {});
describe('FilterRules', () => {
test('should support FilterRules success render', () => {
const wrapper = render(
Expand Down
4 changes: 0 additions & 4 deletions src/filterRules/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
rowKey: string; // 当前节点的唯一标识
Expand Down
15 changes: 9 additions & 6 deletions src/filterRules/ruleController/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
Expand Down Expand Up @@ -46,6 +42,13 @@ export const RulesController = <T,>(props: IProps<T>) => {
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<T>) =>
item?.type &&
[ROW_PERMISSION_RELATION.AND, ROW_PERMISSION_RELATION.OR].includes(item?.type);
Expand Down
2 changes: 2 additions & 0 deletions src/locale/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const localeValues: Locale = {
},
FilterRules: {
message: 'Must have one data item',
and: 'And',
or: 'Or',
},
Fullscreen: {
exitFull: 'Exit Full Screen',
Expand Down
2 changes: 2 additions & 0 deletions src/locale/useLocale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export interface Locale {
};
FilterRules: {
message: string;
and: string;
or: string;
};
Fullscreen: { exitFull: string; full: string };
GlobalLoading: { loading: string };
Expand Down
2 changes: 2 additions & 0 deletions src/locale/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const localeValues: Locale = {
},
FilterRules: {
message: '必须有一条数据',
and: '且',
or: '或',
},
Fullscreen: {
exitFull: '退出全屏',
Expand Down
Loading