Skip to content

Conversation

@ValJed
Copy link
Contributor

@ValJed ValJed commented Nov 3, 2025

Summary

See ticket, flow support:

  • Save draft or not before to switch (confirmation modal)
  • Ask user if he want to localize current doc or start blank
  • If localize, opens the localize modal

Cypress tests: https://github.com/apostrophecms/testbed/pull/399

What kind of change does this PR introduce?

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Build-related changes
  • Other

Make sure the PR fulfills these requirements:

  • It includes a) the existing issue ID being resolved, b) a convincing reason for adding this feature, or c) a clear description of the bug it resolves
  • The changelog is updated
  • Related documentation has been updated
  • Related tests have been updated

@ValJed ValJed self-assigned this Nov 3, 2025
@ValJed ValJed marked this pull request as draft November 3, 2025 14:39
@ValJed ValJed requested a review from haroun November 4, 2025 14:43
@ValJed ValJed marked this pull request as ready for review November 4, 2025 14:44
"willMoveImageToArchive": "Tým sa obrázok presunie do archívu.",
"yes": "Áno",
"yesLocalizeAndSwitchLocales": "Áno, preložte túto stránku a prepnite jazykovú mutáciu",
"yesLocalizeAndSwitchLocalesDoc": "Sim, localizar este {{ docType }} e trocar idiomas",
Copy link
Contributor

Choose a reason for hiding this comment

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

This is portugese

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

},
computed: {
...mapState(useModalStore, [ 'activeModal', 'updateModalData' ]),
...mapState(useModalStore, [ 'activeModal' ]),
Copy link
Contributor

Choose a reason for hiding this comment

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

we still use updateModalData, why did we removed it?

Copy link
Contributor Author

@ValJed ValJed Nov 5, 2025

Choose a reason for hiding this comment

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

Yes it was already here in the methods, so when you added it in the computed it created a duplicates warning. (methods should be added to methods not computed which is for reactive data: refs / computed).

CHANGELOG.md Outdated

### Adds

* When switching locale from the doc editor, ask the user if he wants to localize the current one in the target locale or want to start a blank document.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* When switching locale from the doc editor, ask the user if he wants to localize the current one in the target locale or want to start a blank document.
* When switching locale from the doc editor, ask if the user wants to localize the current document in the target locale or want to start a blank document.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

@ValJed ValJed force-pushed the pro-8541-switch-locale-empty-doc branch from b28a981 to c03f0e3 Compare November 5, 2025 11:20
@ValJed ValJed requested a review from haroun November 5, 2025 13:59
},
isBatchMode() {
return this.batchOptions.enabled;
},
Copy link
Contributor

Choose a reason for hiding this comment

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

this.currentLocale is still used in this file

}
},
close() {
close(hasBeenSubmitted = false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A bit confusing, don't think it has anything to do with submit draft feature, so I don't know what this is

}
});
if (result.redirectTo) {
if (this.redirect && result.redirectTo) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if you don't want to redirect, why do we return a redirectTo property? We then add a new vue prop to skip the redirect if it's there. It works ok, I'm confused.

const forbiddenTooltip = $t('apostrophe:localeSwitcherPermissionToCreate', {
docType: props.moduleOptions.label.toLowerCase()
});
const docType = $t(props.moduleOptions.label)?.toLowerCase();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is a reliable way to get the doc type. It should be props.moduleOptions.name.

if (isLocalized) {
this.switchModalLocale(locale.name);
await this.$nextTick();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why here only?

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.

3 participants