Skip to content

feat: add custom cover image support for datasets - #4117

Merged
aicam merged 17 commits into
apache:mainfrom
xuang7:feat/dataset-cover
Jan 12, 2026
Merged

aicam merged 17 commits into
apache:mainfrom
xuang7:feat/dataset-cover

Conversation

@xuang7

@xuang7 xuang7 commented Dec 7, 2025 •

Copy link
Copy Markdown
Contributor

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:

    • 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)
      set_icon
    • home page displays cover images on dataset cards with automatic fallback to default background

Public datasets display:

Before (default cover) After (customized cover)
before after

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

@github-actions github-actions Bot added feature ddl-change Changes to the TexeraDB DDL frontend Changes related to the frontend GUI service labels Dec 7, 2025
@xuang7
xuang7 marked this pull request as ready for review December 7, 2025 06:57
@xuang7 xuang7 changed the title Add custom cover image support for datasets feat: add custom cover image support for datasets Dec 7, 2025
@chenlica

chenlica commented Dec 7, 2025

Copy link
Copy Markdown
Contributor

@aicam please review it first before @aglinxinyuan does it.

@aicam aicam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, left minor comments

Comment thread sql/updates/16.sql Resolved
@aicam
aicam enabled auto-merge (squash) January 2, 2026 19:21
@chenlica

chenlica commented Jan 3, 2026

Copy link
Copy Markdown
Contributor

@xuang7 Please resolve those comments after they are taken care of.

auto-merge was automatically disabled January 4, 2026 00:18

Head branch was pushed to by a user without write access

@chenlica

chenlica commented Jan 4, 2026

Copy link
Copy Markdown
Contributor

@aglinxinyuan Please review this PR.

@xuang7

xuang7 commented Jan 4, 2026

Copy link
Copy Markdown
Contributor Author

This PR is using a recently removed API (dataset/file). I’ll update the code soon.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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_image column 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.

@aglinxinyuan

Copy link
Copy Markdown
Contributor

Please address the comments.

@chenlica

chenlica commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

@aicam Please take the lead to finish this PR.

@aicam aicam left a comment

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added the common label Jan 6, 2026
@xuang7
xuang7 requested a review from aicam January 6, 2026 22:31

@aicam aicam left a comment

Copy link
Copy Markdown
Contributor

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

@aicam
aicam enabled auto-merge (squash) January 12, 2026 18:30
@aicam
aicam merged commit a7d2adf into apache:main Jan 12, 2026
10 checks passed
SarahAsad23 pushed a commit to madisonmlin/texera that referenced this pull request May 20, 2026
<!--
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]>
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
<!--
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]>
@xuang7
xuang7 deleted the feat/dataset-cover branch July 1, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common ddl-change Changes to the TexeraDB DDL feature frontend Changes related to the frontend GUI service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add custom cover image support for datasets

5 participants