From cb204ed79f905a2c344b97c82fb032fc98b945dc Mon Sep 17 00:00:00 2001 From: Anastasiia Date: Wed, 25 Dec 2024 09:51:07 +0300 Subject: [PATCH 1/2] MSP-4672 update templates in ConfigurationEditorForm --- .../ConfigurationEditorForm/index.tsx | 227 ++++++++---------- .../ConfigurationEditor.type.ts | 13 +- .../configuration-editor-page.scss | 75 +++++- 3 files changed, 187 insertions(+), 128 deletions(-) diff --git a/src/components/ConfigurationEditorForm/index.tsx b/src/components/ConfigurationEditorForm/index.tsx index a2cf4dc..2b9bef1 100644 --- a/src/components/ConfigurationEditorForm/index.tsx +++ b/src/components/ConfigurationEditorForm/index.tsx @@ -8,7 +8,6 @@ import { Button, Tabs, Tooltip, - Form as FormAntd, Collapse, Typography, Space @@ -22,9 +21,9 @@ import { ConfigurationEditorPropsType, DescriptionPropsType, ErrorsObjType, - FieldTemplatePropsType, ObjectFieldTemplatePropertyType, ObjectFieldTemplatePropsType, + RemoveButtonProps, SortPropType } from '@pages/ConfigurationEditorPage/ConfigurationEditor.type.ts' import { ResponseSchemaType } from '@pages/ModulesPage/module.type.ts' @@ -103,98 +102,12 @@ const ConfigurationEditorForm: FC = ({ return id.split('_').length } - const getName = (id: string) => { - if (!id) { - return '' - } - const arr = id.split('_') - return `#${arr[arr.length - 1] || ''}` - } - - const FieldTemplate: FC = (props) => { - const { - id, - classNames, - label, - rawHelp, - required, - rawDescription, - rawErrors, - children, - displayLabel, - schema - } = props - - const isObject = schema.type === 'object' - const depth = getDepth(id) - const name = label || getName(id) - - // Проверяем на наличие ошибок и формируем их вывод - const errorMessages = rawErrors ? rawErrors.join('\n') : null - - // Объекты и массивы - Обработка по глубине - if (isObject && depth !== 1) { - const title = ( -
- {depth !== 2 && {name}} - {errorMessages && ( - {` (${errorMessages})`} - )} - {depth !== 2 && } -
- ) - - if (depth === 2 || schema.dynamic) { - return ( -
- {!schema.dynamic && title} - {children} -
- ) - } - - return ( - 1 ? '' : id}> - - {children} - - - ) - } - - // Для остальных типов возвращаем форму с элементами - return ( - - {name} - - - ) : null - } - > - {children} - - ) - } - const ArrayFieldTemplate: FC = ({ items, onAddClick, canAdd, title, - idSchema, - schema: { description } + idSchema }) => { return ( @@ -207,9 +120,11 @@ const ConfigurationEditorForm: FC = ({ style={{ justifyContent: 'space-between', width: '100%' }} > + {title} + - + {canAdd && (