Skip to content
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

Dataverse Featured Items support #11124

Open
wants to merge 51 commits into
base: develop
Choose a base branch
from
Open

Dataverse Featured Items support #11124

wants to merge 51 commits into from

Conversation

GPortas
Copy link
Contributor

@GPortas GPortas commented Dec 23, 2024

What this PR does / why we need it:

CRUD endpoints for Collection Featured Items have been implemented. In particular, the following endpoints have been implemented:

  • Create a feature item (POST /api/dataverses/<dataverse_id>/featuredItems)
  • Update a feature item (PUT /api/dataverseFeaturedItems/<item_id>)
  • Delete a feature item (DELETE /api/dataverseFeaturedItems/<item_id>)
  • List all featured items in a collection (GET /api/dataverses/<dataverse_id>/featuredItems)
  • Delete all featured items in a collection (DELETE /api/dataverses/<dataverse_id>/featuredItems)
  • Update all featured items in a collection (PUT /api/dataverses/<dataverse_id>/featuredItems)

Which issue(s) this PR closes:

Suggestions on how to test this:

Follow the docs added to native-api to make curl calls and test the different operations on featured items.

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

No

Is there a release notes update needed for this change?:

Yes, attached.

Preview docs at https://dataverse-guide--11124.org.readthedocs.build/en/11124/api/native-api.html#list-collection-featured-items

@GPortas GPortas marked this pull request as draft December 23, 2024 12:51

This comment has been minimized.

1 similar comment

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@GPortas GPortas added the SPA.Q1 Not related to any specific Q1 feature label Jan 15, 2025

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@GPortas GPortas marked this pull request as ready for review January 16, 2025 15:59
@GPortas GPortas added Size: 10 A percentage of a sprint. 7 hours. Original size: 10 SPA These changes are required for the Dataverse SPA FY25 Sprint 15 FY25 Sprint 15 (2025-01-15 - 2025-01-29) labels Jan 16, 2025

This comment has been minimized.

@pdurbin pdurbin self-assigned this Jan 16, 2025
Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

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

This is a big PR that adds some very useful functionality. I'm leaving some initial feedback and assigning @GPortas to take a look.

@@ -0,0 +1,112 @@
package edu.harvard.iq.dataverse.api;

Copy link
Member

Choose a reason for hiding this comment

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

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 don't have access to Jenkins. Can you tell me exactly which tests are failing? I can also request temporal access to Jenkins.

doc/release-notes/10943-featured-items.md Show resolved Hide resolved
doc/sphinx-guides/source/api/native-api.rst Outdated Show resolved Hide resolved

The ``file`` parameter must be specified for each image we want to attach to featured items. Note that images can be shared between featured items, so ``fileName`` can have the same value in different featured items.

The ``id`` parameter must be ``0`` for new items or set to the item's identifier for updates. The ``fileName`` parameter should be empty to exclude an image or match the name of a file sent in a ``file`` parameter to set a new image. ``keepFile`` must always be set to ``false``, unless it's an update to a featured item where we want to preserve the existing image, if one exists.
Copy link
Member

Choose a reason for hiding this comment

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

Wow! This is a bit confusing! The examples as well, with all the -F arguments. Did you consider other ways of accepting input, such as having all input in a JSON file? Are you happy with the final result?

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 tried to simplify the input, but couldn't make it simpler due to how the API handles Multipart Form Data input type. For example, the inability to send optional parameters while maintaining the relationship between properties of the same object in the form forced me to structure it this way (e.g. using 0 as id, or keepFile=false when not needed). Currently, js-dataverse successfully calls the endpoint, and it works correctly in the SPA (check the related PRs: IQSS/dataverse-client-javascript#235 and IQSS/dataverse-frontend#575). I will be happy to simplify it further in the future if we find a better way to send the data.

Comment on lines +15 to +17
@Entity
@Table(indexes = @Index(columnList = "displayOrder"))
public class DataverseFeaturedItem {
Copy link
Member

Choose a reason for hiding this comment

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

We don't need a SQL upgrade script because we're creating a new table, is that right?

Comment on lines +44 to +45
.addTags("h1", "h2", "h3", "kbd", "hr", "s", "del", "map", "area")
.addAttributes("img", "usemap")
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little confused what's going on here. Are we allowing more HTML tags and attributes? Does this affect other parts of the app, besides features items? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. We only allow more HTML tags for featured items, where for example we need to prevent HTML sanitization from removing important tags like className. Previous use cases work as before. The many changes you see are simply due to the refactoring I did to selectively support the new logic for featured items.

GPortas and others added 2 commits January 21, 2025 18:59
Co-authored-by: Philip Durbin <philip_durbin@harvard.edu>
Co-authored-by: Philip Durbin <philip_durbin@harvard.edu>

This comment has been minimized.

1 similar comment
Copy link

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:10943-featured-items
ghcr.io/gdcc/configbaker:10943-featured-items

🚢 See on GHCR. Use by referencing with full name as printed above, mind the registry name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FY25 Sprint 15 FY25 Sprint 15 (2025-01-15 - 2025-01-29) GREI Re-arch Issues related to the GREI Dataverse rearchitecture Original size: 10 Size: 10 A percentage of a sprint. 7 hours. SPA.Q1 Not related to any specific Q1 feature SPA.Q4 Not related to any specific Q4 feature SPA These changes are required for the Dataverse SPA
Projects
Status: In Review 🔎
Development

Successfully merging this pull request may close these issues.

API support for SPA Featured Items
3 participants