Verified Commit cfc0f427 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3444745 by fjgarlin, plopesc, m4olivei: Navigation Top Bar hides entity...

Issue #3444745 by fjgarlin, plopesc, m4olivei: Navigation Top Bar hides entity local tasks even if the user has no access to the bar

(cherry picked from commit a49ba338)
parent 8c1d5599
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -158,8 +158,10 @@ function navigation_menu_links_discovered_alter(&$links) {
function navigation_block_build_local_tasks_block_alter(array &$build, BlockPluginInterface $block) {
  $navigation_renderer = \Drupal::service('navigation.renderer');
  assert($navigation_renderer instanceof NavigationRenderer);
  if (\Drupal::currentUser()->hasPermission('access navigation')) {
    $navigation_renderer->removeLocalTasks($build, $block);
  }
}

/**
 * Implements hook_plugin_filter_TYPE__CONSUMER_alter().
+9 −0
Original line number Diff line number Diff line
@@ -99,6 +99,15 @@ public function testTopBarVisibility(): void {
      $this->assertSession()->elementTextEquals('xpath', "//div[contains(@class, 'top-bar__content')]/button/span", 'More actions');
      $this->assertSession()->elementNotExists('xpath', '//div[@id="block-tabs"]');
    }

    // Regular tabs are visible for user that cannot access to navigation.
    $this->drupalLogin($this->drupalCreateUser([
      'bypass node access',
    ]));

    $this->drupalGet($this->node->toUrl());
    $this->assertSession()->elementNotExists('xpath', "//div[contains(@class, 'top-bar__content')]/div[contains(@class, 'top-bar__actions')]/button/span");
    $this->assertSession()->elementExists('xpath', '//div[@id="block-tabs"]');
  }

}