Skip to content

collections: improve service and resource apis#110

Merged
zzacharo merged 8 commits intoinveniosoftware:masterfrom
jrcastro2:improve-collections-api-master
Apr 2, 2026
Merged

collections: improve service and resource apis#110
zzacharo merged 8 commits intoinveniosoftware:masterfrom
jrcastro2:improve-collections-api-master

Conversation

@jrcastro2
Copy link
Copy Markdown
Contributor

@jrcastro2 jrcastro2 commented Jan 15, 2026

@jrcastro2 jrcastro2 force-pushed the improve-collections-api-master branch 2 times, most recently from 1ba3ad8 to 091ea25 Compare January 15, 2026 16:45
@egabancho
Copy link
Copy Markdown
Member

@jrcastro2, I am pretty biased on this one 😂 Probably somebody from the CDS/Zenodo team should look into it.

Comment thread invenio_collections/services/schema.py Outdated
Comment thread invenio_collections/api.py Outdated
Comment thread tests/test_service.py
ctree=tree,
)

# Try to delete without cascade should fail
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we allow users to try to delete without cascade if there are children in the UI?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, the test there is for the service, the func requires the cascade param, the tests are meant so that if not passed it doesn't allow to delete the collection if there are children.

path=path,
title=title,
search_query=query,
search_query=search_query,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the thinking behind renaming query to search_query?
Does it break backwards-compatibility?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reason for the rename is that IMHO it was wrong from before. In the Collection API obj we do have both, query property and the search_query, they are different things and at some point we are calling self.query and self.search_query, which could lead to confusion and it was actually causing issues for me so I decided to align things. The backwards compatibility would break if there is external code calling the Collection.create() (which I don't think should be the case). Other than that should be fine specially since it was a feature that was not fully used, but let me know if I am missing something.

@jrcastro2 jrcastro2 force-pushed the improve-collections-api-master branch 4 times, most recently from e4b7426 to 7a43162 Compare February 23, 2026 12:50
@jrcastro2 jrcastro2 force-pushed the improve-collections-api-master branch 2 times, most recently from 13442e0 to b567c6e Compare March 9, 2026 18:16
Comment thread invenio_collections/templates/semantic-ui/invenio_collections/collections.html Outdated

# revision identifiers, used by Alembic.
revision = "3c1b8d0e7f52"
down_revision = "d2f434c0ac92"
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.

@palkerecsenyi @jrcastro2 is this the correct revision?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for checking, this looks correct. This is the latest revision

Comment thread invenio_collections/assets/semantic-ui/js/invenio_collections/api/api.js Outdated
Comment thread invenio_collections/assets/semantic-ui/js/invenio_collections/api/api.js Outdated
import DeleteCollectionAction from "./actions/DeleteCollectionAction";
import DeleteCollectionTreeAction from "./actions/DeleteCollectionTreeAction";

class CollectionTreeCardGroup extends Component {
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.

this component also needs responsibilities separation. Some of the states of the forms are belonging to child forms components, it is not entirely understandable to me why this parent component is evaluating these internal "children states"?
The component is very complex and needs simplifications in my opinion

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reason the parent holds the form state is cuz of the change to use modal actions (on the demo it was suggested to use them), this means that the Save button lives in Modal.Actions but Formik is in the child, so we lift just { isValid, isSubmitting, handleSubmit } via onFormReady. I believe that the same approach used in other places.

In any case I moved each modal to single cmp so that the state of each is not in the parent and like that it might be a bit more understandable but still each parent modal holds the stat.

Still this cmp is quite complex since it has the darg logic as well, let me know if this is good enough or if we should try to move this away as well.

Comment thread invenio_collections/models.py Outdated
@jrcastro2 jrcastro2 force-pushed the improve-collections-api-master branch 2 times, most recently from 5890b4f to a1bd862 Compare March 18, 2026 12:44
Copy link
Copy Markdown
Member

@slint slint left a comment

Choose a reason for hiding this comment

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

Minor comments on the backend parts, some shelveable.

Comment thread invenio_collections/services/service.py Outdated
Comment thread invenio_collections/resources/resource.py Outdated
Comment thread invenio_collections/resources/resource.py Outdated
Comment thread invenio_collections/services/service.py
Comment thread invenio_collections/services/service.py
Comment thread invenio_collections/services/service.py
jrcastro2 and others added 5 commits March 23, 2026 12:10
* Complete resource layer with missing collections features
* Enhance service layer
* Add tests
* Improve schema

Co-Authored-By: egabancho <me@egabancho.com>
Comment thread invenio_collections/assets/semantic-ui/js/invenio_collections/api/api.js Outdated
Comment thread invenio_collections/assets/semantic-ui/js/invenio_collections/api/api.js Outdated
Comment thread invenio_collections/resources/config.py Outdated
collection_tree_cls = CollectionTree
tree_schema = CollectionTreeSchema

links_item = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are there no other links?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I intentionally left just search for now because adding self_html requires the community slug, which isn't directly on the Collection model anymore (only namespace_id). I think this should be tackled when there is more work done on abstracting invenio-collections.

)
.scalar()
)
data["order"] = (max_order or 0) + 10
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why +10?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reason to use 10 comes from the initial implementation where the order was a form field and the user could input it. It would be easier to insert a new value in a middle position if we use tens, otherwise we would need to update all the other values. Right now we mostly insert at the end by default and let the user reorder the values which ends up reassigning the order to all the values. So this is not that much needed still I believe is a nice addition to keep then separated by tens.

Comment thread invenio_collections/models.py Outdated
Comment thread pyproject.toml Outdated
@jrcastro2 jrcastro2 force-pushed the improve-collections-api-master branch 4 times, most recently from 620e531 to a22152c Compare March 25, 2026 12:19
@jrcastro2 jrcastro2 force-pushed the improve-collections-api-master branch from a22152c to 4ad4366 Compare March 26, 2026 12:29
Comment thread invenio_collections/services/config.py
@jrcastro2 jrcastro2 force-pushed the improve-collections-api-master branch from 4ad4366 to 2324fae Compare March 31, 2026 12:41
@zzacharo zzacharo merged commit 549f17f into inveniosoftware:master Apr 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 - Implement full collections management + Browse tab visibility rules

7 participants