Loading scheduler.links.task.yml +0 −16 Original line number Diff line number Diff line Loading @@ -9,19 +9,3 @@ scheduler.cron_tab: title: Lightweight cron weight: 10 base_route: scheduler.admin_form content_moderation.content: # Use content_moderation.content which is the same key as is used in the core # Content Moderation module. If that modules is enabled this avoids two # 'Overview' links. If https://www.drupal.org/project/drupal/issues/3199682 # gets committed then this route could be removed from here. title: 'Overview' route_name: system.admin_content parent_id: system.admin_content scheduler.scheduled_content: title: 'Scheduled content' route_name: view.scheduler_scheduled_content.overview parent_id: system.admin_content # Overview seems to have weight 0 and moderated content is weight 1. weight: 5 scheduler.module +36 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ use Drupal\Core\Url; use Drupal\node\Entity\NodeType; use Drupal\scheduler\SchedulerEvent; use Drupal\scheduler\SchedulerEvents; use Drupal\views\Entity\View; /** * Implements hook_help(). Loading Loading @@ -729,3 +730,38 @@ function _scheduler_get_scheduler_enabled_node_types($action) { return $bundle->getThirdPartySetting('scheduler', $action . '_enable', $config->get('default_' . $action . '_enable')); }); } /** * Implements hook_local_tasks_alter(). */ function scheduler_local_tasks_alter(&$local_tasks) { $view = View::load('scheduler_scheduled_content'); if ($view && $view->status() && $view->getDisplay('overview')) { // Views do not currently support defining secondary local tasks, so define // it dynamically if the view exists, is enabled and the display exists. // Change this if https://www.drupal.org/node/2172307 gets fixed. $local_tasks['scheduler.scheduled_content'] = [ 'title' => t('Scheduled content'), 'route_name' => 'view.scheduler_scheduled_content.overview', 'parent_id' => 'system.admin_content', 'class' => 'Drupal\Core\Menu\LocalTaskDefault', 'options' => [], // Overview seems to have weight 0 and moderated content is weight 1. 'weight' => 5, ]; if (!\Drupal::moduleHandler()->moduleExists('content_moderation')) { // Define a fallback overview local task if content_moderation is not // enabled. If https://www.drupal.org/project/drupal/issues/3199682 // gets committed then this route could be removed from here. $local_tasks['scheduler.content_overview'] = [ 'title' => t('Overview'), 'route_name' => 'system.admin_content', 'parent_id' => 'system.admin_content', 'class' => 'Drupal\Core\Menu\LocalTaskDefault', 'options' => [], 'weight' => 0, ]; } } } tests/src/Functional/SchedulerScheduledContentListAccessTest.php +25 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,9 @@ class SchedulerScheduledContentListAccessTest extends SchedulerBrowserTestBase { 'view own unpublished content', ]; // Create three users, all of whom can access and create content. The editor // can also view the admin overview page, and the two scheduler users each // have one of the scheduler permissions but not the other. $this->editorUser = $this->drupalCreateUser(array_merge($base_permissions, ['access content overview'])); $this->schedulerUser = $this->drupalCreateUser(array_merge($base_permissions, ['schedule publishing of nodes'])); $this->schedulerManager = $this->drupalCreateUser(array_merge($base_permissions, ['view scheduled content'])); Loading Loading @@ -143,6 +146,28 @@ class SchedulerScheduledContentListAccessTest extends SchedulerBrowserTestBase { $assert->pageTextContains('Node created by Scheduler User for unpublishing'); $assert->pageTextContains('Node created by Scheduler Manager for publishing'); $assert->pageTextContains('Node created by Scheduler Manager for unpublishing'); // Disable the scheduled content view. $view = $this->container->get('entity_type.manager')->getStorage('view')->load('scheduler_scheduled_content'); $view->disable()->save(); // Attempt to view the scheduled content page. Interactively this gives a // '404 page not found' error, but in phpunit it is served with a 200 code. // However the page is empty so we can check that the content is not shown. $this->drupalGet('admin/content/scheduled'); $assert->pageTextNotContains('Node created by Scheduler User for unpublishing'); // Check that access to the content overview page is unaffected. $this->drupalLogin($this->editorUser); $this->drupalGet('admin/content'); $assert->statusCodeEquals(200); $assert->pageTextContains('Node created by Scheduler User for unpublishing'); // Delete the view and check again that the overview remains accessible. $view->delete(); $this->drupalGet('admin/content'); $assert->statusCodeEquals(200); $assert->pageTextContains('Node created by Scheduler User for unpublishing'); } } Loading
scheduler.links.task.yml +0 −16 Original line number Diff line number Diff line Loading @@ -9,19 +9,3 @@ scheduler.cron_tab: title: Lightweight cron weight: 10 base_route: scheduler.admin_form content_moderation.content: # Use content_moderation.content which is the same key as is used in the core # Content Moderation module. If that modules is enabled this avoids two # 'Overview' links. If https://www.drupal.org/project/drupal/issues/3199682 # gets committed then this route could be removed from here. title: 'Overview' route_name: system.admin_content parent_id: system.admin_content scheduler.scheduled_content: title: 'Scheduled content' route_name: view.scheduler_scheduled_content.overview parent_id: system.admin_content # Overview seems to have weight 0 and moderated content is weight 1. weight: 5
scheduler.module +36 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ use Drupal\Core\Url; use Drupal\node\Entity\NodeType; use Drupal\scheduler\SchedulerEvent; use Drupal\scheduler\SchedulerEvents; use Drupal\views\Entity\View; /** * Implements hook_help(). Loading Loading @@ -729,3 +730,38 @@ function _scheduler_get_scheduler_enabled_node_types($action) { return $bundle->getThirdPartySetting('scheduler', $action . '_enable', $config->get('default_' . $action . '_enable')); }); } /** * Implements hook_local_tasks_alter(). */ function scheduler_local_tasks_alter(&$local_tasks) { $view = View::load('scheduler_scheduled_content'); if ($view && $view->status() && $view->getDisplay('overview')) { // Views do not currently support defining secondary local tasks, so define // it dynamically if the view exists, is enabled and the display exists. // Change this if https://www.drupal.org/node/2172307 gets fixed. $local_tasks['scheduler.scheduled_content'] = [ 'title' => t('Scheduled content'), 'route_name' => 'view.scheduler_scheduled_content.overview', 'parent_id' => 'system.admin_content', 'class' => 'Drupal\Core\Menu\LocalTaskDefault', 'options' => [], // Overview seems to have weight 0 and moderated content is weight 1. 'weight' => 5, ]; if (!\Drupal::moduleHandler()->moduleExists('content_moderation')) { // Define a fallback overview local task if content_moderation is not // enabled. If https://www.drupal.org/project/drupal/issues/3199682 // gets committed then this route could be removed from here. $local_tasks['scheduler.content_overview'] = [ 'title' => t('Overview'), 'route_name' => 'system.admin_content', 'parent_id' => 'system.admin_content', 'class' => 'Drupal\Core\Menu\LocalTaskDefault', 'options' => [], 'weight' => 0, ]; } } }
tests/src/Functional/SchedulerScheduledContentListAccessTest.php +25 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,9 @@ class SchedulerScheduledContentListAccessTest extends SchedulerBrowserTestBase { 'view own unpublished content', ]; // Create three users, all of whom can access and create content. The editor // can also view the admin overview page, and the two scheduler users each // have one of the scheduler permissions but not the other. $this->editorUser = $this->drupalCreateUser(array_merge($base_permissions, ['access content overview'])); $this->schedulerUser = $this->drupalCreateUser(array_merge($base_permissions, ['schedule publishing of nodes'])); $this->schedulerManager = $this->drupalCreateUser(array_merge($base_permissions, ['view scheduled content'])); Loading Loading @@ -143,6 +146,28 @@ class SchedulerScheduledContentListAccessTest extends SchedulerBrowserTestBase { $assert->pageTextContains('Node created by Scheduler User for unpublishing'); $assert->pageTextContains('Node created by Scheduler Manager for publishing'); $assert->pageTextContains('Node created by Scheduler Manager for unpublishing'); // Disable the scheduled content view. $view = $this->container->get('entity_type.manager')->getStorage('view')->load('scheduler_scheduled_content'); $view->disable()->save(); // Attempt to view the scheduled content page. Interactively this gives a // '404 page not found' error, but in phpunit it is served with a 200 code. // However the page is empty so we can check that the content is not shown. $this->drupalGet('admin/content/scheduled'); $assert->pageTextNotContains('Node created by Scheduler User for unpublishing'); // Check that access to the content overview page is unaffected. $this->drupalLogin($this->editorUser); $this->drupalGet('admin/content'); $assert->statusCodeEquals(200); $assert->pageTextContains('Node created by Scheduler User for unpublishing'); // Delete the view and check again that the overview remains accessible. $view->delete(); $this->drupalGet('admin/content'); $assert->statusCodeEquals(200); $assert->pageTextContains('Node created by Scheduler User for unpublishing'); } }