Skip to content

Commit

Permalink
Merge branch 'develop' into YALB-1437--two-column
Browse files Browse the repository at this point in the history
  • Loading branch information
codechefmarc committed Jul 10, 2023
2 parents d10aecd + a49028c commit 60c3f66
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ uuid: e03d9a42-6814-4262-aec2-1914178b1d69
langcode: en
status: true
dependencies:
module:
- system
theme:
- ys_admin_theme
_core:
Expand All @@ -19,4 +21,8 @@ settings:
provider: core
primary: true
secondary: false
visibility: { }
visibility:
request_path:
id: request_path
negate: true
pages: '/node/*'
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ public function addItems(): array {
if ($this->showEditButton()) {
$this->toolbarItems['toolbar_edit_link'] = $this->buildButton(
'entity.node.edit_form',
'Setup'
'Manage Settings'
);
}

// Add a dedicated 'layout' link to the toolbar. Access controls are used to
// ensure this link only appears on entities with layout overrides enabled.
$this->toolbarItems['toolbar_layout_link'] = $this->buildButton(
'layout_builder.overrides.node.view',
'Layout Builder'
'Edit Layout And Content'
);

// Add a publish button to the toolbar when viewing an unpublished node.
Expand All @@ -137,6 +137,14 @@ public function addItems(): array {
);
}

// Add an unpublish button to the toolbar when viewing a published node.
if ($this->showUnpublishButton()) {
$this->toolbarItems['toolbar_unpublish_link'] = $this->buildButton(
'entity.node.publish',
'Unpublish'
);
}

$this->toolbarItems['toolbar_theme_settings_link'] = $this->buildOffCanvasButton(
'ys_themes.theme_settings',
'Theme Settings'
Expand Down Expand Up @@ -187,16 +195,27 @@ protected function showEditButton(): bool {
}

/**
* Chech if the dedicated 'publish' button should appear on the current route.
* Chech if a dedicated 'publish' button should appear on the current route.
*
* @return bool
* True if the publish button should appear on the toolbar.
* True if the button should appear on the toolbar.
*/
protected function showPublishButton(): bool {
// Show the edit button on all node routes except the edit form.
// Show the button if viewing an unpublished node.
return !$this->currentNode->isPublished() && $this->isViewRoute();
}

/**
* Chech if a dedicated 'unpublish' button should appear on the current route.
*
* @return bool
* True if the button should appear on the toolbar.
*/
protected function showUnpublishButton(): bool {
// Show the button if viewing a published node.
return $this->currentNode->isPublished() && $this->isViewRoute();
}

/**
* Get node parameters for creating a route.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function ys_toolbar_toolbar_alter(&$items) {
// all nodes. Change to "Manage this Page" to make it easier to understand.
if (\Drupal::service('ys_toolbar.items')->isCurrentRouteNode()) {
if (!empty($items['admin_toolbar_local_tasks']['tab']['#title'])) {
$items['admin_toolbar_local_tasks']['tab']['#title'] = 'Toolset';
$items['admin_toolbar_local_tasks']['tab']['#title'] = 'More Actions';
}
}

Expand Down

0 comments on commit 60c3f66

Please sign in to comment.