Repository navigation
feat: add custom cover image support for datasets - #4117
Conversation
|
@aicam please review it first before @aglinxinyuan does it. |
|
@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.
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.
|
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.
Make sure to add test cases with corner cases
aicam
left a comment
There was a problem hiding this comment.
LGTM! just fix the comments and makes sure no logics are duplicate
<!-- Thanks for sending a pull request (PR)! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: [Contributing to Texera](https://github.com/apache/texera/blob/main/CONTRIBUTING.md) 2. Ensure you have added or run the appropriate tests for your PR 3. If the PR is work in progress, mark it a draft on GitHub. 4. Please write your PR title to summarize what this PR proposes, we are following Conventional Commits style for PR titles as well. 5. Be sure to keep the PR description updated to reflect all changes. --> ### What changes were proposed in this PR? <!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes. Here are some tips for you: 1. If you propose a new API, clarify the use case for a new API. 2. If you fix a bug, you can clarify why it is a bug. 3. If it is a refactoring, clarify what has been changed. 3. It would be helpful to include a before-and-after comparison using screenshots or GIFs. 4. Please consider writing useful notes for better and faster reviews. --> 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:** - Added a cover_image column to the dataset table. - Stores cover image as `{dvid}/{relative_path}` format (e.g., `v1/demo.png`) - **Backend:** - `POST /api/dataset/{did}/update/cover` – Set dataset cover image - Validates file type (`.jpg`, `.jpeg`, `.png`, `.gif`, `.webp`) and size (max 10 MB) - `GET /api/dataset/{did}/cover` – Get cover image with 307 redirect to presigned URL - Only accessible for public datasets - **Frontend:** - Adds a “Set as Cover” button next to image files in the version file tree, button only visible for image file (.jpg, .jpeg, .png, .gif, .webp) <img width="402" height="305" alt="set_icon" src="https://github.com/user-attachments/assets/acb6baad-8fed-4851-b230-e8fb07a02ec8" /> - home page displays cover images on dataset cards with automatic fallback to default background Public datasets display: | Before (default cover) | After (customized cover) | | --- | --- | | <img width="339" height="461" alt="before" src="https://github.com/user-attachments/assets/bad4ee74-8c93-49df-a165-a6abe89e6d94" /> | <img width="339" height="461" alt="after" src="https://github.com/user-attachments/assets/ae51fa2d-cc4f-4732-b141-035a7f3d3591" /> | ### Any related issues, documentation, discussions? <!-- Please use this section to link other resources if not mentioned already. 1. If this PR fixes an issue, please include `Fixes apache#1234`, `Resolves apache#1234` or `Closes apache#1234`. If it is only related, simply mention the issue number. 2. If there is design documentation, please add the link. 3. If there is a discussion in the mailing list, please add the link. --> Closes apache#4115 ### How was this PR tested? <!-- If tests were added, say they were added here. Or simply mention that if the PR is tested with existing test cases. Make sure to include/update test cases that check the changes thoroughly including negative and positive cases if possible. If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future. If tests were not added, please describe why they were not added and/or why it was difficult to add. --> 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? <!-- If generative AI tooling has been used in the process of authoring this PR, please include the phrase: 'Generated-by: ' followed by the name of the tool and its version. If no, write 'No'. Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details. --> Generated-by: Claude for code review --------- Signed-off-by: Xuan Gu <[email protected]>
<!-- Thanks for sending a pull request (PR)! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: [Contributing to Texera](https://github.com/apache/texera/blob/main/CONTRIBUTING.md) 2. Ensure you have added or run the appropriate tests for your PR 3. If the PR is work in progress, mark it a draft on GitHub. 4. Please write your PR title to summarize what this PR proposes, we are following Conventional Commits style for PR titles as well. 5. Be sure to keep the PR description updated to reflect all changes. --> ### What changes were proposed in this PR? <!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes. Here are some tips for you: 1. If you propose a new API, clarify the use case for a new API. 2. If you fix a bug, you can clarify why it is a bug. 3. If it is a refactoring, clarify what has been changed. 3. It would be helpful to include a before-and-after comparison using screenshots or GIFs. 4. Please consider writing useful notes for better and faster reviews. --> 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:** - Added a cover_image column to the dataset table. - Stores cover image as `{dvid}/{relative_path}` format (e.g., `v1/demo.png`) - **Backend:** - `POST /api/dataset/{did}/update/cover` – Set dataset cover image - Validates file type (`.jpg`, `.jpeg`, `.png`, `.gif`, `.webp`) and size (max 10 MB) - `GET /api/dataset/{did}/cover` – Get cover image with 307 redirect to presigned URL - Only accessible for public datasets - **Frontend:** - Adds a “Set as Cover” button next to image files in the version file tree, button only visible for image file (.jpg, .jpeg, .png, .gif, .webp) <img width="402" height="305" alt="set_icon" src="https://github.com/user-attachments/assets/acb6baad-8fed-4851-b230-e8fb07a02ec8" /> - home page displays cover images on dataset cards with automatic fallback to default background Public datasets display: | Before (default cover) | After (customized cover) | | --- | --- | | <img width="339" height="461" alt="before" src="https://github.com/user-attachments/assets/bad4ee74-8c93-49df-a165-a6abe89e6d94" /> | <img width="339" height="461" alt="after" src="https://github.com/user-attachments/assets/ae51fa2d-cc4f-4732-b141-035a7f3d3591" /> | ### Any related issues, documentation, discussions? <!-- Please use this section to link other resources if not mentioned already. 1. If this PR fixes an issue, please include `Fixes apache#1234`, `Resolves apache#1234` or `Closes apache#1234`. If it is only related, simply mention the issue number. 2. If there is design documentation, please add the link. 3. If there is a discussion in the mailing list, please add the link. --> Closes apache#4115 ### How was this PR tested? <!-- If tests were added, say they were added here. Or simply mention that if the PR is tested with existing test cases. Make sure to include/update test cases that check the changes thoroughly including negative and positive cases if possible. If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future. If tests were not added, please describe why they were not added and/or why it was difficult to add. --> 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? <!-- If generative AI tooling has been used in the process of authoring this PR, please include the phrase: 'Generated-by: ' followed by the name of the tool and its version. If no, write 'No'. Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details. --> Generated-by: Claude for code review --------- Signed-off-by: Xuan Gu <[email protected]>
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