-
Notifications
You must be signed in to change notification settings - Fork 112
feat: add custom cover image support for datasets #4117
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
base: main
Are you sure you want to change the base?
Conversation
|
@aicam please review it first before @aglinxinyuan does it. |
aicam
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left minor comments
...-dataset-explorer/user-dataset-version-filetree/user-dataset-version-filetree.component.scss
Show resolved
Hide resolved
...er-dataset-explorer/user-dataset-version-filetree/user-dataset-version-filetree.component.ts
Outdated
Show resolved
Hide resolved
...er-dataset-explorer/user-dataset-version-filetree/user-dataset-version-filetree.component.ts
Outdated
Show resolved
Hide resolved
|
@xuang7 Please resolve those comments after they are taken care of. |
Signed-off-by: Xuan Gu <[email protected]>
Head branch was pushed to by a user without write access
|
@aglinxinyuan Please review this PR. |
|
This PR is using a recently removed API (dataset/file). I’ll update the code soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds functionality for dataset owners to set custom cover images from files within their datasets, improving visual presentation on the hub/home page. However, there is a critical issue with the SQL migration file that must be addressed before merging.
- Added a
cover_imagecolumn to the dataset table to store image paths in{dvid}/{relative_path}format - Implemented a backend API endpoint (
POST /api/dataset/{did}/update/cover) with file size validation (10 MB limit) - Added UI controls in the file tree to set cover images for image files and display them on the hub/home page
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| sql/updates/17.sql | CRITICAL: Migration adds wrong column to wrong table (affiliation to user instead of cover_image to dataset) |
| sql/texera_ddl.sql | Adds cover_image column definition to dataset table schema |
| frontend/src/app/hub/component/browse-section/browse-section.component.ts | Implements cover image URL construction and fallback logic |
| frontend/src/app/hub/component/browse-section/browse-section.component.html | Updates template to use dynamic cover images with error handling |
| frontend/src/app/dashboard/type/dashboard-entry.ts | Adds coverImageUrl property to DashboardEntry type |
| frontend/src/app/dashboard/service/user/dataset/dataset.service.ts | Adds updateDatasetCoverImage service method with inconsistent API design |
| frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-version-filetree/user-dataset-version-filetree.component.ts | Adds image file detection and cover image setter functionality |
| frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-version-filetree/user-dataset-version-filetree.component.scss | Renames CSS class from delete-button to icon-button for reusability |
| frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-version-filetree/user-dataset-version-filetree.component.html | Adds "Set as Cover" button for image files in file tree |
| frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-version-creator/user-dataset-version-creator.component.ts | Initializes coverImage field to undefined in dataset creation |
| frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.ts | Implements onSetCoverImage handler with error notification |
| frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.html | Connects cover image event to handler |
| frontend/src/app/common/type/dataset.ts | Adds coverImage property to Dataset interface |
| file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala | Adds updateDatasetCoverImage endpoint with size validation but missing file type validation and tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala
Show resolved
Hide resolved
frontend/src/app/dashboard/service/user/dataset/dataset.service.ts
Outdated
Show resolved
Hide resolved
file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala
Show resolved
Hide resolved
file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala
Outdated
Show resolved
Hide resolved
file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala
Show resolved
Hide resolved
file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala
Show resolved
Hide resolved
frontend/src/app/hub/component/browse-section/browse-section.component.ts
Outdated
Show resolved
Hide resolved
file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala
Show resolved
Hide resolved
|
Please address the comments. |
Signed-off-by: Xuan Gu <[email protected]>
|
@aicam Please take the lead to finish this PR. |
aicam
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to add test cases with corner cases
file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala
Outdated
Show resolved
Hide resolved
file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala
Outdated
Show resolved
Hide resolved
file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala
Show resolved
Hide resolved
file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala
Outdated
Show resolved
Hide resolved
aicam
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! just fix the comments and makes sure no logics are duplicate
file-service/src/main/scala/org/apache/texera/service/resource/DatasetResource.scala
Outdated
Show resolved
Hide resolved
file-service/src/test/scala/org/apache/texera/service/resource/DatasetResourceSpec.scala
Show resolved
Hide resolved
| assertThrows[BadRequestException] { | ||
| DatasetResource.validateSafePath(" ") | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one missing test is a correct test that should set cover and retrieve it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn’t add “set cover successfully” tests because they would require a real file in storage. Would you like me to add test file setup? I could upload a minimal JPEG (a few hundred bytes) during the test setup to enable this kind of test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just create a JPEG image from empty byte array
What changes were proposed in this PR?
This PR adds support for dataset owners to set a custom cover image from files within their dataset. This improves visual presentation and makes datasets easier to recognize on the hub/home page.
Changes:
Database:
{dvid}/{relative_path}format (e.g.,v1/demo.png)Backend:
POST /api/dataset/{did}/update/cover– Set dataset cover image.jpg,.jpeg,.png,.gif,.webp) and size (max 10 MB)GET /api/dataset/{did}/cover– Get cover image with 307 redirect to presigned URLFrontend:
Public datasets display:
Any related issues, documentation, discussions?
Closes #4115
How was this PR tested?
Test cases include: path traversal rejection, absolute path rejection, invalid file type rejection, empty/null path rejection, unauthorized user rejection, private dataset access checks, and validateSafePath coverage.
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude for code review