diff --git a/packages/arex/src/i18n/locales/cn/components.json b/packages/arex/src/i18n/locales/cn/components.json index dfcf37a9..f5768467 100644 --- a/packages/arex/src/i18n/locales/cn/components.json +++ b/packages/arex/src/i18n/locales/cn/components.json @@ -103,6 +103,7 @@ "recordMachineNum": "录制机器数量", "replay": "回放", "runningStatus": "运行状态", + "selectMethodTip": "请选择一个方法以保存", "selectNodePath": "选择节点路径", "serializeSkip": "序列化忽略", "skipMock": "不Mock依赖", diff --git a/packages/arex/src/i18n/locales/en/components.json b/packages/arex/src/i18n/locales/en/components.json index 722273a9..e68e9d3d 100644 --- a/packages/arex/src/i18n/locales/en/components.json +++ b/packages/arex/src/i18n/locales/en/components.json @@ -104,6 +104,7 @@ "recordMachineNum": "Record Machine Count", "replay": "Replay", "runningStatus": "Running Status", + "selectMethodTip": "Please select a method to save", "selectNodePath": "Select Node Path", "serializeSkip": "SerializeSkip", "skipMock": "Skip Mock", diff --git a/packages/arex/src/panes/AppSetting/CompareConfig/NodesTransform/TransformCard.tsx b/packages/arex/src/panes/AppSetting/CompareConfig/NodesTransform/TransformCard.tsx deleted file mode 100644 index f351b06d..00000000 --- a/packages/arex/src/panes/AppSetting/CompareConfig/NodesTransform/TransformCard.tsx +++ /dev/null @@ -1,208 +0,0 @@ -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; - options?: SelectProps['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 = (props) => { - const { t } = useTranslation('components'); - const { token } = theme.useToken(); - - const nodePathRef = useRef(null); - useEffect(() => { - props.edit && nodePathRef.current?.focus(); - }, [props.edit]); - - const items: { title: ReactNode; description?: ReactNode }[] = [ - { - title: t('appSetting.originalNode'), - description: ( - - props.onNodePathChange?.(e.target.value.split('/'))} - placeholder={t('appSetting.transformNodePath')} - style={{ - display: 'inline-block', - textAlign: 'center', - height: '18px', - width: 'auto', - overflow: 'hidden', - textOverflow: 'ellipsis', - whiteSpace: 'nowrap', - color: token.colorTextDescription, - }} - /> - {props.edit && ( - } - onClick={props.onPathLocationClick} - style={{ color: token.colorTextDescription, marginLeft: '4px' }} - /> - )} - - ), - }, - ]; - - items.push( - ...props.data.transformDetail!.transformMethods.map((method, methodIndex) => ({ - title: props.edit ? ( - - ), - description: ( - 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 ( - - ( - <> - {props.edit && !!methodIndex && methodIndex < (items?.length || 0) - 1 && ( - - } - onClick={() => props.onInsertBefore?.(methodIndex)} - /> - } - onClick={() => props.onDrop?.(methodIndex)} - /> - } - onClick={() => props.onInsertAfter?.(methodIndex)} - /> - - )} - -
{dot}
- - )} - style={{ marginTop: '20px' }} - /> - - - {props.edit ? ( - <> - - - - - - ) : ( - - )} - - - {props.edit && ( - props.onDelete?.(props.data.id!)} - > - - - )} -
- ); -}; - -export default TransformCard; diff --git a/packages/arex/src/panes/AppSetting/CompareConfig/NodesTransform/index.tsx b/packages/arex/src/panes/AppSetting/CompareConfig/NodesTransform/index.tsx index ec57481d..e929ad50 100644 --- a/packages/arex/src/panes/AppSetting/CompareConfig/NodesTransform/index.tsx +++ b/packages/arex/src/panes/AppSetting/CompareConfig/NodesTransform/index.tsx @@ -1,16 +1,10 @@ -import { SyncOutlined } from '@ant-design/icons'; -import { PaneDrawer, SpaceBetweenWrapper, useTranslation } from '@arextest/arex-core'; -import { useAutoAnimate } from '@formkit/auto-animate/react'; +import { Label, useTranslation } from '@arextest/arex-core'; import { useRequest } from 'ahooks'; -import { App, Button, Space, Typography } from 'antd'; +import { App, Button, Card, Select } from 'antd'; import React, { FC, useState } from 'react'; -import { useImmer } from 'use-immer'; -import { EditAreaPlaceholder, Icon } from '@/components'; -import IgnoreTree from '@/panes/AppSetting/CompareConfig/NodesIgnore/IgnoreTree'; -import TransformCard from '@/panes/AppSetting/CompareConfig/NodesTransform/TransformCard'; import { ComparisonService } from '@/services'; -import { DependencyParams, TransformDetail, TransformNode } from '@/services/ComparisonService'; +import { DependencyParams } from '@/services/ComparisonService'; import { CONFIG_TARGET } from '../index'; @@ -25,28 +19,20 @@ export type NodesTransformProps = { loadingContract?: boolean; }; -const TemporaryId = '_temporary_id_'; - const NodesTransform: FC = (props) => { const { message } = App.useApp(); - const { t } = useTranslation(['components', 'common']); - - const [wrapperRef] = useAutoAnimate(); - - const [transformData, setTransformData] = useImmer[]>([]); - const [edit, setEdit] = useState(); + const { t } = useTranslation(); - const [openIndex, setOpenIndex] = useState(-1); - const [nodePath, setNodePath] = useState(); + const [methodValue, setMethodValue] = useState(''); - const { data: transformOptions = [] } = useRequest(ComparisonService.getTransformMethod, { + const { data: methods = [] } = useRequest(ComparisonService.getTransformMethod, { ready: !!props.appId, defaultParams: [props.appId!], }); - const { data = [], run: queryTransformNode } = useRequest( + const { data: transformData = [], refresh: queryTransformRootNode } = useRequest( () => - ComparisonService.queryTransformNode({ + ComparisonService.queryTransformRootNode({ appId: props.appId!, operationId: props.operationId, ...(props.dependency || {}), @@ -55,205 +41,74 @@ const NodesTransform: FC = (props) => { ready: !!props.appId, refreshDeps: [props.appId, props.operationId, props.dependency], onSuccess: (data) => { - setTransformData(data); + setMethodValue(data[0]?.transformMethodName); }, }, ); - const { run: insertTransformNode } = useRequest( - (transformDetail: TransformDetail) => - ComparisonService.insertTransformNode({ + const { run: updateTransformNode } = useRequest( + () => + ComparisonService.updateTransformRootNode({ appId: props.appId!, - operationId: props.operationId!, + operationId: props.operationId, ...(props.dependency || {}), - transformDetail, + transformMethodName: methodValue, }), { manual: true, - ready: !!props.appId, onSuccess: (success) => { if (success) { - message.success(t('message.createSuccess', { ns: 'common' })); - setEdit(undefined); - } else message.error(t('message.createFailed', { ns: 'common' })); + message.success(t('common:message.updateSuccess')); + queryTransformRootNode(); + } else message.error(t('common:message.updateFailed')); }, }, ); - const { run: updateTransformNode } = useRequest(ComparisonService.updateTransformNode, { - manual: true, - onSuccess: (success) => { - if (success) { - message.success(t('message.updateSuccess', { ns: 'common' })); - setEdit(undefined); - } else message.error(t('message.updateFailed', { ns: 'common' })); - }, - }); - - const { run: deleteTransformNode } = useRequest(ComparisonService.deleteTransformNode, { + const { run: deleteTransformRootNode } = useRequest(ComparisonService.deleteTransformRootNode, { manual: true, onSuccess: (success) => { if (success) { - message.success(t('message.delSuccess', { ns: 'common' })); - setEdit(undefined); - setNodePath(undefined); - queryTransformNode(); - } else message.error(t('message.delFailed', { ns: 'common' })); + message.success(t('common:message.updateSuccess')); + queryTransformRootNode(); + } else message.error(t('common:message.updateFailed')); }, }); return ( - <> -
- {transformData.map((item, dataIndex) => { - return ( - ({ label: method, value: method }))} - onNodePathChange={(path) => - setTransformData((draft) => { - draft[dataIndex].transformDetail!.nodePath = path; - }) - } - onPathLocationClick={() => setOpenIndex(dataIndex)} - onMethodNameChange={(value, methodIndex) => - setTransformData((draft) => { - draft[dataIndex].transformDetail!.transformMethods[methodIndex].methodName = - value; - }) - } - onMethodArgsChange={(value, methodIndex) => - setTransformData((draft) => { - draft[dataIndex].transformDetail!.transformMethods[methodIndex].methodArgs = - value; - }) - } - onInsertBefore={(methodIndex) => - setTransformData((draft) => { - draft[dataIndex].transformDetail?.transformMethods.splice(methodIndex - 1, 0, {}); - }) - } - onInsertAfter={(methodIndex) => - setTransformData((draft) => { - draft[dataIndex].transformDetail?.transformMethods.splice(methodIndex, 0, {}); - }) - } - onDrop={(methodIndex) => - setTransformData((draft) => { - draft[dataIndex].transformDetail?.transformMethods.splice(methodIndex - 1, 1); - }) - } - onAdd={() => - setTransformData((draft) => { - draft[dataIndex].transformDetail?.transformMethods.push({}); - }) - } - onSave={() => { - if (item.id && item.id !== TemporaryId) { - updateTransformNode({ - id: item.id, - transformDetail: item.transformDetail!, - }); - } else { - insertTransformNode(item.transformDetail!); - } - }} - onEdit={() => { - setTransformData(data); - setEdit(item.id); - }} - onCancel={() => { - setTransformData(data); - setEdit(undefined); - }} - onDelete={deleteTransformNode} - /> - ); - })} + +
+
+ + { - setFullClassNameInputStatus(''); - handleChange('fullClassName', e.target.value); - }} - /> - ) : ( - hiddenAc(text) - ); - }, + render: (text, record) => ( + { + setFullClassNameInputStatus(''); + handleChange(record.id, 'fullClassName', e.target.value); + }} + style={{ borderColor: 'transparent' }} + /> + ), }, { title: ( @@ -92,11 +87,11 @@ const DynamicClassesEditableTable: FC = (props ), key: 'base', dataIndex: 'base', + align: 'center', render: (checked, record) => ( handleChange('base', e.target.checked)} + onChange={(e) => handleChange(record.id, 'base', e.target.checked)} /> ), }, @@ -108,27 +103,32 @@ const DynamicClassesEditableTable: FC = (props ), dataIndex: 'methodName', key: 'methodName', - render: (text, record) => - isEditableRow(record.id) ? ( - handleChange('methodName', e.target.value)} /> - ) : ( - text - ), + render: (text, record) => ( + handleChange(record.id, 'methodName', e.target.value)} + style={{ borderColor: 'transparent' }} + /> + ), }, { title: ( - + {t('appSetting.parameterTypes', { ns: 'components' })} ), dataIndex: 'parameterTypes', key: 'parameterTypes', - render: (text, record) => - isEditableRow(record.id) ? ( - handleChange('parameterTypes', e.target.value)} /> - ) : ( - text - ), + render: (text, record) => ( + handleChange(record.id, 'parameterTypes', e.target.value)} + style={{ borderColor: 'transparent' }} + /> + ), }, { title: ( @@ -151,12 +151,13 @@ const DynamicClassesEditableTable: FC = (props ), dataIndex: 'keyFormula', key: 'keyFormula', - render: (text, record) => - isEditableRow(record.id) ? ( - handleChange('keyFormula', e.target.value)} /> - ) : ( - text - ), + render: (text, record) => ( + handleChange(record.id, 'keyFormula', e.target.value)} + style={{ borderColor: 'transparent' }} + /> + ), }, { title: t('action'), @@ -165,150 +166,83 @@ const DynamicClassesEditableTable: FC = (props align: 'center', className: 'actions', render: (text, record) => ( - - {isEditableRow(record.id) ? ( - } - onClick={() => reload({ appId: props.appId })} - /> - ) : ( - } - onClick={() => { - // 防止某一行在编辑未保存状态下意外开始编辑新的一行数据,导致夹带未保存的数据 - reload({ appId: props.appId }); - setEditableRow(record.id); - }} - /> - )} - - {isEditableRow(record.id) ? ( - } - onClick={() => handleSave(record)} - /> - ) : ( - { - if (record.id === EDIT_ROW_KEY) { - setDataSource((state) => { - state.shift(); - }); - } else if (record.id) { - remove({ appId: props.appId, id: record.id as string }); - } - }} - okText={t('yes')} - cancelText={t('no')} - > - ), }, ]; }; const handleAddRecord = () => { - setEditableRow(EDIT_ROW_KEY); setDataSource((state) => { - state.unshift(InitRowData); + state.push(generateInitRowData()); }); + focusNewLineInput(tableRef); }; - const handleSave = (record: DynamicClass) => { - if (!record.fullClassName) { - setFullClassNameInputStatus('error'); - message.warning(t('appSetting.emptyFullClassName', { ns: 'components' })); - return; - } - - const params = { - fullClassName: (record.base ? 'ac:' : '') + hiddenAc(record.fullClassName), - methodName: record.methodName, - keyFormula: record.keyFormula, - parameterTypes: record.parameterTypes, - }; - - record.id === EDIT_ROW_KEY - ? insert({ ...params, appId: props.appId, configType: 0 }) - : update({ - ...params, - id: record.id, - appId: props.appId, - }); + const handleSave = () => { + // verify fullClassName + // if (!record.fullClassName) { + // setFullClassNameInputStatus('error'); + // message.warning(t('appSetting.emptyFullClassName', { ns: 'components' })); + // return; + // } + + const params = dataSource.map((data) => ({ + id: data.id.startsWith(EDIT_ROW_KEY) ? undefined : data.id, + appId: props.appId, + fullClassName: (data.base ? 'ac:' : '') + hiddenAc(data.fullClassName), + methodName: data.methodName, + keyFormula: data.keyFormula, + parameterTypes: data.parameterTypes, + })); + + replace(props.appId, params); }; - const { run: reload, loading } = useRequest(ConfigService.queryDynamicClass, { + useImperativeHandle(ref, () => ({ save: handleSave }), [handleSave]); + + const { refresh: reload, loading } = useRequest(ConfigService.queryDynamicClass, { defaultParams: [{ appId: props.appId }], - onBefore() { - setEditableRow(undefined); - }, onSuccess(res) { setDataSource(res || []); }, loadingDelay: 100, }); - const { run: insert } = useRequest(ConfigService.insertDynamicClass, { + const { run: replace } = useRequest(ConfigService.replaceDynamicClass, { manual: true, - onSuccess(res) { - res ? reload({ appId: props.appId }) : message.error(t('message.saveFailed')); - }, onError(e) { console.error(e); message.error(t('message.saveFailed')); - }, - }); - - const { run: update } = useRequest(ConfigService.updateDynamicClass, { - manual: true, - onSuccess(res) { - res ? reload({ appId: props.appId }) : message.error(t('message.saveFailed')); - }, - onError(e) { - console.error(e); - message.error(t('message.saveFailed')); - }, - }); - - const { run: remove } = useRequest(ConfigService.removeDynamicClass, { - manual: true, - onSuccess(res) { - res ? reload({ appId: props.appId }) : message.error(t('message.delFailed')); - }, - onError(e) { - console.error(e); - message.error(t('message.delFailed')); + reload(); }, }); return ( -
- - - - +
( + + )} + pagination={false} + /> ); -}; +}); export default DynamicClassesEditableTable; diff --git a/packages/arex/src/panes/AppSetting/Record/Standard/FormItem/SerializeSkip.tsx b/packages/arex/src/panes/AppSetting/Record/Standard/FormItem/SerializeSkip.tsx index 5d140c0d..746054c3 100644 --- a/packages/arex/src/panes/AppSetting/Record/Standard/FormItem/SerializeSkip.tsx +++ b/packages/arex/src/panes/AppSetting/Record/Standard/FormItem/SerializeSkip.tsx @@ -1,18 +1,21 @@ import { DeleteOutlined, PlusOutlined } from '@ant-design/icons'; -import { css, FlexCenterWrapper, SmallTextButton, useTranslation } from '@arextest/arex-core'; -import { Button, Input, Space, Table, theme } from 'antd'; +import { css, FlexCenterWrapper, useTranslation } from '@arextest/arex-core'; +import { Button, Input, Table, theme } from 'antd'; import { ColumnsType } from 'antd/es/table'; -import React, { FC, useEffect, useMemo } from 'react'; +import React, { FC, useEffect, useMemo, useRef } from 'react'; import { useImmer } from 'use-immer'; import { FormItemProps } from '@/panes/AppSetting/Record/Standard/FormItem/index'; import { SerializeSkipInfo } from '@/services/ConfigService'; +import { focusNewLineInput } from '@/utils/table'; const SerializeSkip: FC> = (props) => { const { token } = theme.useToken(); const { t } = useTranslation('components'); const [dataSource, setDataSource] = useImmer(props.value || []); + const tableRef = useRef(null); + const inputCssObject = useMemo( () => css` height: 26px; @@ -101,10 +104,13 @@ const SerializeSkip: FC> = (props) => { fieldName: '', }); }); + focusNewLineInput(tableRef); }; return (
> = (props) => { )} - css={css` - .ant-table-footer { - padding: 4px; - } - `} /> ); }; diff --git a/packages/arex/src/panes/AppSetting/Record/Standard/index.tsx b/packages/arex/src/panes/AppSetting/Record/Standard/index.tsx index bea5d694..08e7e920 100644 --- a/packages/arex/src/panes/AppSetting/Record/Standard/index.tsx +++ b/packages/arex/src/panes/AppSetting/Record/Standard/index.tsx @@ -2,7 +2,7 @@ import { css, HelpTooltip, useTranslation } from '@arextest/arex-core'; import { useRequest } from 'ahooks'; import { App, Button, Collapse, Form, InputNumber, TimePicker } from 'antd'; import dayjs, { Dayjs } from 'dayjs'; -import React, { FC, useState } from 'react'; +import React, { FC, useRef, useState } from 'react'; import { useImmer } from 'use-immer'; import { InterfaceSelect } from '@/components'; @@ -17,6 +17,7 @@ import { IntegerStepSlider, SerializeSkip, } from './FormItem'; +import { DynamicClassesEditableTableRef } from './FormItem/DynamicClassesEditableTable'; import RunningStatus from './FormItem/RunningStatus'; import { decodeWeekCode, encodeWeekCode } from './utils'; @@ -58,6 +59,8 @@ const Standard: FC = (props) => { const { message } = App.useApp(); const { t } = useTranslation(['components', 'common']); + const dynamicClassesEditableTableRef = useRef(null); + const [initialValues, setInitialValues] = useImmer(defaultValues); const [loading, setLoading] = useState(false); @@ -116,6 +119,8 @@ const Standard: FC = (props) => { serializeSkipInfoList: values.serializeSkipInfoList, }; update(params); + + dynamicClassesEditableTableRef?.current?.save(); }; return ( @@ -180,7 +185,10 @@ const Standard: FC = (props) => { } > - + & { appId: string }; const ExcludeOperation: FC = (props) => { - const { message } = App.useApp(); const { t } = useTranslation(['components', 'common']); - const tableRowCount = useRef(0); const tableRef = useRef(null); const [value, setValue] = useImmer( props.value || [{ id: Date.now().toString(), key: '', value: [] }], @@ -76,74 +73,31 @@ const ExcludeOperation: FC = (props) => { align: 'center', className: 'actions', render: (text, record, i) => ( - - } - title={t('save', { ns: 'common' })} - onClick={onSave} - /> - } - onClick={() => - setValue?.((params) => { - params.splice(i, 1); - }) - } - /> - + ), }, ]; - const { run: updateReplaySetting } = useRequest(ConfigService.updateReplaySetting, { - manual: true, - onSuccess(res) { - res && message.success(t('message.updateSuccess', { ns: 'common' })); - }, - }); - - const onSave = () => { - const params = { - appId: props.appId, - excludeOperationMap: value.reduce<{ [key: string]: string[] }>((map, cur) => { - map[cur['key']] = cur['value']; - return map; - }, {}), - }; - updateReplaySetting(params); - }; - useEffect(() => { props.onChange?.(value); - if (tableRowCount.current !== value.length) { - // focus last row key input - const path = [6, 2, 2]; - let inputRef: ChildNode | null | undefined = tableRef?.current; - path.forEach((level, i) => { - for (let x = level; x > 0; x--) { - if (!inputRef) break; - inputRef = inputRef?.[i % 2 ? 'lastChild' : 'firstChild']; - } - }); - // @ts-ignore - inputRef?.focus?.({ - cursor: 'start', - }); - - tableRowCount.current = value.length; - } }, [value]); return ( + // @ts-ignore ref={tableRef} rowKey='id' dataSource={value} @@ -160,6 +114,7 @@ const ExcludeOperation: FC = (props) => { setValue((state) => { state.push({ id: '', key: '', value: [] }); }); + focusNewLineInput(tableRef); }} > {t('add', { ns: 'common' })} diff --git a/packages/arex/src/services/ComparisonService/deleteTransformNode.ts b/packages/arex/src/services/ComparisonService/deleteTransformNode.ts index 7bd06d94..4286da1d 100644 --- a/packages/arex/src/services/ComparisonService/deleteTransformNode.ts +++ b/packages/arex/src/services/ComparisonService/deleteTransformNode.ts @@ -1,5 +1,9 @@ import { request } from '@/utils'; +/** + * @deprecated flow design is deprecated, use deleteTransformRootNode + * @param id + */ export async function deleteTransformNode(id: string) { const res = await request.post('/webApi/config/comparison/transform/modify/REMOVE', { id, diff --git a/packages/arex/src/services/ComparisonService/index.ts b/packages/arex/src/services/ComparisonService/index.ts index 6e6d9e87..5cb0f033 100644 --- a/packages/arex/src/services/ComparisonService/index.ts +++ b/packages/arex/src/services/ComparisonService/index.ts @@ -17,6 +17,7 @@ export * from './queryIgnoreCategory'; export * from './queryIgnoreNode'; export * from './querySortNode'; export * from './queryTransformNode'; +export * from './transformRootNode'; export * from './updateEncryptionNode'; export * from './updateSortNode'; export * from './updateTransformNode'; diff --git a/packages/arex/src/services/ComparisonService/queryTransformNode.ts b/packages/arex/src/services/ComparisonService/queryTransformNode.ts index 4511cd8b..0237243b 100644 --- a/packages/arex/src/services/ComparisonService/queryTransformNode.ts +++ b/packages/arex/src/services/ComparisonService/queryTransformNode.ts @@ -1,23 +1,8 @@ +import { TransformNode } from '@/services/ComparisonService/transformRootNode/queryTransformRootNode'; import { request } from '@/utils'; import { QueryNodeReq } from './queryIgnoreNode'; -export type TransformNode = { - status: null | number; - modifiedTime: number; - id: string; - appId: string; - operationId: string; - expirationType: number; - expirationDate: number; - compareConfigType: number; - fsInterfaceId: string | null; - dependencyId: string | null; - operationType: string | null; - operationName: string | null; - transformDetail: TransformDetail; -}; - export type TransformDetail = { nodePath: string[]; transformMethods: { @@ -26,8 +11,14 @@ export type TransformDetail = { }[]; }; +export type TransformFlowNode = TransformNode<{ transformDetail: TransformDetail }>; + +/** + * @deprecated flow design is deprecated, use queryTransformRootNode + * @param params + */ export async function queryTransformNode(params: QueryNodeReq<'Global'>) { - const res = await request.post( + const res = await request.post( '/webApi/config/comparison/transform/queryComparisonConfig', params, ); diff --git a/packages/arex/src/services/ComparisonService/transformRootNode/deleteTransformRootNode.ts b/packages/arex/src/services/ComparisonService/transformRootNode/deleteTransformRootNode.ts new file mode 100644 index 00000000..530d1834 --- /dev/null +++ b/packages/arex/src/services/ComparisonService/transformRootNode/deleteTransformRootNode.ts @@ -0,0 +1,9 @@ +import { request } from '@/utils'; + +export async function deleteTransformRootNode(id: string) { + const res = await request.post('/webApi/config/comparison/rootTransform/modify/REMOVE', { + id, + }); + + return res.body; +} diff --git a/packages/arex/src/services/ComparisonService/transformRootNode/index.ts b/packages/arex/src/services/ComparisonService/transformRootNode/index.ts new file mode 100644 index 00000000..c1f2654d --- /dev/null +++ b/packages/arex/src/services/ComparisonService/transformRootNode/index.ts @@ -0,0 +1,3 @@ +export * from './deleteTransformRootNode'; +export * from './queryTransformRootNode'; +export * from './updateTransformRootNode'; diff --git a/packages/arex/src/services/ComparisonService/transformRootNode/queryTransformRootNode.ts b/packages/arex/src/services/ComparisonService/transformRootNode/queryTransformRootNode.ts new file mode 100644 index 00000000..80be9cd7 --- /dev/null +++ b/packages/arex/src/services/ComparisonService/transformRootNode/queryTransformRootNode.ts @@ -0,0 +1,28 @@ +import { QueryNodeReq } from '@/services/ComparisonService'; +import { request } from '@/utils'; + +export type TransformNode = { + status: null | number; + modifiedTime: number; + id: string; + appId: string; + operationId: string; + expirationType: number; + expirationDate: number; + compareConfigType: number; + fsInterfaceId: string | null; + dependencyId: string | null; + operationType: string | null; + operationName: string | null; +} & T; + +export type TransformRootNodeParams = { transformMethodName: string }; +export type TransformRootNode = TransformNode; + +export async function queryTransformRootNode(params: QueryNodeReq<'Global'>) { + const res = await request.post( + '/webApi/config/comparison/rootTransform/queryComparisonConfig', + params, + ); + return res.body; +} diff --git a/packages/arex/src/services/ComparisonService/transformRootNode/updateTransformRootNode.ts b/packages/arex/src/services/ComparisonService/transformRootNode/updateTransformRootNode.ts new file mode 100644 index 00000000..dc6d1387 --- /dev/null +++ b/packages/arex/src/services/ComparisonService/transformRootNode/updateTransformRootNode.ts @@ -0,0 +1,15 @@ +import { QueryNodeReq } from '@/services/ComparisonService'; +import { request } from '@/utils'; + +import { TransformRootNodeParams } from './queryTransformRootNode'; + +interface UpdateTransformRootNodeReq extends QueryNodeReq<'Global'>, TransformRootNodeParams {} + +export async function updateTransformRootNode(params: UpdateTransformRootNodeReq) { + const res = await request.post( + '/webApi/config/comparison/rootTransform/modify/INSERT', + params, + ); + + return res.body; +} diff --git a/packages/arex/src/services/ComparisonService/updateTransformNode.ts b/packages/arex/src/services/ComparisonService/updateTransformNode.ts index d35385fc..e609f319 100644 --- a/packages/arex/src/services/ComparisonService/updateTransformNode.ts +++ b/packages/arex/src/services/ComparisonService/updateTransformNode.ts @@ -7,6 +7,10 @@ export interface UpdateTransformNodeReq { transformDetail: TransformDetail; } +/** + * @deprecated flow design is deprecated, use queryComparisonConfig + * @param params + */ export async function updateTransformNode(params: UpdateTransformNodeReq) { const res = await request.post( '/webApi/config/comparison/transform/modify/UPDATE', diff --git a/packages/arex/src/services/ConfigService/recordDynamicClass/index.ts b/packages/arex/src/services/ConfigService/recordDynamicClass/index.ts index 6f83413d..81970986 100644 --- a/packages/arex/src/services/ConfigService/recordDynamicClass/index.ts +++ b/packages/arex/src/services/ConfigService/recordDynamicClass/index.ts @@ -1,4 +1,5 @@ export * from './insertDynamicClass'; export * from './queryDynamicClass'; export * from './removeDynamicClass'; +export * from './replaceDynamicClass'; export * from './updateDynamicClass'; diff --git a/packages/arex/src/services/ConfigService/recordDynamicClass/insertDynamicClass.ts b/packages/arex/src/services/ConfigService/recordDynamicClass/insertDynamicClass.ts index 4be8070a..48996839 100644 --- a/packages/arex/src/services/ConfigService/recordDynamicClass/insertDynamicClass.ts +++ b/packages/arex/src/services/ConfigService/recordDynamicClass/insertDynamicClass.ts @@ -1,6 +1,10 @@ import { DynamicClass } from '@/services/ConfigService'; import { request } from '@/utils'; +/** + * @deprecated use replaceDynamicClass for batch update + * @param params + */ export async function insertDynamicClass(params: Omit) { const res = await request.post('/webApi/config/dynamicClass/modify/INSERT', params); return res.body; diff --git a/packages/arex/src/services/ConfigService/recordDynamicClass/removeDynamicClass.ts b/packages/arex/src/services/ConfigService/recordDynamicClass/removeDynamicClass.ts index 4516e5a7..cfeb5616 100644 --- a/packages/arex/src/services/ConfigService/recordDynamicClass/removeDynamicClass.ts +++ b/packages/arex/src/services/ConfigService/recordDynamicClass/removeDynamicClass.ts @@ -5,6 +5,10 @@ export interface RemoveDynamicClassSettingReq { id: string; } +/** + * @deprecated use replaceDynamicClass for batch update + * @param params + */ export async function removeDynamicClass(params: RemoveDynamicClassSettingReq) { const res = await request.post('/webApi/config/dynamicClass/modify/REMOVE', params); return res.body; diff --git a/packages/arex/src/services/ConfigService/recordDynamicClass/replaceDynamicClass.ts b/packages/arex/src/services/ConfigService/recordDynamicClass/replaceDynamicClass.ts new file mode 100644 index 00000000..04a78ce3 --- /dev/null +++ b/packages/arex/src/services/ConfigService/recordDynamicClass/replaceDynamicClass.ts @@ -0,0 +1,13 @@ +import { DynamicClass } from '@/services/ConfigService'; +import { request } from '@/utils'; + +export async function replaceDynamicClass( + appId: string, + dynamicClasses: Omit[], +) { + const res = await request.post( + '/webApi/config/dynamicClass/replace/' + appId, + dynamicClasses, + ); + return res.body; +} diff --git a/packages/arex/src/services/ConfigService/recordDynamicClass/updateDynamicClass.ts b/packages/arex/src/services/ConfigService/recordDynamicClass/updateDynamicClass.ts index 3f7de482..ad258063 100644 --- a/packages/arex/src/services/ConfigService/recordDynamicClass/updateDynamicClass.ts +++ b/packages/arex/src/services/ConfigService/recordDynamicClass/updateDynamicClass.ts @@ -1,6 +1,10 @@ import { DynamicClass } from '@/services/ConfigService'; import { request } from '@/utils'; +/** + * @deprecated use replaceDynamicClass for batch update + * @param params + */ export async function updateDynamicClass(params: DynamicClass) { const res = await request.post('/webApi/config/dynamicClass/modify/UPDATE', params); return res.body; diff --git a/packages/arex/src/utils/table.ts b/packages/arex/src/utils/table.ts new file mode 100644 index 00000000..63b3ab51 --- /dev/null +++ b/packages/arex/src/utils/table.ts @@ -0,0 +1,19 @@ +import { RefObject } from 'react'; + +export const focusNewLineInput = (tableRef: RefObject) => { + setTimeout(() => { + // focus last row key input + const path = [6, 2, 2]; + let inputRef: ChildNode | null | undefined = tableRef?.current; + path.forEach((level, i) => { + for (let x = level; x > 0; x--) { + if (!inputRef) break; + inputRef = inputRef?.[i % 2 ? 'lastChild' : 'firstChild']; + } + }); + // @ts-ignore + inputRef?.focus?.({ + cursor: 'start', + }); + }); +};