Skip to content

Conversation

@xuang7
Copy link
Contributor

@xuang7 xuang7 commented Dec 7, 2025

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
Copy link
Contributor

chenlica commented Dec 7, 2025

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

Copy link
Contributor

@aicam aicam left a 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

@aicam aicam enabled auto-merge (squash) January 2, 2026 19:21
@chenlica
Copy link
Contributor

chenlica commented Jan 3, 2026

@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
Copy link
Contributor

chenlica commented Jan 4, 2026

@aglinxinyuan Please review this PR.

@xuang7
Copy link
Contributor Author

xuang7 commented Jan 4, 2026

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

Copy link
Contributor

Copilot AI left a 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_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
Contributor

Please address the comments.

@chenlica
Copy link
Contributor

chenlica commented Jan 6, 2026

@aicam Please take the lead to finish this PR.

Copy link
Contributor

@aicam aicam left a 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

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

@aicam aicam left a 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

assertThrows[BadRequestException] {
DatasetResource.validateSafePath(" ")
}
}
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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

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

4 participants