From 13319c795cd705e890fb21d9e038a3704dca91ea Mon Sep 17 00:00:00 2001 From: okorie2 Date: Fri, 13 Sep 2024 18:57:21 +0100 Subject: [PATCH] chore: folder restructure --- .../__test__/headerBlock.test.tsx | 10 +- .../components/headerBlock/index.tsx | 2 +- .../components/headerBlock/style.ts | 0 .../rowStructure/addRowFrameButton.tsx | 0 .../rowStructure/index.tsx | 4 +- .../rowStructure/rowStructureDisplay.tsx | 0 .../rowStructure/style.ts | 0 .../report-module/views/create/index.tsx | 141 +----------------- .../report-module/views/edit/index.tsx | 1 - .../report-module/views/preview/index.tsx | 4 +- 10 files changed, 13 insertions(+), 149 deletions(-) rename src/app/modules/report-module/{sub-module => }/components/headerBlock/index.tsx (99%) rename src/app/modules/report-module/{sub-module => }/components/headerBlock/style.ts (100%) rename src/app/modules/report-module/{sub-module => components}/rowStructure/addRowFrameButton.tsx (100%) rename src/app/modules/report-module/{sub-module => components}/rowStructure/index.tsx (99%) rename src/app/modules/report-module/{sub-module => components}/rowStructure/rowStructureDisplay.tsx (100%) rename src/app/modules/report-module/{sub-module => components}/rowStructure/style.ts (100%) diff --git a/src/app/modules/report-module/__test__/headerBlock.test.tsx b/src/app/modules/report-module/__test__/headerBlock.test.tsx index 9ad3b5349..10380eb7c 100644 --- a/src/app/modules/report-module/__test__/headerBlock.test.tsx +++ b/src/app/modules/report-module/__test__/headerBlock.test.tsx @@ -1,12 +1,6 @@ -import { - act, - fireEvent, - render, - screen, - waitFor, -} from "@testing-library/react"; +import { fireEvent, render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; -import HeaderBlock from "app/modules/report-module/sub-module/components/headerBlock/"; +import HeaderBlock from "app/modules/report-module/components/headerBlock"; import { ContentState, EditorState } from "draft-js"; import { ToolbarPluginsType } from "app/modules/report-module/components/reportSubHeaderToolbar/staticToolbar"; import Router from "react-router-dom"; diff --git a/src/app/modules/report-module/sub-module/components/headerBlock/index.tsx b/src/app/modules/report-module/components/headerBlock/index.tsx similarity index 99% rename from src/app/modules/report-module/sub-module/components/headerBlock/index.tsx rename to src/app/modules/report-module/components/headerBlock/index.tsx index 512c070bd..e870a375c 100644 --- a/src/app/modules/report-module/sub-module/components/headerBlock/index.tsx +++ b/src/app/modules/report-module/components/headerBlock/index.tsx @@ -11,7 +11,7 @@ import { reportRightPanelViewAtom } from "app/state/recoil/atoms"; import { RichEditor } from "app/modules/common/RichEditor"; import { ReactComponent as EditIcon } from "app/modules/report-module/asset/editIcon.svg"; import { ReactComponent as DeleteIcon } from "app/modules/report-module/asset/deleteIcon.svg"; -import { headerBlockcss } from "app/modules/report-module/sub-module/components/headerBlock/style"; +import { headerBlockcss } from "app/modules/report-module/components/headerBlock/style"; import { ReactComponent as HeaderHandlesvg } from "app/modules/report-module/asset/header-handle.svg"; import { Tooltip } from "@material-ui/core"; import useDebounce from "react-use/lib/useDebounce"; diff --git a/src/app/modules/report-module/sub-module/components/headerBlock/style.ts b/src/app/modules/report-module/components/headerBlock/style.ts similarity index 100% rename from src/app/modules/report-module/sub-module/components/headerBlock/style.ts rename to src/app/modules/report-module/components/headerBlock/style.ts diff --git a/src/app/modules/report-module/sub-module/rowStructure/addRowFrameButton.tsx b/src/app/modules/report-module/components/rowStructure/addRowFrameButton.tsx similarity index 100% rename from src/app/modules/report-module/sub-module/rowStructure/addRowFrameButton.tsx rename to src/app/modules/report-module/components/rowStructure/addRowFrameButton.tsx diff --git a/src/app/modules/report-module/sub-module/rowStructure/index.tsx b/src/app/modules/report-module/components/rowStructure/index.tsx similarity index 99% rename from src/app/modules/report-module/sub-module/rowStructure/index.tsx rename to src/app/modules/report-module/components/rowStructure/index.tsx index ce2ac197e..6dddbeda5 100644 --- a/src/app/modules/report-module/sub-module/rowStructure/index.tsx +++ b/src/app/modules/report-module/components/rowStructure/index.tsx @@ -5,7 +5,7 @@ import { useUpdateEffect } from "react-use"; import IconButton from "@material-ui/core/IconButton"; import { useHistory, useLocation, useParams } from "react-router-dom"; import { itemSpacing, containerGap } from "app/modules/report-module/data"; -import RowstructureDisplay from "app/modules/report-module/sub-module/rowStructure/rowStructureDisplay"; +import RowstructureDisplay from "app/modules/report-module/components/rowStructure/rowStructureDisplay"; import { ReactComponent as CloseIcon } from "app/modules/report-module/asset/closeIcon.svg"; import { ReactComponent as DeleteIcon } from "app/modules/report-module/asset/deleteIcon.svg"; import { @@ -15,7 +15,7 @@ import { import { blockcss, containercss, -} from "app/modules/report-module/sub-module/rowStructure/style"; +} from "app/modules/report-module/components/rowStructure/style"; import { IFramesArray } from "app/modules/report-module/views/create/data"; import { useOnClickOutside } from "usehooks-ts"; import { ToolbarPluginsType } from "app/modules/report-module/components/reportSubHeaderToolbar/staticToolbar"; diff --git a/src/app/modules/report-module/sub-module/rowStructure/rowStructureDisplay.tsx b/src/app/modules/report-module/components/rowStructure/rowStructureDisplay.tsx similarity index 100% rename from src/app/modules/report-module/sub-module/rowStructure/rowStructureDisplay.tsx rename to src/app/modules/report-module/components/rowStructure/rowStructureDisplay.tsx diff --git a/src/app/modules/report-module/sub-module/rowStructure/style.ts b/src/app/modules/report-module/components/rowStructure/style.ts similarity index 100% rename from src/app/modules/report-module/sub-module/rowStructure/style.ts rename to src/app/modules/report-module/components/rowStructure/style.ts diff --git a/src/app/modules/report-module/views/create/index.tsx b/src/app/modules/report-module/views/create/index.tsx index f3bd6f27d..11688a9a6 100644 --- a/src/app/modules/report-module/views/create/index.tsx +++ b/src/app/modules/report-module/views/create/index.tsx @@ -1,27 +1,22 @@ import React from "react"; import { v4 } from "uuid"; -import { useDrop } from "react-dnd"; import Box from "@material-ui/core/Box"; import Container from "@material-ui/core/Container"; import useResizeObserver from "use-resize-observer"; -import { useRecoilState, useRecoilValue } from "recoil"; +import { useRecoilState } from "recoil"; import { GridColumns } from "app/modules/report-module/components/grid-columns"; -import HeaderBlock from "app/modules/report-module/sub-module/components/headerBlock"; +import HeaderBlock from "app/modules/report-module/components/headerBlock"; import { ItemComponent } from "app/modules/report-module/components/order-container"; -import { ReportElementsType } from "app/modules/report-module/components/right-panel-create-view"; -import AddRowFrameButton from "app/modules/report-module/sub-module/rowStructure/addRowFrameButton"; -import RowFrame from "app/modules/report-module/sub-module/rowStructure"; -import { - ReportCreateViewProps, - PlaceholderProps, -} from "app/modules/report-module/views/create/data"; +import AddRowFrameButton from "app/modules/report-module/components/rowStructure/addRowFrameButton"; +import RowFrame from "app/modules/report-module/components/rowStructure"; +import { ReportCreateViewProps } from "app/modules/report-module/views/create/data"; import { IRowFrameStructure, reportContentContainerWidth, - isDividerOrRowFrameDraggingAtom, } from "app/state/recoil/atoms"; import TourGuide from "app/components/Dialogs/TourGuide"; import { useTitle } from "react-use"; +import PlaceHolder from "app/modules/report-module/components/placeholder"; function ReportCreateView(props: Readonly) { useTitle("DX Dataxplorer - Create Report"); @@ -197,127 +192,3 @@ function ReportCreateView(props: Readonly) { } export default ReportCreateView; - -export const PlaceHolder = (props: PlaceholderProps) => { - const moveCard = React.useCallback((itemId: string) => { - props.updateFramesArray((draft) => { - const dragIndex = draft.findIndex((frame) => frame.id === itemId); - - const dropIndex = - props.index ?? draft.findIndex((frame) => frame.id === props.rowId) + 1; - - const fakeId = v4(); - const tempItem = draft[dragIndex]; - draft[dragIndex].id = fakeId; - - draft.splice(dropIndex, 0, tempItem); - const fakeIndex = draft.findIndex((frame) => frame.id === fakeId); - draft.splice(fakeIndex, 1); - }); - }, []); - const [{ isOver, handlerId, item: dragItem }, drop] = useDrop(() => ({ - // The type (or types) to accept - strings or symbols - accept: [ - ReportElementsType.DIVIDER, - ReportElementsType.ROWFRAME, - ReportElementsType.ROW, - ], - // Props to collect - collect: (monitor) => ({ - isOver: monitor.isOver(), - canDrop: monitor.canDrop(), - item: monitor.getItem(), - handlerId: monitor.getHandlerId(), - }), - drop: (item: any, monitor) => { - if (item.type === ReportElementsType.ROW) { - moveCard(item.id); - } else { - props.updateFramesArray((draft) => { - const tempIndex = - props.index ?? - draft.findIndex((frame) => frame.id === props.rowId) + 1; - - const id = v4(); - draft.splice(tempIndex, 0, { - id, - frame: { - rowId: id, - rowIndex: tempIndex, - - type: item.type, - }, - content: - item.type === ReportElementsType.ROWFRAME ? [] : ["divider"], - contentWidths: [], - contentHeights: [], - contentTypes: - item.type === ReportElementsType.ROWFRAME ? [] : ["divider"], - structure: null, - }); - }); - } - }, - })); - - const isItemDragging = useRecoilValue(isDividerOrRowFrameDraggingAtom); - - const itemDragIndex = props.framesArray.findIndex( - (frame) => frame.id === isItemDragging.rowId - ); - - const placeholderIndex = - props.index ?? - props.framesArray.findIndex((frame) => frame.id === props.rowId) + 1; - - const dragIndex = props.framesArray.findIndex( - (frame) => frame.id === (dragItem as any)?.id - ); - - const placeholderActive = () => { - if (isOver) { - if (dragIndex === -1) { - return true; - } - if (placeholderIndex === dragIndex) { - return false; - } - if (placeholderIndex - 1 === dragIndex) { - return false; - } - return true; - } - return false; - }; - - const isDroppable = () => { - if (isItemDragging.state) { - if (itemDragIndex === -1) { - return true; - } - if (placeholderIndex === itemDragIndex) { - return false; - } - if (placeholderIndex - 1 === itemDragIndex) { - return false; - } - return true; - } - return false; - }; - - return ( -
- ); -}; diff --git a/src/app/modules/report-module/views/edit/index.tsx b/src/app/modules/report-module/views/edit/index.tsx index c0c948aaf..677353f7b 100644 --- a/src/app/modules/report-module/views/edit/index.tsx +++ b/src/app/modules/report-module/views/edit/index.tsx @@ -400,7 +400,6 @@ function ReportEditView(props: Readonly) { height: 20px; `} /> - {/* */}