CONSOLE-5015: Replace react-dnd with PF MultipleFileUpload in topology#16179
CONSOLE-5015: Replace react-dnd with PF MultipleFileUpload in topology#16179logonoff wants to merge 1 commit intoopenshift:mainfrom
Conversation
Replace the react-dnd DropTarget/withDragDropContext HOC pattern in DroppableTopologyComponent with PatternFly's MultipleFileUpload, which wraps react-dropzone internally. This removes the dependency on react-dnd and react-dnd-html5-backend for the topology file drop zone. DroppableTopologyComponent now wraps TopologyView in a MultipleFileUpload (with noClick/noKeyboard to prevent accidental file dialogs) when file upload extensions are available. TopologyView no longer receives connectDropTarget, isOver, canDrop, or onDrop props. The drop overlay is always rendered but hidden via CSS, becoming visible when MultipleFileUpload applies pf-m-drag-over on drag enter (handled by existing rules in _file-input.scss). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@logonoff: This pull request references CONSOLE-5015 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
/label px-approved |
|
@logonoff: This pull request references CONSOLE-5015 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: logonoff The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
📝 WalkthroughWalkthroughThe drag-and-drop implementation for file uploads in the Topology component has been refactored. The ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment Tip CodeRabbit can generate a title for your PR based on the changes with custom instructions.Set the |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
frontend/packages/topology/src/components/page/DroppableTopologyComponent.tsx (1)
12-21: Add accept property to dropzoneProps to filter files at the UI layer.Validation does occur downstream in
setFileUpload(file-upload-context.ts), which checks extensions and shows a warning toast for unsupported files. However, this component has access toextensionsfrom context but doesn't prevent invalid files from reachingonFileDropvia the dropzone. PatternFly'sMultipleFileUploadsupports anacceptproperty (see droppable-edit-yaml.tsx for pattern), which would reject incompatible files at the UI layer rather than requiring downstream handling.Build the
acceptobject from the availableextensionsarray and pass it indropzonePropsto provide early feedback to users and avoid unnecessary processing.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frontend/packages/topology/src/components/page/DroppableTopologyComponent.tsx` around lines 12 - 21, DroppableTopologyComponent currently computes canDropFile and handles files in handleFileDrop/setFileUpload but doesn't prevent invalid types at the UI; construct an accept map from the extensions array (e.g., mapping MIME/types or extensions to their patterns) and pass that as accept inside the dropzoneProps passed to the MultipleFileUpload component so the dropzone rejects unsupported files before onFileDrop is invoked; update the component where dropzoneProps are defined to include accept (use the existing extensions and canDropFile to build the accept object and include it in the props supplied to MultipleFileUpload).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@frontend/packages/topology/src/components/page/DroppableTopologyComponent.tsx`:
- Around line 12-21: DroppableTopologyComponent currently computes canDropFile
and handles files in handleFileDrop/setFileUpload but doesn't prevent invalid
types at the UI; construct an accept map from the extensions array (e.g.,
mapping MIME/types or extensions to their patterns) and pass that as accept
inside the dropzoneProps passed to the MultipleFileUpload component so the
dropzone rejects unsupported files before onFileDrop is invoked; update the
component where dropzoneProps are defined to include accept (use the existing
extensions and canDropFile to build the accept object and include it in the
props supplied to MultipleFileUpload).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 73b6ebab-63b0-4430-ba0a-d8765b0675d2
📒 Files selected for processing (2)
frontend/packages/topology/src/components/page/DroppableTopologyComponent.tsxfrontend/packages/topology/src/components/page/TopologyView.tsx
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
frontend/packages/topology/src/components/page/TopologyView.tsxfrontend/packages/topology/src/components/page/DroppableTopologyComponent.tsx
🔇 Additional comments (1)
frontend/packages/topology/src/components/page/TopologyView.tsx (1)
330-334: Good decoupling of view from DnD wiring.This keeps
TopologyViewfocused on rendering while drop mechanics stay in the wrapper component, which improves maintainability.Also applies to: 360-360
| noClick: true, | ||
| noKeyboard: true, | ||
| maxFiles: 1, | ||
| }} |
There was a problem hiding this comment.
note we don't use accept here because it suppresses downstream file type validation. dropzone rejections at this stage do not produce feedback for the user.
|
@logonoff: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Replace the react-dnd DropTarget/withDragDropContext HOC pattern in DroppableTopologyComponent with PatternFly's MultipleFileUpload, which wraps react-dropzone internally. This removes the dependency on react-dnd and react-dnd-html5-backend for the topology file drop zone.
DroppableTopologyComponent now wraps TopologyView in a MultipleFileUpload (with noClick/noKeyboard to prevent accidental file dialogs) when file upload extensions are available.
TopologyView no longer receives connectDropTarget, isOver, canDrop, or onDrop props. The drop overlay is always rendered but hidden via CSS, becoming visible when MultipleFileUpload applies pf-m-drag-over on drag enter (handled by existing rules in _file-input.scss).
Summary by CodeRabbit
Release Notes