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 45 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 2:21pm

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

Copy link
Member

@joshuaellis joshuaellis left a comment

Choose a reason for hiding this comment

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

There's some strange decisions in the FE i think we need to discuss.

@@ -35,7 +35,7 @@ class FetchError extends Error {
public name: string;
public message: string;
public response?: ErrorResponse;
public code?: number;
public code?: number | string;
Copy link
Member

Choose a reason for hiding this comment

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

when is code a string? 🤔

Comment on lines +12 to +13
'Release',
'ReleaseAction',
Copy link
Member

Choose a reason for hiding this comment

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

This is cross-domain pollution with 0 documentation? Why are you doing this here and what other ways did you consider doing 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.

The problem is that changes to documents could cause stale release data. For example, if you have an invalid entry that causes a release to have a "Blocked" status, and then you go to the Edit View and update the entry to fit the validation rules, this changes the release status to "Ready". This is the scenario I want to address here.

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 think I didn't explain the first question 😅 I'm doing that I think, for example I invalidate the releases tags here on the update document.

Adding the types here is to avoid a Typescript error that not allowed me to invalidate the releases tags because they are not known. Here is a discussion about this on the RTK's repo

Copy link
Member

Choose a reason for hiding this comment

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

you're invalidating it in the wrong place, because thats the endpoint definition in the domain of the content-manager, instead your enhanceEndpoints object on the CR service should look like this:

  .enhanceEndpoints({
    addTagTypes: ['Release', 'ReleaseAction', 'EntriesInRelease'],
    endpoints: {
      updateDocument: {
        invalidatesTags: [
          { type: 'Release', id: 'LIST' },
          { type: 'ReleaseAction', id: 'LIST' },
        ],
      },
      deleteDocument: {
        invalidatesTags: [
          { type: 'Release', id: 'LIST' },
          { type: 'ReleaseAction', id: 'LIST' },
        ],
      },
      deleteManyDocuments: {
        invalidatesTags: [
          { type: 'Release', id: 'LIST' },
          { type: 'ReleaseAction', id: 'LIST' },
        ],
      },
      discardDocument: {
        invalidatesTags: [
          { type: 'Release', id: 'LIST' },
          { type: 'ReleaseAction', id: 'LIST' },
        ],
      },
    },
  })

where you add the invalidate tags from this side, keeping the release logic locked away. This is the way i'd expect plugin authors to have their data invalidated when a document is published, for example.

"@strapi/design-system": "2.0.0-beta.6",
"@strapi/icons": "2.0.0-beta.6",
"@strapi/types": "workspace:*",
"@strapi/utils": "5.0.0-beta.9",
"axios": "1.6.8",
Copy link
Member

Choose a reason for hiding this comment

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

how come you need axios? we've moved the FE to use native fetch

{
collectionType: schema?.kind ?? '',
model: schema?.uid ?? '',
},
{
skip: !schema,
skip: true,
Copy link
Member

Choose a reason for hiding this comment

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

You should add this as a comment, it's not clear to people

import { CMReleasesContainer } from './components/CMReleasesContainer';
import { ReleaseActionModalForm } from './components/ReleaseActionModal';
import { Panel as ReleasesPanel } from './components/ReleasesPanel';
// import { addColumnToTableHook } from './components/ReleaseListCell';
Copy link
Member

Choose a reason for hiding this comment

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

should this be here? did you forget about 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.

This is for the "Releases" column in the list view, is not implemented yet and I would like to do it in an upcoming PR. I left the code commented here because I think it should not change too much at this file.

} from '@strapi/design-system';
import { Cursor } from '@strapi/icons';
import { EmptyDocuments } from '@strapi/icons/symbols';
import { isAxiosError } from 'axios';
Copy link
Member

Choose a reason for hiding this comment

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

I think the base query uses fetch not axios so your calls to this won't work as expected.

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