Skip to content
Snippets Groups Projects
Verified Commit 664eb630 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3356684 by sumit_saini, acbramley, smustgrave: Generic Revision UI's...

Issue #3356684 by sumit_saini, acbramley, smustgrave: Generic Revision UI's Revision overview page generates wrong operations/view links for a translation

(cherry picked from commit b0ac814d)
parent d1979705
No related branches found
No related tags found
14 merge requests!11628Update file MediaLibraryWidget.php,!7564Revert "Issue #3364773 by roshnichordiya, Chris Matthews, thakurnishant_06,...,!5752Issue #3275828 by joachim, quietone, bradjones1, Berdir: document the reason...,!5627Issue #3261805: Field not saved when change of 0 on string start,!5427Issue #3338518: send credentials in ajax if configured in CORS settings.,!5395Issue #3387916 by fjgarlin, Spokje: Each GitLab job exposes user email,!5217Issue #3386607 by alexpott: Improve spell checking in commit-code-check.sh,!5064Issue #3379522 by finnsky, Gauravvvv, kostyashupenko, smustgrave, Chi: Revert...,!5040SDC ComponentElement: Transform slots scalar values to #plain_text instead of throwing an exception,!4958Issue #3392147: Whitelist IP for a Ban module.,!4894Issue #3280279: Add API to allow sites to opt in to upload SVG images in CKEditor 5,!3106Issue #3017548: "Filtered HTML" text format does not support manual teaser break (<!--break-->),!925Issue #2339235: Remove taxonomy hard dependency on node module,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links
Pipeline #24515 failed
Pipeline: drupal

