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

chore(content-releases): releases migration to v5 #20259

Open
wants to merge 44 commits into
base: v5/main
Choose a base branch
from

Conversation

Feranchz
Copy link
Contributor

@Feranchz Feranchz commented May 3, 2024

What does it do?

Migrates and apply new changes on the Content Releases plugin for v5.

Work to do

  • Fix test cases
  • Validate releases with entries with multiple relations and if validation is still working
  • Validate db lifecycles and how affected are releases (entry is deleted, discarded, etc)

* chore: migrate bulkDelete to v5

* chore: change findLocales type to accept strings array

* fix: docs prettier styles

* chore: remove console.log
@Feranchz Feranchz added pr: chore This PR contains chore tasks (cleanups, configs, tooling...) source: core:content-releases labels May 3, 2024
@Feranchz Feranchz self-assigned this May 3, 2024

This comment was marked as spam.

Copy link

vercel bot commented May 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
contributor-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 12, 2024 8:39am

Comment on lines 37 to 41
await strapi.db.query(RELEASE_ACTION_MODEL_UID).deleteMany({
where: {
target_type: model.uid,
target_id: {
$in: (entriesToDelete as Array<{ id: Data.ID }>).map((entry) => entry.id),
},
contentType: model.uid,
locale: where.locale ?? null,
...(where.documentId && { entryDocumentId: where.documentId }),
Copy link
Contributor

Choose a reason for hiding this comment

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

could this create a recursive infinite loop? (deleteMany triggering this same lifecycle)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a good point, honestly never thought about that. But you can see at line 15 that this subscriber is added only for D&P ContentTypes, and ReleaseAction doesn't has D&P, so the subscriber is not registered for it

Comment on lines +99 to +100
const query: GetReleases.Request['query'] = await permissionsManager.sanitizeQuery(ctx.query);
const { results, pagination } = await releaseService.findPage(query);
Copy link
Contributor

Choose a reason for hiding this comment

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

shoulndt this endpoint also need a yup validation?

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 think is necessary because this query doesn't handle any custom logic and the ctx.query is already sanitized with the permissionsManager, I tried some basis cases and it's working

Copy link
Contributor

@Marc-Roig Marc-Roig left a comment

Choose a reason for hiding this comment

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

overall approach lgtm ! :) only added minor comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: chore This PR contains chore tasks (cleanups, configs, tooling...) source: core:content-releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants