refactor: restructure DatasetCard component for improved readability and maintainability#30617
refactor: restructure DatasetCard component for improved readability and maintainability#30617CodingOnStar merged 3 commits intomainfrom
Conversation
…and maintainability - Split DatasetCard into multiple subcomponents: CornerLabels, DatasetCardHeader, DatasetCardFooter, DatasetCardModals, Description, TagArea, and OperationsPopover. - Introduced a custom hook, useDatasetCardState, to manage state and modal logic. - Enhanced tag management and modal handling for renaming and deletion. - Improved code organization and reduced complexity in the main DatasetCard component.
Summary of ChangesHello @CodingOnStar, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on a significant refactoring of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is an excellent refactoring of the DatasetCard component. By splitting it into smaller, focused subcomponents and extracting state management into the useDatasetCardState custom hook, you've significantly improved the code's readability, maintainability, and organization. The new structure is much cleaner and follows React best practices. I've left a few suggestions to further enhance code clarity and robustness. Great work on this cleanup!
web/app/components/datasets/list/dataset-card/hooks/use-dataset-card-state.ts Show resolved Hide resolved
web/app/components/datasets/list/dataset-card/components/dataset-card-footer.tsx Show resolved Hide resolved
web/app/components/datasets/list/dataset-card/components/dataset-card-footer.tsx Show resolved Hide resolved
…DatasetCardFooter - Updated error handling in useDatasetCardState to differentiate between Response and Error types for better clarity. - Removed redundant document count checks in DatasetCardFooter for cleaner code and improved readability.
There was a problem hiding this comment.
Pull request overview
This PR refactors the DatasetCard component to improve code organization and maintainability by breaking it down into smaller, focused subcomponents and extracting state management logic into a custom hook.
- Split the monolithic component into 7 focused subcomponents for better separation of concerns
- Introduced
useDatasetCardStatehook to centralize state and modal management - Created new service hooks (
useCheckDatasetUsage,useDeleteDataset) using React Query for better data fetching patterns
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
web/service/use-dataset-card.ts | New service file with React Query mutations for dataset operations |
web/app/components/datasets/list/dataset-card/index.tsx | Refactored main component to compose subcomponents and use the new hook |
web/app/components/datasets/list/dataset-card/hooks/use-dataset-card-state.ts | New custom hook managing state, modals, and dataset operations |
web/app/components/datasets/list/dataset-card/components/tag-area.tsx | Extracted tag selector area into standalone component |
web/app/components/datasets/list/dataset-card/components/operations-popover.tsx | Extracted operations menu popover into standalone component |
web/app/components/datasets/list/dataset-card/components/description.tsx | Extracted description display into standalone component |
web/app/components/datasets/list/dataset-card/components/dataset-card-modals.tsx | Extracted modal rendering logic into standalone component |
web/app/components/datasets/list/dataset-card/components/dataset-card-header.tsx | Extracted header section with icon and metadata into standalone component |
web/app/components/datasets/list/dataset-card/components/dataset-card-footer.tsx | Extracted footer with document counts and timestamps into standalone component |
web/app/components/datasets/list/dataset-card/components/corner-labels.tsx | Extracted corner labels (unavailable/pipeline) into standalone component |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
web/app/components/datasets/list/dataset-card/hooks/use-dataset-card-state.ts Show resolved Hide resolved
web/app/components/datasets/list/dataset-card/components/operations-popover.tsx Outdated Show resolved Hide resolved
web/app/components/datasets/list/dataset-card/hooks/use-dataset-card-state.ts Outdated Show resolved Hide resolved
web/app/components/datasets/list/dataset-card/components/dataset-card-footer.tsx Show resolved Hide resolved
web/app/components/datasets/list/dataset-card/components/dataset-card-header.tsx Show resolved Hide resolved
web/app/components/datasets/list/dataset-card/hooks/use-dataset-card-state.ts Outdated Show resolved Hide resolved
web/app/components/datasets/list/dataset-card/hooks/use-dataset-card-state.ts Show resolved Hide resolved
…ved tag management - Modified handleExportPipeline to accept an optional boolean parameter. - Removed the custom useSyncTags hook and implemented useEffect for syncing tags directly in useDatasetCardState, enhancing clarity and reducing complexity.
Summary
refactor: restructure DatasetCard component for improved readability and maintainability
Checklist
make lintandmake type-check(backend) andcd web && npx lint-staged(frontend) to appease the lint gods