#24521

    Pipeline: drupal

    #24520

      Pipeline: drupal

      #24519

        ......@@ -225,7 +225,7 @@ protected function loadRevisions(RevisionableInterface $entity) {
        // Only show revisions that are affected by the language that is being
        // displayed.
        if (!$translatable || ($revision->hasTranslation($currentLangcode) && $revision->getTranslation($currentLangcode)->isRevisionTranslationAffected())) {
        yield $revision;
        yield ($translatable ? $revision->getTranslation($currentLangcode) : $revision);
        }
        }
        }
        ......
        ......@@ -8,6 +8,18 @@
        * @ContentEntityType(
        * id = "entity_test_mul_revlog",
        * label = @Translation("Test entity - data table, revisions log"),
        * handlers = {
        * "access" = \Drupal\entity_test_revlog\EntityTestRevlogAccessControlHandler::class,
        * "form" = {
        * "default" = \Drupal\Core\Entity\ContentEntityForm::class,
        * "revision-delete" = \Drupal\Core\Entity\Form\RevisionDeleteForm::class,
        * "revision-revert" = \Drupal\Core\Entity\Form\RevisionRevertForm::class,
        * },
        * "route_provider" = {
        * "html" = \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::class,
        * "revision" = \Drupal\Core\Entity\Routing\RevisionHtmlRouteProvider::class,
        * },
        * },
        * base_table = "entity_test_mul_revlog",
        * data_table = "entity_test_mul_revlog_field_data",
        * revision_table = "entity_test_mul_revlog_revision",
        ......@@ -26,6 +38,16 @@
        * "revision_created" = "revision_created",
        * "revision_log_message" = "revision_log_message"
        * },
        * links = {
        * "add-form" = "/entity_test_mul_revlog/add",
        * "canonical" = "/entity_test_mul_revlog/manage/{entity_test_mul_revlog}",
        * "delete-form" = "/entity_test/delete/entity_test_mul_revlog/{entity_test_mul_revlog}",
        * "edit-form" = "/entity_test_mul_revlog/manage/{entity_test_mul_revlog}/edit",
        * "revision" = "/entity_test_mul_revlog/{entity_test_mul_revlog}/revision/{entity_test_mul_revlog_revision}/view",
        * "revision-delete-form" = "/entity_test_mul_revlog/{entity_test_mul_revlog}/revision/{entity_test_mul_revlog_revision}/delete",
        * "revision-revert-form" = "/entity_test_mul_revlog/{entity_test_mul_revlog}/revision/{entity_test_mul_revlog_revision}/revert",
        * "version-history" = "/entity_test_mul_revlog/{entity_test_mul_revlog}/revisions",
        * }
        * )
        */
        class EntityTestMulWithRevisionLog extends EntityTestWithRevisionLog {
        ......
        <?php
        declare(strict_types = 1);
        namespace Drupal\FunctionalTests\Entity;
        use Drupal\entity_test_revlog\Entity\EntityTestMulWithRevisionLog;
        use Drupal\language\Entity\ConfigurableLanguage;
        use Drupal\Tests\BrowserTestBase;
        /**
        * Tests version history page with translations.
        *
        * @group Entity
        * @coversDefaultClass \Drupal\Core\Entity\Controller\VersionHistoryController
        */
        final class RevisionVersionHistoryTranslatableTest extends BrowserTestBase {
        /**
        * {@inheritdoc}
        */
        protected static $modules = [
        'entity_test_revlog',
        'content_translation',
        'language',
        'user',
        ];
        /**
        * {@inheritdoc}
        */
        protected $defaultTheme = 'stark';
        /**
        * {@inheritdoc}
        */
        protected function setUp(): void {
        parent::setUp();
        ConfigurableLanguage::createFromLangcode('es')->save();
        // Rebuild the container so that the new languages are picked up by services
        // that hold a list of languages.
        $this->rebuildContainer();
        }
        /**
        * Tests the version history page for translations.
        */
        public function testVersionHistoryTranslations(): void {
        $label = 'view all revisions,revert,delete revision';
        $entity = EntityTestMulWithRevisionLog::create([
        'name' => $label,
        'type' => 'entity_test_mul_revlog',
        ]);
        $entity->addTranslation('es', ['label' => 'version history test translations es']);
        $entity->save();
        $firstRevisionId = $entity->getRevisionId();
        $entity->setNewRevision();
        $entity->setName($label . ',2')
        ->save();
        $this->drupalGet($entity->toUrl('version-history'));
        $this->assertSession()->statusCodeEquals(200);
        $this->assertSession()->elementsCount('css', 'table tbody tr', 2);
        /** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
        $storage = $this->container->get('entity_type.manager')->getStorage($entity->getEntityTypeId());
        $firstRevision = $storage->loadRevision($firstRevisionId);
        $this->assertSession()->linkByHrefExists($firstRevision->toUrl('revision-revert-form')->toString());
        $this->assertSession()->linkByHrefExists($firstRevision->toUrl('revision-delete-form')->toString());
        $this->assertSession()->linkByHrefNotExists($firstRevision->getTranslation('es')->toUrl('revision-revert-form')->toString());
        $this->assertSession()->linkByHrefNotExists($firstRevision->getTranslation('es')->toUrl('revision-delete-form')->toString());
        $this->drupalGet($entity->getTranslation('es')->toUrl('version-history'));
        // We can't use linkByHrefNotExists here because it does a "contains" match
        // and the translated URLs contain the non translated ones.
        // i.e /es/entity_test_mul_revlog/1/revision/1/revert contains
        // /entity_test_mul_revlog/1/revision/1/revert.
        $xpath = $this->assertSession()->buildXPathQuery('//a[@href=:href]', [':href' => $firstRevision->toUrl('revision-revert-form')->toString()]);
        $this->assertEmpty($this->getSession()->getPage()->findAll('xpath', $xpath));
        $xpath = $this->assertSession()->buildXPathQuery('//a[@href=:href]', [':href' => $firstRevision->toUrl('revision-delete-form')->toString()]);
        $this->assertEmpty($this->getSession()->getPage()->findAll('xpath', $xpath));
        $this->assertSession()->linkByHrefExists($firstRevision->getTranslation('es')->toUrl('revision-revert-form')->toString());
        $this->assertSession()->linkByHrefExists($firstRevision->getTranslation('es')->toUrl('revision-delete-form')->toString());
        }
        }
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment