Problem/Motivation

Content moderation allows for specific states to be set per entity / revision / language. It would be nice to schedule a specific translation of an entity to be published via the scheduled transitions.

Proposed resolution

Add a language field and only act on the specific translation of the revision.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

seanB created an issue. See original summary.

seanb’s picture

Status: Active » Needs review
StatusFileSize
new13.72 KB

The patch attached implements a new base field to store the langcode of the selected revision. The scheduled transition tab is changed to only add/show scheduled transitions for the current language (consistent with the revision tab).

For example:
When you are on a French translation, this means you only see the scheduled transitions for the French language when navigating to the tab.
You only see the French revisions when trying to add a new scheduled transition.

Please review.

jibran’s picture

Category: Feature request » Task
Issue tags: +Needs tests

Really nice work. Thanks, for creating the issue and the patch. Let's add some tests.

  1. +++ b/src/Form/Entity/ScheduledTransitionAddForm.php
    @@ -322,14 +337,23 @@ class ScheduledTransitionAddForm extends ContentEntityForm {
    +      $revision = $entityStorage->loadRevision($revisionId);
    +      if ($revision instanceof TranslatableInterface) {
    +        $revision = $revision->getTranslation($this->languageManager->getCurrentLanguage()->getId());
    +      }
    +      return $revision;
    

    Let's add a comment here?

  2. +++ b/src/Form/Entity/ScheduledTransitionAddForm.php
    @@ -322,14 +337,23 @@ class ScheduledTransitionAddForm extends ContentEntityForm {
    +    $entityRevisions = array_filter($entityRevisions, function (EntityInterface $revision) {
    +      return $revision instanceof TranslatableRevisionableInterface ? $revision->isRevisionTranslationAffected() : TRUE;
    +    });
    

    Can we please add a comment here, as well?

seanb’s picture

StatusFileSize
new14.02 KB
new1.28 KB

Added some docs!

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, for addressing the feedback. We'll create a meta for tests and address this there.

dpi’s picture

Status: Reviewed & tested by the community » Needs work

Patch looks reasonable.

Took a while for me to get re-acquainted with how translation works (procrastination). This is definitely going to need tests as I can easily see myself or others breaking changes introduced by this issue.

Ive got a feeling showing the current language for the list page and form will bite us in the future. Going to overlook it in the meantime.

Some feedback

  • add return types for new lang method in transition entity.
  • all/similar the same tests for NON-translatable entity. Make sure features work the same if entity is not translatable.
  • Langcode field should be required. Double check usage of new lang method should account for NULL values.
  • Views field plugin needs update (as used by default view).

Suggested test scenarios

  • test for runner, must transition correct id/rev/t9n
  • test for count in tab, count must not show id/rev/t9n relevant to currentUser
  • test for only showing language in list, must transition correct id/rev/t9n
  • test for only showing language in list in form, must transition correct id/rev/t9n
  • test for lang method on transition entity
  • others as needed
dpi’s picture

This issue is the remaining blocker for 1.0

dpi’s picture

Assigned: Unassigned » dpi
dpi’s picture

Assigned: dpi » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new29.12 KB
new41.06 KB
  • A slew of tests.
  • Updated coding to project standard.
  • Changed method to account for possible NULL value.

Status: Needs review » Needs work

The last submitted patch, 9: 3022681-translation-9.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jibran’s picture

Nice work on tests 👏👏👏👏👏👏

+++ b/tests/src/Kernel/ScheduledTransitionTest.php
@@ -437,6 +444,63 @@ class ScheduledTransitionTest extends KernelTestBase {
+    $entity->save();

I didn't know that saving the entity will save the translations as well.

dpi’s picture

Status: Needs work » Needs review
StatusFileSize
new4.54 KB
new41.24 KB

Fixes bad test, problem with site in subdirectory on drupalci

dpi’s picture

I didn't know that saving the entity will save the translations as well.

PHP magic; objects always references. Good stuff.

Status: Needs review » Needs work

The last submitted patch, 12: 3022681-translation-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

dpi’s picture

Status: Needs work » Needs review
StatusFileSize
new828 bytes
new41.23 KB

missed one 🤞

  • dpi committed 7f94991 on 8.x-1.x
    Issue #3022681 by dpi, seanB, jibran: Add option to schedule a...
dpi’s picture

Status: Needs review » Fixed
StatusFileSize
new3.94 KB

Committed with minor amendments.

  • dpi committed ff79dd7 on 8.x-1.x authored by seanB
    Issue #3022681 by dpi, seanB, jibran: Add option to schedule a...
dpi’s picture

Added an empty authorship commit.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.