Skip to content

feat(ui) Add drag and drop functionality to modules on home page #14100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 18, 2025

Conversation

chriscollins3456
Copy link
Collaborator

@chriscollins3456 chriscollins3456 commented Jul 15, 2025

This PR adds the ability to drag and drop modules between rows, within rows, and to new rows. The functionality utilizes a well known library that's already being used in our SaaS product, so it is still consistent.

Leverage the existing page module context in order to moveModule and save the state of the template and save the correct template on the backend as well. This works with the same logic for updating templates as is with other edits to modules like adding or removing them.

There's a good amount of refactoring here to factor in the drag and drop context and logic. It's pretty complicated stuff so I tried to modularize it and break it down into readable functions as much as possible.

Note: a huge part of the diff is yarn lock changes and tests

image
Screen.Recording.2025-07-16.at.7.09.37.PM.1.mov

@github-actions github-actions bot added the product PR or Issue related to the DataHub UI/UX label Jul 15, 2025
@datahub-cyborg datahub-cyborg bot added the needs-review Label for PRs that need review from a maintainer. label Jul 15, 2025
Copy link

codecov bot commented Jul 15, 2025

Bundle Report

Changes will increase total bundle size by 49.53kB (0.22%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
datahub-react-web-esm 22.23MB 49.53kB (0.22%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: datahub-react-web-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/index-*.js 49.53kB 18.59MB 0.27%

Files in assets/index-*.js:

  • ./src/app/homeV3/templateRow/components/ModuleDropZone.tsx → Total Size: 828 bytes

  • ./src/app/homeV3/context/hooks/useModuleOperations.ts → Total Size: 8.79kB

  • ./src/app/homeV3/context/hooks/utils/moduleOperationsUtils.ts → Total Size: 2.42kB

  • ./src/app/homeV3/modules/assetCollection/AssetCollectionModal.tsx → Total Size: 1.72kB

  • ./src/app/homeV3/module/components/LargeModule.tsx → Total Size: 2.65kB

  • ./src/app/homeV3/template/components/NewRowDropZone.tsx → Total Size: 700 bytes

  • ./src/app/homeV3/templateRow/components/RowLayout.tsx → Total Size: 1.39kB

  • ./src/app/homeV3/context/PageTemplateContext.tsx → Total Size: 1.81kB

  • ./src/app/homeV3/template/components/DragAndDropProvider.tsx → Total Size: 931 bytes

  • ./src/app/homeV3/template/Template.tsx → Total Size: 1.14kB

  • ./src/app/homeV3/template/components/TemplateGrid.tsx → Total Size: 1.0kB

  • ./src/app/homeV3/templateRow/TemplateRow.tsx → Total Size: 365 bytes

  • ./src/app/homeV3/templateRow/hooks/useDragRowContext.ts → Total Size: 264 bytes

  • ./src/app/homeV3/templateRow/hooks/useTemplateRowLogic.ts → Total Size: 879 bytes

  • ./src/app/homeV3/module/Module.tsx → Total Size: 657 bytes

  • ./src/app/homeV3/module/components/ModuleContainer.tsx → Total Size: 669 bytes

  • ./src/app/homeV3/context/hooks/useDragAndDrop.ts → Total Size: 1.56kB

Copy link

alwaysmeticulous bot commented Jul 15, 2025

✅ Meticulous spotted 0 visual differences across 1589 screens tested: view results.

Meticulous evaluated ~9 hours of user flows against your PR.

Expected differences? Click here. Last updated for commit eb9915c. This comment will update as new commits are pushed.

Copy link

codecov bot commented Jul 16, 2025

@chriscollins3456 chriscollins3456 changed the title [WIP] Add drag and drop functionality to modules on home page feat(ui) Add drag and drop functionality to modules on home page Jul 16, 2025
Base automatically changed from cc--ch-555-remove-modules to master July 17, 2025 13:34
Copy link
Collaborator

@jayacryl jayacryl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beauty

if (!template) return null;

const { rowIndex: toRowIndex } = toPosition;
if (toRowIndex === undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when would this happen?

@@ -85,3 +107,6 @@ export default function LargeModule({ children, module, loading, onClickViewAll
</ModuleContainer>
);
}

// Export memoized component to prevent unnecessary re-renders
export default memo(LargeModule);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

insertNewRow?: boolean;
}

function NewRowDropZoneComponent({ rowIndex, insertNewRow = false }: Props) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can guess for this one, but comments for many of these sub components describing where & how they're used / expected behavior could be helpful longer term

import TemplateRow from '@app/homeV3/templateRow/TemplateRow';
import { WrappedRow } from '@app/homeV3/templateRow/types';

// import NewRowDropZone from './NewRowDropZone';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete?

const { active } = useDndContext();

return useMemo(() => {
const activeDragData = active?.data?.current as { position?: ModulePositionInput } | undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to avoid cast here?

@datahub-cyborg datahub-cyborg bot added pending-submitter-merge and removed needs-review Label for PRs that need review from a maintainer. labels Jul 17, 2025
@chriscollins3456 chriscollins3456 force-pushed the cc--ch-535-drag-and-drop branch from 2ca1df7 to eb9915c Compare July 17, 2025 22:14
@chriscollins3456 chriscollins3456 merged commit 784c005 into master Jul 18, 2025
32 of 34 checks passed
@chriscollins3456 chriscollins3456 deleted the cc--ch-535-drag-and-drop branch July 18, 2025 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-submitter-merge product PR or Issue related to the DataHub UI/UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants