Verified Commit ba0fa0ea authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3501465 by plopesc, gxleano, berdir: Navigation Top Bar Page Actions...

Issue #3501465 by plopesc, gxleano, berdir: Navigation Top Bar Page Actions dropdown should not include link to the current page and order should respect local tasks weight
parent 95c0c2e8
Loading
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -264,7 +264,14 @@ public function getLocalTasks(): array {
      return $this->localTasks;
    }
    $entity_local_tasks = $this->localTaskManager->getLocalTasks($this->routeMatch->getRouteName());
    foreach ($entity_local_tasks['tabs'] as $route_name => $local_task) {
    uasort($entity_local_tasks['tabs'], [SortArray::class, 'sortByWeightProperty']);
    foreach ($entity_local_tasks['tabs'] as $local_task_name => $local_task) {
      // Exclude current route local task, since it is not going to be included
      // in the page actions link list.
      $url = $local_task['#link']['url'] ?? NULL;
      if ($url?->getRouteName() === $entity_local_tasks['route_name']) {
        continue;
      }
      // The $local_task array that we get here is tailor-made for use
      // with the menu-local-tasks.html.twig, eg. the menu_local_task
      // theme hook. It has all the information we need, but we're not
@@ -277,7 +284,7 @@ public function getLocalTasks(): array {
      $link['localized_options'] += [
        'set_active_class' => TRUE,
      ];
      $this->localTasks['page_actions'][$route_name] = [
      $this->localTasks['page_actions'][$local_task_name] = [
        '#theme' => 'top_bar_page_action',
        '#link' => [
          '#type' => 'link',
+3 −0
Original line number Diff line number Diff line
@@ -111,6 +111,9 @@ public function testTopBarVisibility(): void {
      $this->clickLink($toolbar_link->getText());
      $this->assertSession()->elementExists('xpath', "(//div[contains(@class, 'top-bar__content')]/div[contains(@class, 'top-bar__actions')]/button)[1]");
      $this->assertSession()->elementAttributeContains('xpath', "(//div[contains(@class, 'top-bar__content')]/div[contains(@class, 'top-bar__actions')]/button)[1]", 'class', 'toolbar-button--icon--dots');
      // Ensure that link to current page is not included in the dropdown.
      $url = $this->getSession()->getCurrentUrl();
      $this->assertSession()->linkByHrefNotExistsExact(parse_url($url, PHP_URL_PATH));
    }

    // Regular tabs are visible for user that cannot access to navigation.