From 8d449193036fa7cbd6c19ad4b1470724394487b3 Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Fri, 7 Mar 2025 22:04:56 +0300 Subject: [PATCH] R: Remove redundant containers --- .../src/components/Container/FlexColumn.tsx | 13 ---- .../src/components/Container/Overlay.tsx | 32 --------- .../src/components/Container/index.tsx | 2 - .../src/components/Dropdown/Dropdown.tsx | 11 ++- .../src/components/Modal/ModalForm.tsx | 10 +-- .../src/components/Modal/ModalView.tsx | 5 +- .../features/help/components/BadgeHelp.tsx | 17 ++++- .../library/components/PickSchema.tsx | 5 +- .../library/components/ToolbarItemAccess.tsx | 10 +-- .../components/ToolbarItemCard.tsx} | 21 +++--- .../src/features/library/components/index.tsx | 1 + .../pages/LibraryPage/TableLibraryItems.tsx | 5 +- .../pages/LibraryPage/ViewSideLocation.tsx | 7 +- .../TabSynthesisOperation.tsx | 5 +- .../dialogs/DlgEditOperation/TabArguments.tsx | 33 ++++----- .../OssPage/EditorOssCard/EditorOssCard.tsx | 10 ++- .../pages/OssPage/EditorOssGraph/OssFlow.tsx | 14 ++-- .../EditorOssGraph/ToolbarOssGraph.tsx | 7 +- .../OssPage/EditorOssGraph/graph/NodeCore.tsx | 5 +- .../src/features/rsform/components/index.tsx | 1 - .../dialogs/DlgCreateCst/FormCreateCst.tsx | 8 +-- .../rsform/dialogs/DlgShowAST/DlgShowAST.tsx | 14 ++-- .../EditorConstituenta/EditorControls.tsx | 5 +- .../EditorConstituenta/FormConstituenta.tsx | 5 +- .../ToolbarConstituenta.tsx | 20 +++--- .../EditorRSExpression/StatusBar.tsx | 12 ++-- .../ToolbarRSExpression.tsx | 5 +- .../EditorRSFormCard/EditorRSFormCard.tsx | 10 ++- .../EditorRSFormCard/ToolbarVersioning.tsx | 8 +-- .../RSFormPage/EditorRSList/EditorRSList.tsx | 15 ++-- .../RSFormPage/EditorRSList/ToolbarRSList.tsx | 14 ++-- .../EditorTermGraph/GraphSelectors.tsx | 9 ++- .../RSFormPage/EditorTermGraph/TGFlow.tsx | 68 +++++++++---------- .../EditorTermGraph/ToolbarTermGraph.tsx | 7 +- .../users/pages/RegisterPage/FormSignup.tsx | 13 ++-- .../pages/UserProfilePage/EditorPassword.tsx | 5 +- rsconcept/frontend/src/styling/styles.css | 2 + rsconcept/frontend/tests/app.spec.ts | 2 +- 38 files changed, 182 insertions(+), 254 deletions(-) delete mode 100644 rsconcept/frontend/src/components/Container/FlexColumn.tsx delete mode 100644 rsconcept/frontend/src/components/Container/Overlay.tsx rename rsconcept/frontend/src/features/{rsform/components/ToolbarRSFormCard.tsx => library/components/ToolbarItemCard.tsx} (78%) diff --git a/rsconcept/frontend/src/components/Container/FlexColumn.tsx b/rsconcept/frontend/src/components/Container/FlexColumn.tsx deleted file mode 100644 index decc2641..00000000 --- a/rsconcept/frontend/src/components/Container/FlexColumn.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import clsx from 'clsx'; - -/** - * `flex` column container. - * This component is useful for creating vertical layouts with flexbox. - */ -export function FlexColumn({ className, children, ...restProps }: React.ComponentProps<'div'>) { - return ( -
- {children} -
- ); -} diff --git a/rsconcept/frontend/src/components/Container/Overlay.tsx b/rsconcept/frontend/src/components/Container/Overlay.tsx deleted file mode 100644 index f816675d..00000000 --- a/rsconcept/frontend/src/components/Container/Overlay.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import clsx from 'clsx'; - -import { type Styling } from '../props'; - -interface OverlayProps extends Styling { - /** Id of the overlay. */ - id?: string; - - /** Classnames for position of the overlay. */ - position?: string; - - /** Classname for z-index of the overlay. */ - layer?: string; -} - -/** - * Displays a transparent overlay over the main content. - * Note: Overlay should be inside a relative container. - */ -export function Overlay({ - children, - className, - position = 'top-0 right-0', - layer = 'z-pop', - ...restProps -}: React.PropsWithChildren) { - return ( -
- {children} -
- ); -} diff --git a/rsconcept/frontend/src/components/Container/index.tsx b/rsconcept/frontend/src/components/Container/index.tsx index 7fd2040b..60ce8da4 100644 --- a/rsconcept/frontend/src/components/Container/index.tsx +++ b/rsconcept/frontend/src/components/Container/index.tsx @@ -1,4 +1,2 @@ export { Divider } from './Divider'; -export { FlexColumn } from './FlexColumn'; -export { Overlay } from './Overlay'; export { type PlacesType, Tooltip } from './Tooltip'; diff --git a/rsconcept/frontend/src/components/Dropdown/Dropdown.tsx b/rsconcept/frontend/src/components/Dropdown/Dropdown.tsx index 63c5f004..b3efd64b 100644 --- a/rsconcept/frontend/src/components/Dropdown/Dropdown.tsx +++ b/rsconcept/frontend/src/components/Dropdown/Dropdown.tsx @@ -39,18 +39,17 @@ export function Dropdown({
{helpTopic && !hideHelpWhen?.() ? ( -
- -
+ ) : null} {helpTopic && !hideHelpWhen?.() ? ( -
- -
+ ) : null} state.showHelp); if (!showHelp) { return null; } return ( -
+
- + }>
event.stopPropagation()}> diff --git a/rsconcept/frontend/src/features/library/components/PickSchema.tsx b/rsconcept/frontend/src/features/library/components/PickSchema.tsx index c95e90ad..0f244cbc 100644 --- a/rsconcept/frontend/src/features/library/components/PickSchema.tsx +++ b/rsconcept/frontend/src/features/library/components/PickSchema.tsx @@ -2,7 +2,6 @@ import { useState } from 'react'; import { useIntl } from 'react-intl'; import clsx from 'clsx'; -import { FlexColumn } from '@/components/Container'; import { MiniButton } from '@/components/Control'; import { createColumnHelper, DataTable, type IConditionalStyle } from '@/components/DataTable'; import { Dropdown, useDropdown } from '@/components/Dropdown'; @@ -148,10 +147,10 @@ export function PickSchema({ columns={columns} conditionalRowStyles={conditionalRowStyles} noDataComponent={ - +

Список схем пуст

Измените параметры фильтра

- +
} onRowClicked={rowData => onChange(rowData.id)} /> diff --git a/rsconcept/frontend/src/features/library/components/ToolbarItemAccess.tsx b/rsconcept/frontend/src/features/library/components/ToolbarItemAccess.tsx index 33fb84c4..d8e90898 100644 --- a/rsconcept/frontend/src/features/library/components/ToolbarItemAccess.tsx +++ b/rsconcept/frontend/src/features/library/components/ToolbarItemAccess.tsx @@ -2,11 +2,9 @@ import { HelpTopic } from '@/features/help'; import { BadgeHelp } from '@/features/help/components'; import { useRoleStore, UserRole } from '@/features/users'; -import { Overlay } from '@/components/Container'; import { MiniButton } from '@/components/Control'; import { IconImmutable, IconMutable } from '@/components/Icons'; import { Label } from '@/components/Input'; -import { PARAMETER } from '@/utils/constants'; import { type AccessPolicy, type ILibraryItem } from '../backend/types'; import { useMutatingLibrary } from '../backend/useMutatingLibrary'; @@ -42,7 +40,7 @@ export function ToolbarItemAccess({ } return ( - +
); } diff --git a/rsconcept/frontend/src/features/rsform/components/ToolbarRSFormCard.tsx b/rsconcept/frontend/src/features/library/components/ToolbarItemCard.tsx similarity index 78% rename from rsconcept/frontend/src/features/rsform/components/ToolbarRSFormCard.tsx rename to rsconcept/frontend/src/features/library/components/ToolbarItemCard.tsx index 65d4c195..9b79ae38 100644 --- a/rsconcept/frontend/src/features/rsform/components/ToolbarRSFormCard.tsx +++ b/rsconcept/frontend/src/features/library/components/ToolbarItemCard.tsx @@ -3,29 +3,28 @@ import { urls, useConceptNavigation } from '@/app'; import { HelpTopic } from '@/features/help'; import { BadgeHelp } from '@/features/help/components'; -import { AccessPolicy, type ILibraryItem, LibraryItemType } from '@/features/library'; -import { useMutatingLibrary } from '@/features/library/backend/useMutatingLibrary'; -import { MiniSelectorOSS } from '@/features/library/components'; +import { type IRSForm } from '@/features/rsform'; import { useRoleStore, UserRole } from '@/features/users'; -import { Overlay } from '@/components/Container'; import { MiniButton } from '@/components/Control'; import { IconDestroy, IconSave, IconShare } from '@/components/Icons'; import { useModificationStore } from '@/stores/modification'; -import { PARAMETER } from '@/utils/constants'; import { tooltipText } from '@/utils/labels'; import { prepareTooltip, sharePage } from '@/utils/utils'; -import { type IRSForm } from '../models/rsform'; +import { AccessPolicy, type ILibraryItem, LibraryItemType } from '../backend/types'; +import { useMutatingLibrary } from '../backend/useMutatingLibrary'; -interface ToolbarRSFormCardProps { +import { MiniSelectorOSS } from './MiniSelectorOSS'; + +interface ToolbarItemCardProps { onSubmit: () => void; isMutable: boolean; schema: ILibraryItem; deleteSchema: () => void; } -export function ToolbarRSFormCard({ schema, onSubmit, isMutable, deleteSchema }: ToolbarRSFormCardProps) { +export function ToolbarItemCard({ schema, onSubmit, isMutable, deleteSchema }: ToolbarItemCardProps) { const role = useRoleStore(state => state.role); const router = useConceptNavigation(); const { isModified } = useModificationStore(); @@ -49,7 +48,7 @@ export function ToolbarRSFormCard({ schema, onSubmit, isMutable, deleteSchema }: })(); return ( - +
{ossSelector} {isMutable || isModified ? ( ) : null} - - + +
); } diff --git a/rsconcept/frontend/src/features/library/components/index.tsx b/rsconcept/frontend/src/features/library/components/index.tsx index a9517428..76d40204 100644 --- a/rsconcept/frontend/src/features/library/components/index.tsx +++ b/rsconcept/frontend/src/features/library/components/index.tsx @@ -5,3 +5,4 @@ export { PickSchema } from './PickSchema'; export { SelectLibraryItem } from './SelectLibraryItem'; export { SelectVersion } from './SelectVersion'; export { ToolbarItemAccess } from './ToolbarItemAccess'; +export { ToolbarItemCard } from './ToolbarItemCard'; diff --git a/rsconcept/frontend/src/features/library/pages/LibraryPage/TableLibraryItems.tsx b/rsconcept/frontend/src/features/library/pages/LibraryPage/TableLibraryItems.tsx index 9632377e..5879d6df 100644 --- a/rsconcept/frontend/src/features/library/pages/LibraryPage/TableLibraryItems.tsx +++ b/rsconcept/frontend/src/features/library/pages/LibraryPage/TableLibraryItems.tsx @@ -4,7 +4,6 @@ import clsx from 'clsx'; import { urls, useConceptNavigation } from '@/app'; -import { FlexColumn } from '@/components/Container'; import { TextURL } from '@/components/Control'; import { DataTable, type IConditionalStyle, type VisibilityState } from '@/components/DataTable'; import { useWindowSize } from '@/hooks/useWindowSize'; @@ -64,13 +63,13 @@ export function TableLibraryItems({ items }: TableLibraryItemsProps) { className={clsx('text-xs sm:text-sm cc-scroll-y h-fit border-b', { 'border-l': folderMode })} style={{ maxHeight: tableHeight }} noDataComponent={ - +

Список схем пуст

- +
} columnVisibility={columnVisibility} onRowClicked={handleOpenItem} diff --git a/rsconcept/frontend/src/features/library/pages/LibraryPage/ViewSideLocation.tsx b/rsconcept/frontend/src/features/library/pages/LibraryPage/ViewSideLocation.tsx index 03069f31..ccfb1a98 100644 --- a/rsconcept/frontend/src/features/library/pages/LibraryPage/ViewSideLocation.tsx +++ b/rsconcept/frontend/src/features/library/pages/LibraryPage/ViewSideLocation.tsx @@ -74,12 +74,7 @@ export function ViewSideLocation({ isVisible, onRenameLocation }: ViewSideLocati }} >
- +
{canRename ? (
- +
); } diff --git a/rsconcept/frontend/src/features/oss/dialogs/DlgEditOperation/TabArguments.tsx b/rsconcept/frontend/src/features/oss/dialogs/DlgEditOperation/TabArguments.tsx index e9d406df..34829384 100644 --- a/rsconcept/frontend/src/features/oss/dialogs/DlgEditOperation/TabArguments.tsx +++ b/rsconcept/frontend/src/features/oss/dialogs/DlgEditOperation/TabArguments.tsx @@ -1,7 +1,6 @@ 'use client'; import { Controller, useFormContext } from 'react-hook-form'; -import { FlexColumn } from '@/components/Container'; import { Label } from '@/components/Input'; import { useDialogsStore } from '@/stores/dialogs'; @@ -25,23 +24,21 @@ export function TabArguments() { return (
- - ( - <> - + ( + <> +
); } diff --git a/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssCard/EditorOssCard.tsx b/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssCard/EditorOssCard.tsx index 291d78a7..0e85e597 100644 --- a/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssCard/EditorOssCard.tsx +++ b/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssCard/EditorOssCard.tsx @@ -2,10 +2,8 @@ import clsx from 'clsx'; -import { EditorLibraryItem } from '@/features/library/components'; -import { ToolbarRSFormCard } from '@/features/rsform/components'; +import { EditorLibraryItem, ToolbarItemCard } from '@/features/library/components'; -import { FlexColumn } from '@/components/Container'; import { useModificationStore } from '@/stores/modification'; import { globalIDs } from '@/utils/constants'; @@ -36,7 +34,7 @@ export function EditorOssCard() { return ( <> - +
- +
- +
diff --git a/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/OssFlow.tsx b/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/OssFlow.tsx index e5224b8d..995060a5 100644 --- a/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/OssFlow.tsx +++ b/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/OssFlow.tsx @@ -10,8 +10,8 @@ import { useOnSelectionChange, useReactFlow } from 'reactflow'; +import clsx from 'clsx'; -import { Overlay } from '@/components/Container'; import { useMainHeight } from '@/stores/appLayout'; import { useDialogsStore } from '@/stores/dialogs'; import { PARAMETER } from '@/utils/constants'; @@ -191,16 +191,20 @@ export function OssFlow() { return (
- setToggleReset(prev => !prev)} /> - +
setIsContextMenuOpen(false)} {...menuProps} /> diff --git a/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/ToolbarOssGraph.tsx b/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/ToolbarOssGraph.tsx index 1b8d3f92..e5165a3f 100644 --- a/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/ToolbarOssGraph.tsx +++ b/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/ToolbarOssGraph.tsx @@ -1,7 +1,6 @@ 'use client'; import { useReactFlow } from 'reactflow'; -import clsx from 'clsx'; import { HelpTopic } from '@/features/help'; import { BadgeHelp } from '@/features/help/components'; @@ -165,11 +164,7 @@ export function ToolbarOssGraph({ onCreate, onDelete, onResetPositions }: Toolba } onClick={toggleEdgeAnimate} /> - +
{isMutable ? (
diff --git a/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/graph/NodeCore.tsx b/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/graph/NodeCore.tsx index ac478e10..8c70d46d 100644 --- a/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/graph/NodeCore.tsx +++ b/rsconcept/frontend/src/features/oss/pages/OssPage/EditorOssGraph/graph/NodeCore.tsx @@ -1,6 +1,5 @@ 'use client'; -import { Overlay } from '@/components/Container'; import { IconConsolidation, IconRSForm } from '@/components/Icons'; import { Indicator } from '@/components/View'; import { globalIDs } from '@/utils/constants'; @@ -29,7 +28,7 @@ export function NodeCore({ node }: NodeCoreProps) { data-tooltip-hidden={node.dragging} onMouseEnter={() => setHover(node.data.operation)} > - +
} /> ) : null} - +
{node.data.operation.operation_type === OperationType.INPUT ? (
diff --git a/rsconcept/frontend/src/features/rsform/components/index.tsx b/rsconcept/frontend/src/features/rsform/components/index.tsx index 18532e98..81a83bd3 100644 --- a/rsconcept/frontend/src/features/rsform/components/index.tsx +++ b/rsconcept/frontend/src/features/rsform/components/index.tsx @@ -1,4 +1,3 @@ export { ConstituentaTooltip } from './ConstituentaTooltip'; export { PickMultiConstituenta } from './PickMultiConstituenta'; export { PickSubstitutions } from './PickSubstitutions'; -export { ToolbarRSFormCard } from './ToolbarRSFormCard'; diff --git a/rsconcept/frontend/src/features/rsform/dialogs/DlgCreateCst/FormCreateCst.tsx b/rsconcept/frontend/src/features/rsform/dialogs/DlgCreateCst/FormCreateCst.tsx index e31a491e..42941765 100644 --- a/rsconcept/frontend/src/features/rsform/dialogs/DlgCreateCst/FormCreateCst.tsx +++ b/rsconcept/frontend/src/features/rsform/dialogs/DlgCreateCst/FormCreateCst.tsx @@ -2,13 +2,11 @@ import { useState } from 'react'; import { Controller, useFormContext, useWatch } from 'react-hook-form'; -import clsx from 'clsx'; import { HelpTopic } from '@/features/help'; import { BadgeHelp } from '@/features/help/components'; import { TextArea, TextInput } from '@/components/Input'; -import { PARAMETER } from '@/utils/constants'; import { CstType, type ICstCreateDTO } from '../../backend/types'; import { RSInput } from '../../components/RSInput'; @@ -54,11 +52,7 @@ export function FormCreateCst({ schema }: FormCreateCstProps) { {...register('alias')} error={errors.alias} /> - +