Skip to content

Commit

Permalink
Feat node transform (#648)
Browse files Browse the repository at this point in the history
* fix: node transform

* fix: node transform

* feat: getTransformMethod

* feat: system advanced setting comparePluginUrl

* feat: getTransformMethod

* feat: system advanced setting comparePluginUrl

* fix: get root json value (#646)

Co-authored-by: onePone <[email protected]>

* Fix bug 0321 (#647)

* fix: report Select suffixIcon is not propagable

* feat: persist collection

* feat: persist collection

* fix: replay case filter

* fix: replay case filter

* fix: collection initial

* fix: await create case inherit from interface

* feat: collection search

* feat: dynamic class tooltip massage

* feat: user avatar

* fix: get root json value (#646)

Co-authored-by: onePone <[email protected]>

---------

Co-authored-by: onePone <[email protected]>

---------

Co-authored-by: onePone <[email protected]>
  • Loading branch information
1pone and Xremn authored Mar 27, 2024
1 parent 11cd78b commit e47ee13
Show file tree
Hide file tree
Showing 17 changed files with 635 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/arex/src/i18n/locales/cn/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"replay": "回放",
"title": "标题",
"untitled": "未命名",
"select": "选择",
"close": "关闭",
"cancel": "取消",
"clearAll": "全部清除",
Expand Down
14 changes: 13 additions & 1 deletion packages/arex/src/i18n/locales/cn/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
"nodesSort": "数组节点",
"nodesDesensitization": "加密节点",
"categoryIgnore": "类型忽略",
"nodesTransform": "转换节点",
"global": "全局",
"interface": "接口",
"dependency": "依赖",
Expand Down Expand Up @@ -360,7 +361,16 @@
"chooseCategoryType": "请选择忽略类型(可多选)",
"categoryTypePlaceholder": "请选择依赖类型",
"operationNamePlaceholder" : "请输入依赖名称",
"environment": "环境"
"environment": "环境",
"originalNode":"原始节点",
"transformedNode":"转换节点",
"addTransformNode":"添加转换节点",
"transformNodePath": "节点路径",
"transformMethodName":"方法名称",
"transformMethodArgs":"方法参数",
"selectNodePath": "选择节点路径",
"clickToSelectNodePath": "点击选择转换节点路径",
"deleteTransformConfirm": "确定删除该转换节点?"
},
"env": {
"searchEnvironment": "搜索环境",
Expand Down Expand Up @@ -448,6 +458,8 @@
"jarFileUrlPlaceholder": "请输入 Jar 包地址",
"replayCallback": "回放回调",
"replayCallbackPlaceholder": "请输入回放回调地址",
"comparePlugin": "对比插件",
"comparePluginPlaceholder": "请输入对比插件 Jar 包地址",
"systemLogs": "系统日志",
"openSystemLogs": "打开系统日志",
"application": "应用",
Expand Down
1 change: 1 addition & 0 deletions packages/arex/src/i18n/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"title": "Title",
"untitled": "Untitled",
"help": "Help",
"select": "Select",
"close": "Close",
"cancel": "Cancel",
"clearAll": "Clear All",
Expand Down
14 changes: 13 additions & 1 deletion packages/arex/src/i18n/locales/en/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
"nodesSort": "Nodes Sort",
"nodesDesensitization": "Nodes Desensitization",
"categoryIgnore": "Category Ignore",
"nodesTransform": "Nodes Transform",
"global": "Global",
"interface": "Interfaces",
"dependency": "Dependency",
Expand Down Expand Up @@ -362,7 +363,16 @@
"chooseCategoryType": "Please select the type of ignore (multiple)",
"categoryTypePlaceholder": "Please select the type of category",
"operationNamePlaceholder" : "Please select the name of operation",
"environment": "Environment"
"environment": "Environment",
"originalNode":"Original Node",
"transformedNode":"Transformed Node",
"addTransformNode":"Add Transform Node",
"transformNodePath": "Node Path",
"transformMethodName":"Method name",
"transformMethodArgs":"Method args",
"selectNodePath": "Select Node Path",
"clickToSelectNodePath": "Click to select transformed node path",
"deleteTransformConfirm": "Are you sure to delete this transform node?"
},
"env": {
"searchEnvironment": "Search Environment",
Expand Down Expand Up @@ -450,6 +460,8 @@
"jarFileUrlPlaceholder": "Please enter Jar file Url",
"replayCallback": "Replay Callback",
"replayCallbackPlaceholder": "Please enter replay callback Url",
"comparePlugin": "Compare Plugin",
"comparePluginPlaceholder": "Please enter compare plugin Jar file Url",
"systemLogs": "System Logs",
"openSystemLogs": "Open System Logs",
"application": "Application",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import React, { FC, useMemo } from 'react';
import { getIgnoreNodes } from './utils';

type IgnoreTreeProps = Omit<TreeProps, 'treeData'> & {
title?: React.ReactNode;
loading?: boolean;
treeData: object;
lineThrough?: boolean;
};

const IgnoreTreeWrapper = styled.div`
const IgnoreTreeWrapper = styled.div<{ lineThrough?: boolean }>`
.ant-tree-node-selected {
text-decoration: line-through;
text-decoration: ${(props) => (props.lineThrough ? 'line-through' : 'none')};
}
`;

Expand All @@ -21,8 +23,8 @@ const IgnoreTree: FC<IgnoreTreeProps> = (props) => {
const treeData = useMemo(() => getIgnoreNodes(props.treeData, ''), [props.treeData]);

return (
<IgnoreTreeWrapper>
<Card size='small' title={t('appSetting.clickToIgnore')}>
<IgnoreTreeWrapper lineThrough={props.lineThrough}>
<Card size='small' title={props.title}>
<EmptyWrapper
loading={props.loading}
empty={!Object.keys(props.treeData).length}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,9 @@ const NodesIgnore: FC<NodesIgnoreProps> = (props) => {
>
<IgnoreTree
// TODO auto expand failed
lineThrough
defaultExpandAll
title={t('appSetting.clickToIgnore')}
loading={props.loadingContract}
treeData={props.contractParsed}
selectedKeys={checkedNodesData.exclusionsList}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
import {
CloseOutlined,
DeleteOutlined,
EditOutlined,
PlusOutlined,
SaveOutlined,
VerticalAlignBottomOutlined,
VerticalAlignTopOutlined,
} from '@ant-design/icons';
import { SmallTextButton, TooltipButton, useTranslation } from '@arextest/arex-core';
import {
Button,
Card,
Flex,
Input,
InputRef,
Popconfirm,
Select,
SelectProps,
Space,
Steps,
theme,
} from 'antd';
import React, { FC, ReactNode, useEffect, useRef } from 'react';

import { Icon } from '@/components';
import { TransformNode } from '@/services/ComparisonService';

export interface TransformCardProps {
edit?: boolean;
data: Partial<TransformNode>;
options?: SelectProps<string>['options'];
onNodePathChange?: (path: string[]) => void;
onPathLocationClick?: () => void;
onMethodNameChange?: (value: string, methodIndex: number) => void;
onMethodArgsChange?: (value: string, methodIndex: number) => void;
onInsertBefore?: (methodIndex: number) => void;
onInsertAfter?: (methodIndex: number) => void;
onDrop?: (methodIndex: number) => void;
onAdd?: () => void;
onSave?: () => void;
onEdit?: () => void;
onCancel?: () => void;
onDelete?: (id: string) => void;
}

const TransformCard: FC<TransformCardProps> = (props) => {
const { t } = useTranslation('components');
const { token } = theme.useToken();

const nodePathRef = useRef<InputRef>(null);
useEffect(() => {
props.edit && nodePathRef.current?.focus();
}, [props.edit]);

const items: { title: ReactNode; description?: ReactNode }[] = [
{
title: t('appSetting.originalNode'),
description: (
<Flex align='center' style={{ width: 'auto' }}>
<Input
ref={nodePathRef}
readOnly={!props.edit}
variant={props.edit ? 'outlined' : 'borderless'}
value={props.data.transformDetail?.nodePath.join('/')}
onChange={(e) => props.onNodePathChange?.(e.target.value.split('/'))}
placeholder={t('appSetting.transformNodePath') as string}
style={{
display: 'inline-block',
textAlign: 'center',
height: '18px',
width: 'auto',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
color: token.colorTextDescription,
}}
/>
{props.edit && (
<SmallTextButton
icon={<Icon name='Crosshair' />}
onClick={props.onPathLocationClick}
style={{ color: token.colorTextDescription, marginLeft: '4px' }}
/>
)}
</Flex>
),
},
];

items.push(
...props.data.transformDetail!.transformMethods.map((method, methodIndex) => ({
title: props.edit ? (
<Select
size='small'
variant={props.edit ? 'outlined' : 'borderless'}
placeholder={t('appSetting.transformMethodName')}
value={method.methodName}
options={props.options}
onChange={(value) => props.onMethodNameChange?.(value, methodIndex)}
style={{ width: '112px' }}
/>
) : (
<Input
readOnly
variant='borderless'
value={method.methodName}
style={{ textAlign: 'center', fontWeight: 'bold', padding: 0 }}
/>
),
description: (
<Input
size='small'
readOnly={!props.edit}
variant={props.edit ? 'outlined' : 'borderless'}
placeholder={t('appSetting.transformMethodArgs') as string}
value={method.methodArgs}
onChange={(e) => props.onMethodArgsChange?.(e.target.value, methodIndex)}
style={{
display: 'inline-block',
textAlign: 'center',
color: token.colorTextDescription,
width: '112px',
height: '18px',
}}
/>
),
})),
);

items.push({ title: t('appSetting.transformedNode') });

return (
<Card size='small' style={{ margin: '8px 0' }}>
<Steps
// direction={lg ? 'horizontal' : 'vertical'}
current={items?.length}
items={items}
progressDot={(dot, { index: methodIndex }) => (
<>
{props.edit && !!methodIndex && methodIndex < (items?.length || 0) - 1 && (
<Space.Compact style={{ position: 'absolute', left: '-31px', top: '-26px' }}>
<TooltipButton
title='Insert Before'
icon={<VerticalAlignBottomOutlined rotate={90} />}
onClick={() => props.onInsertBefore?.(methodIndex)}
/>
<TooltipButton
title='Delete'
icon={<DeleteOutlined />}
onClick={() => props.onDrop?.(methodIndex)}
/>
<TooltipButton
title='Insert After'
icon={<VerticalAlignTopOutlined rotate={90} />}
onClick={() => props.onInsertAfter?.(methodIndex)}
/>
</Space.Compact>
)}

<div style={{ height: '7px' }}>{dot}</div>
</>
)}
style={{ marginTop: '20px' }}
/>

<Space.Compact size='small' style={{ position: 'absolute', right: 8, top: 4 }}>
{props.edit ? (
<>
<Button type='text' icon={<CloseOutlined />} onClick={props.onCancel}>
{t('cancel', { ns: 'common' })}
</Button>

<Button type='text' icon={<PlusOutlined />} onClick={props.onAdd}>
{t('add', { ns: 'common' })}
</Button>
<Button type='text' icon={<SaveOutlined />} onClick={props.onSave}>
{t('save', { ns: 'common' })}
</Button>
</>
) : (
<Button type='text' icon={<EditOutlined />} onClick={props.onEdit}>
{t('edit', { ns: 'common' })}
</Button>
)}
</Space.Compact>

{props.edit && (
<Popconfirm
title={t('appSetting.deleteTransformConfirm')}
onConfirm={() => props.onDelete?.(props.data.id!)}
>
<Button
danger
type='text'
size='small'
icon={<DeleteOutlined />}
style={{ position: 'absolute', left: 8, top: 4 }}
>
{t('delete', { ns: 'common' })}
</Button>
</Popconfirm>
)}
</Card>
);
};

export default TransformCard;
Loading

0 comments on commit e47ee13

Please sign in to comment.