Loading admin_toolbar_tools/admin_toolbar_tools.module +44 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Cache\CacheableMetadata; /** * Implements hook_toolbar(). Loading @@ -24,6 +25,49 @@ function admin_toolbar_tools_toolbar() { ], '#attached' => ['library' => ['admin_toolbar_tools/toolbar.icon']], ]; // Toolbar item for primary local tasks. $config = \Drupal::config('admin_toolbar_tools.settings')->get('show_local_tasks'); $items['admin_toolbar_local_tasks'] = []; CacheableMetadata::createFromObject($config)->applyTo($items['admin_toolbar_local_tasks']); if ($config) { $items['admin_toolbar_local_tasks'] += [ '#type' => 'toolbar_item', '#wrapper_attributes' => [ 'class' => ['local-tasks-toolbar-tab'], ], // Put it after contextual toolbar item so when float right is applied // local tasks item will be first. '#weight' => 10, 'tab' => [ // We can't use #lazy_builder here because // ToolbarItem::preRenderToolbarItem will insert #attributes before // lazy_builder callback and this will produce Exception. // This means that for now we always render Local Tasks item even when // the tray is empty. '#type' => 'link', '#title' => t('Local Tasks'), '#url' => Url::fromRoute('<none>'), '#attributes' => [ 'class' => [ 'toolbar-icon', 'toolbar-icon-local-tasks', ], ], ], 'tray' => [ 'local_links' => [ '#lazy_builder' => [ 'admin_toolbar_tools.helper:localTasksTrayLazyBuilder', [], ], ], ], '#attached' => ['library' => ['admin_toolbar_tools/toolbar.icon']], ]; } return $items; } Loading admin_toolbar_tools/admin_toolbar_tools.services.yml +2 −0 Original line number Diff line number Diff line Loading @@ -3,3 +3,5 @@ services: class: Drupal\admin_toolbar_tools\AdminToolbarToolsHelper arguments: - '@entity_type.manager' - '@plugin.manager.menu.local_task' - '@current_route_match' No newline at end of file admin_toolbar_tools/config/install/admin_toolbar_tools.settings.yml +1 −0 Original line number Diff line number Diff line max_bundle_number: 20 hoverintent_functionality: true show_local_tasks: false admin_toolbar_tools/config/schema/admin_toolbar_tools.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -8,3 +8,6 @@ admin_toolbar_tools.settings: hoverintent_functionality: type: boolean label: 'Enable or disable hoverintent functionality' show_local_tasks: type: boolean label: 'Show local tasks in toolbar' admin_toolbar_tools/css/tools.css +12 −0 Original line number Diff line number Diff line Loading @@ -33,3 +33,15 @@ .toolbar-icon-8 .toolbar-icon-admin-toolbar-tools-help.active:before { background-image: url(../misc/icons/ffffff/drupal-8-logo.svg); } .toolbar-oriented .toolbar-bar .local-tasks-toolbar-tab { float: right; } .toolbar-horizontal .local-tasks-toolbar-tab .toolbar-menu { float: right; } .toolbar-bar .toolbar-icon-local-tasks:before { background-image: url(../misc/icons/bebebe/tasks.svg); } No newline at end of file Loading
admin_toolbar_tools/admin_toolbar_tools.module +44 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Cache\CacheableMetadata; /** * Implements hook_toolbar(). Loading @@ -24,6 +25,49 @@ function admin_toolbar_tools_toolbar() { ], '#attached' => ['library' => ['admin_toolbar_tools/toolbar.icon']], ]; // Toolbar item for primary local tasks. $config = \Drupal::config('admin_toolbar_tools.settings')->get('show_local_tasks'); $items['admin_toolbar_local_tasks'] = []; CacheableMetadata::createFromObject($config)->applyTo($items['admin_toolbar_local_tasks']); if ($config) { $items['admin_toolbar_local_tasks'] += [ '#type' => 'toolbar_item', '#wrapper_attributes' => [ 'class' => ['local-tasks-toolbar-tab'], ], // Put it after contextual toolbar item so when float right is applied // local tasks item will be first. '#weight' => 10, 'tab' => [ // We can't use #lazy_builder here because // ToolbarItem::preRenderToolbarItem will insert #attributes before // lazy_builder callback and this will produce Exception. // This means that for now we always render Local Tasks item even when // the tray is empty. '#type' => 'link', '#title' => t('Local Tasks'), '#url' => Url::fromRoute('<none>'), '#attributes' => [ 'class' => [ 'toolbar-icon', 'toolbar-icon-local-tasks', ], ], ], 'tray' => [ 'local_links' => [ '#lazy_builder' => [ 'admin_toolbar_tools.helper:localTasksTrayLazyBuilder', [], ], ], ], '#attached' => ['library' => ['admin_toolbar_tools/toolbar.icon']], ]; } return $items; } Loading
admin_toolbar_tools/admin_toolbar_tools.services.yml +2 −0 Original line number Diff line number Diff line Loading @@ -3,3 +3,5 @@ services: class: Drupal\admin_toolbar_tools\AdminToolbarToolsHelper arguments: - '@entity_type.manager' - '@plugin.manager.menu.local_task' - '@current_route_match' No newline at end of file
admin_toolbar_tools/config/install/admin_toolbar_tools.settings.yml +1 −0 Original line number Diff line number Diff line max_bundle_number: 20 hoverintent_functionality: true show_local_tasks: false
admin_toolbar_tools/config/schema/admin_toolbar_tools.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -8,3 +8,6 @@ admin_toolbar_tools.settings: hoverintent_functionality: type: boolean label: 'Enable or disable hoverintent functionality' show_local_tasks: type: boolean label: 'Show local tasks in toolbar'
admin_toolbar_tools/css/tools.css +12 −0 Original line number Diff line number Diff line Loading @@ -33,3 +33,15 @@ .toolbar-icon-8 .toolbar-icon-admin-toolbar-tools-help.active:before { background-image: url(../misc/icons/ffffff/drupal-8-logo.svg); } .toolbar-oriented .toolbar-bar .local-tasks-toolbar-tab { float: right; } .toolbar-horizontal .local-tasks-toolbar-tab .toolbar-menu { float: right; } .toolbar-bar .toolbar-icon-local-tasks:before { background-image: url(../misc/icons/bebebe/tasks.svg); } No newline at end of file