diff --git a/config/install/dashboards.dashboard.my_dashboard.yml b/config/install/dashboards.dashboard.my_dashboard.yml index cadcea2827b86a0e43744757725b75ed4ca83801..1a5cc5a03f79a78071981d70b2fbaaa5962a31bc 100644 --- a/config/install/dashboards.dashboard.my_dashboard.yml +++ b/config/install/dashboards.dashboard.my_dashboard.yml @@ -6,6 +6,7 @@ dependencies: third_party_settings: layout_builder_restrictions: allowed_block_categories: + - Editoria11y - 'Lists (Views)' - Menus - System @@ -19,18 +20,13 @@ third_party_settings: - uw_3_column - uw_inverted_l_right - uw_inverted_l_left - restricted_categories: { } - blacklisted_blocks: - 'Lists (Views)': - - 'views_block:bibcite_reference-bibcite_reference_block' - Menus: { } - System: { } - 'UW Custom Blocks': - - uw_cbl_blog_author - - uw_cbl_special_alert - - uw_cbl_content_moderation - 'UW Dashboard Items': { } - Webform: { } + restricted_categories: + - Editoria11y + - 'Lists (Views)' + - Menus + - System + - Webform + blacklisted_blocks: { } whitelisted_blocks: { } id: my_dashboard admin_label: 'My Dashboard' diff --git a/config/install/views.view.uw_view_pub_authors.yml b/config/install/views.view.uw_view_pub_authors.yml index ba7de861ed3eed53d229b2f34510a2067ec56a09..39b33239214c3cdcefc3cd2cf7b32c096c7a0e84 100644 --- a/config/install/views.view.uw_view_pub_authors.yml +++ b/config/install/views.view.uw_view_pub_authors.yml @@ -597,7 +597,7 @@ display: offset: 0 items_per_page: 50 total_pages: null - id: 0 + id: 1 tags: next: ›› previous: ‹‹ diff --git a/config/install/views.view.uw_view_pub_keywords.yml b/config/install/views.view.uw_view_pub_keywords.yml index 7db60a31d1a938d640b7afa9260cc48ba74110a1..3ee991ce98edcf049ccc43a00a5533102ee7aab1 100644 --- a/config/install/views.view.uw_view_pub_keywords.yml +++ b/config/install/views.view.uw_view_pub_keywords.yml @@ -143,7 +143,7 @@ display: offset: 0 items_per_page: 50 total_pages: null - id: 0 + id: 2 tags: next: ›› previous: ‹‹ diff --git a/config/install/views.view.uw_view_pub_reference.yml b/config/install/views.view.uw_view_pub_reference.yml index abff38e0955c9c64938ee35fc3186a03527c97c0..7be3ee33f89526ff183ddf6c1652270b31a6c7ed 100644 --- a/config/install/views.view.uw_view_pub_reference.yml +++ b/config/install/views.view.uw_view_pub_reference.yml @@ -460,7 +460,7 @@ display: offset: 0 items_per_page: 50 total_pages: null - id: 0 + id: 3 tags: next: ›› previous: ‹‹ diff --git a/css/uw_dashboard.css b/css/uw_dashboard.css index 38b8271ced14440a11335edb22a7b4b7455ea2e3..e1c0776c6e23960d89c3cb3cd7855ccceabe9e76 100644 --- a/css/uw_dashboard.css +++ b/css/uw_dashboard.css @@ -10,3 +10,8 @@ flex-grow: 1; flex-basis: 0; } + +.dashboard__site-info { + float: right; + margin-bottom: 0.2rem; +} diff --git a/src/Form/AllowedBlocksForm.php b/src/Form/AllowedBlocksForm.php deleted file mode 100644 index 9a93f97b47abcfd5b4963f05fcabce3670e7ad72..0000000000000000000000000000000000000000 --- a/src/Form/AllowedBlocksForm.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php - -namespace Drupal\uw_dashboard\Form; - -use Drupal\Core\Block\BlockManagerInterface; -use Drupal\Core\Form\ConfigFormBase; -use Drupal\Core\Form\FormStateInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Class for blocks allowed on the dashboard. - */ -class AllowedBlocksForm extends ConfigFormBase { - const SETTINGS = 'uw_dashboard.allowed_blocks'; - - /** - * The plugin manager block. - * - * @var \Drupal\Core\Block\BlockManagerInterface - */ - protected $blockManager; - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('plugin.manager.block') - ); - } - - /** - * UWDashboardBlockRestriction constructor. - * - * @param \Drupal\Core\Block\BlockManagerInterface $pluginManagerBlock - * The plugin manager block. - */ - public function __construct(BlockManagerInterface $pluginManagerBlock) { - $this->blockManager = $pluginManagerBlock; - } - - /** - * {@inheritdoc} - */ - protected function getEditableConfigNames() { - return [ - static::SETTINGS, - ]; - } - - /** - * {@inheritdoc} - */ - public function getFormId() { - return 'uw_dashboard_block_restrictions'; - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, FormStateInterface $form_state) { - $rows = []; - $config = $this->config(static::SETTINGS); - // Get list of blocks that could be displayed on dashboard override. - $definitions = $this->blockManager->getFilteredDefinitions('dashboard_override', [], ['section_storage' => NULL]); - // Sort definitions to be displayed on table select. - $grouped_definitions = $this->blockManager->getGroupedDefinitions($definitions); - - foreach ($grouped_definitions as $group => $group_definitions) { - foreach ($group_definitions as $id => $definition) { - $rows[$id] = [ - 'label' => ucfirst($definition['admin_label']), - 'group' => ucfirst($group), - ]; - } - } - - $form['allowed_blocks'] = [ - '#type' => 'tableselect', - '#header' => [ - 'label' => $this->t('Block label'), - 'group' => $this->t('Group'), - ], - '#sticky' => TRUE, - '#options' => $rows, - '#empty' => $this->t('No blocks found.'), - '#default_value' => $config->get('allowed_blocks') ?: [], - ]; - - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, FormStateInterface $form_state) { - $blocks = $form_state->getValue('allowed_blocks'); - $selected = array_filter($blocks); - $this->configFactory->getEditable(static::SETTINGS) - ->set('allowed_blocks', $selected) - ->save(); - - parent::submitForm($form, $form_state); - } - -} diff --git a/uw_dashboard.info.yml b/uw_dashboard.info.yml index c139376aff5ccf56f9fbc7bb3a821112bd4921a3..c8c34051196b6e53419c81b3591c8507f477ce6f 100644 --- a/uw_dashboard.info.yml +++ b/uw_dashboard.info.yml @@ -2,8 +2,9 @@ name: 'UW Dashboard Items' description: 'Block placement for dashboard blocks and site management menu' package: WCMS type: module -core_version_requirement: ^9 || ^10 +core_version_requirement: '^9.4 || ^10' dependencies: + - 'bibcite_entity:bibcite_entity' - 'drupal:better_exposed_filters' - 'drupal:config_views' - 'drupal:content_moderation' diff --git a/uw_dashboard.module b/uw_dashboard.module index d85453f54507a02c56c1271c75649022c8e6ad94..a68fd4de7ef44a1aba06dd76eb5e7c775c77c721 100644 --- a/uw_dashboard.module +++ b/uw_dashboard.module @@ -5,6 +5,7 @@ * UW Dashboard module file. */ +use Drupal\Core\Link; use Drupal\Core\Url; use Drupal\user\Entity\User; use Drupal\uw_dashboard\Handler\UWWebformEntityListBuilder; @@ -59,17 +60,6 @@ function uw_dashboard_toolbar_alter(&$items) { $items['dashboards']['#weight'] = -15; // Rename 'Dashboards' to 'Workbench'. $items['dashboards']['tab']['#title'] = 'Workbench'; - - // Adding config form for user with permission to update it. This prevents - // menu item to be displayed and getting access denied by clicking on it. - $url = Url::fromRoute('uw_dashboard.allowed_blocks'); - if ($url->access()) { - $items['dashboards']['tray']['dashboards']['#items'][] = [ - '#type' => 'link', - '#title' => 'Allowed blocks', - '#url' => $url, - ]; - } } /** @@ -124,33 +114,57 @@ function uw_dashboard_entity_type_alter(array &$entity_types) { } /** - * Implements hook_views_pre_execute(). + * Implements hook_preprocess_page(). */ -function uw_dashboard_views_pre_execute(ViewExecutable $view) { - - // Have a variable that can be used "globally". - static $view_instances_count; - - // If there is no count yet, set it to 0. - if (!isset($view_instances_count)) { - $view_instances_count = 0; - } - - // The views that need the pager id adjusted. - $view_ids = [ - 'uw_view_content_list', - 'uw_view_pub_reference', - 'uw_view_pub_keywords', - 'uw_view_pub_authors', - ]; - - // If a view needs its pager id adjusted, then do it. - if (in_array($view->id(), $view_ids)) { - - // Increment the counter, so we get the correct pager id. - $view_instances_count++; +function uw_dashboard_preprocess_page(&$variables) { + if (\Drupal::routeMatch()->getRouteName() == 'entity.dashboard.canonical') { + // Start building the site info string with the version information. + $string = 'WCMS version ' . \Drupal::service('extension.list.profile')->getList()['uw_base_profile']->info['version']; + $string = Link::fromTextAndUrl($string, Url::fromUri('https://uwaterloo.ca/web-resources/news?tags[90]=90'))->toString(); + + // Get the website lead(s). + $query = \Drupal::entityQuery('user') + ->condition('status', 1) + ->condition('roles', 'uw_role_website_lead') + ->sort('field_uw_last_name', 'ASC') + ->sort('field_uw_first_name', 'ASC'); + $uids = $query->execute(); + $users = User::loadMultiple($uids); + $user_list = []; + foreach ($users as $user) { + $user_list[] = Link::fromTextAndUrl($user->getDisplayName(), Url::fromUri('mailto:' . $user->getEmail()))->toString(); + } + if (!$user_list) { + $user_list[] = 'not set'; + } + $string .= ' • Website lead'; + if (count($user_list) > 1) { + $string .= 's'; + } + $string .= ': ' . implode(', ', $user_list); + + // Get the site owner(s). + $query = \Drupal::entityQuery('user') + ->condition('status', 1) + ->condition('roles', 'uw_role_site_owner') + ->sort('field_uw_last_name', 'ASC') + ->sort('field_uw_first_name', 'ASC'); + $uids = $query->execute(); + $users = User::loadMultiple($uids); + $user_list = []; + foreach ($users as $user) { + $user_list[] = Link::fromTextAndUrl($user->getDisplayName(), Url::fromUri('mailto:' . $user->getEmail()))->toString(); + } + if (!$user_list) { + $user_list[] = 'not set'; + } + $string .= ' • Site owner'; + if (count($user_list) > 1) { + $string .= 's'; + } + $string .= ': ' . implode(', ', $user_list); - // Set the pager id in the view. - $view->pager->options['id'] = $view_instances_count; + // Get the site owner(s). + $variables['page']['help']['#markup'] = '<div class="dashboard__site-info">' . $string . '</div>'; } }