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

fix(i18n): allow to store the new entry in the draft after a pre save #7227

Merged
merged 9 commits into from
Aug 2, 2024

Conversation

jmfiaschi
Copy link
Contributor

@jmfiaschi jmfiaschi commented Jun 5, 2024

Summary

fixex #4729 : Today it's not possible for example to translate empty fields with external APIs with the preSave because the preSave expect to return only a datathat not contain i18n values.

With this kind of code, we should be able to update the i18n values :

CMS.registerEventListener({
  name: 'preSave',
  handler: async ({ entry }) => {
      return entry.setIn(["i18n", "it", "data", "title"], "my translated title for IT");
  }
});

The change has no regression. PreSave can return data/entry modifications.

Test plan

Done

Checklist

Please add a x inside each checkbox:

A picture of a cute animal (not mandatory but encouraged)

@jmfiaschi jmfiaschi requested a review from a team as a code owner June 5, 2024 08:57
@jmfiaschi
Copy link
Contributor Author

if someone can review

Copy link
Member

@martinjagodic martinjagodic left a comment

Choose a reason for hiding this comment

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

@jmfiaschi please fix the linter error

@martinjagodic martinjagodic self-requested a review August 2, 2024 10:27
@martinjagodic martinjagodic enabled auto-merge (squash) August 2, 2024 10:27
@martinjagodic martinjagodic merged commit dc8b684 into decaporg:main Aug 2, 2024
9 checks passed
martinjagodic added a commit that referenced this pull request Aug 5, 2024
…#7227)

* fix(i18n): allow to store the new entry in the draft after a pre save

* feat(persistEntry): test preSave that return data or entry map

* fix(linter): expected property shorthand  object-shorthand

* fix: format backend spec, update caniuse-lite

---------

Co-authored-by: Martin Jagodic <jagodicmartin1@gmail.com>
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.

2 participants