Verified Commit 906ccf1d authored by Dave Long's avatar Dave Long
Browse files

task: #3592672 Remove the who's new and who's online views

By: catch
By: danielveza
By: godotislate
parent 5baee171
Loading
Loading
Loading
Loading
+0 −194
Changes for core/modules/user/config/optional/views.view.who_s_new.yml: 0 added lines, 194 removed lines.
Original line number Diff line number Diff line
langcode: en
status: true
dependencies:
  module:
    - user
id: who_s_new
label: 'Who''s new'
module: user
description: 'Shows a list of the newest user accounts on the site.'
tag: default
base_table: users_field_data
base_field: uid
display:
  default:
    id: default
    display_title: Default
    display_plugin: default
    position: 0
    display_options:
      title: 'Who''s new'
      fields:
        name:
          id: name
          table: users_field_data
          field: name
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: user
          entity_field: name
          plugin_id: field
          label: ''
          exclude: false
          alter:
            alter_text: false
            make_link: false
            absolute: false
            word_boundary: false
            ellipsis: false
            strip_tags: false
            trim: false
            html: false
          element_type: ''
          element_class: ''
          element_label_type: ''
          element_label_class: ''
          element_label_colon: true
          element_wrapper_type: ''
          element_wrapper_class: ''
          element_default_classes: true
          empty: ''
          hide_empty: false
          empty_zero: false
          hide_alter_empty: true
          type: user_name
      pager:
        type: some
        options:
          offset: 0
          items_per_page: 5
      exposed_form:
        type: basic
        options:
          submit_button: Apply
          reset_button: false
          reset_button_label: Reset
          exposed_sorts_label: 'Sort by'
          expose_sort_order: true
          sort_asc_label: Asc
          sort_desc_label: Desc
      access:
        type: perm
        options:
          perm: 'access content'
      cache:
        type: tag
        options: {  }
      empty: {  }
      sorts:
        created:
          id: created
          table: users_field_data
          field: created
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: user
          entity_field: created
          plugin_id: date
          order: DESC
          expose:
            label: ''
            field_identifier: created
          exposed: false
          granularity: second
      arguments: {  }
      filters:
        status:
          id: status
          table: users_field_data
          field: status
          entity_type: user
          entity_field: status
          plugin_id: boolean
          value: '1'
          group: 1
          expose:
            operator: '0'
            operator_limit_selection: false
            operator_list: {  }
        access:
          id: access
          table: users_field_data
          field: access
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: user
          entity_field: access
          plugin_id: date
          operator: '>'
          value:
            min: ''
            max: ''
            value: '1970-01-01'
            type: date
          group: 1
          exposed: false
          expose:
            operator_id: '0'
            label: ''
            description: ''
            use_operator: false
            operator: ''
            operator_limit_selection: false
            operator_list: {  }
            identifier: ''
            required: false
            remember: false
            multiple: false
            remember_roles:
              authenticated: authenticated
          is_grouped: false
          group_info:
            label: ''
            description: ''
            identifier: ''
            optional: true
            widget: select
            multiple: false
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items: {  }
      style:
        type: html_list
      row:
        type: fields
      query:
        type: views_query
        options:
          query_comment: ''
          disable_sql_rewrite: false
          distinct: false
          replica: false
          query_tags: {  }
      relationships: {  }
      header: {  }
      footer: {  }
      display_extenders: {  }
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - user.permissions
      tags: {  }
  block_1:
    id: block_1
    display_title: 'Who''s new'
    display_plugin: block
    position: 1
    display_options:
      display_description: 'A list of new users'
      display_extenders: {  }
      block_description: 'Who''s new'
      block_category: User
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - user.permissions
      tags: {  }
+0 −221
Changes for core/modules/user/config/optional/views.view.who_s_online.yml: 0 added lines, 221 removed lines.
Original line number Diff line number Diff line
langcode: en
status: true
dependencies:
  module:
    - user
id: who_s_online
label: 'Who''s online block'
module: user
description: 'Shows the user names of the most recently active users, and the total number of active users.'
tag: default
base_table: users_field_data
base_field: uid
display:
  default:
    id: default
    display_title: Default
    display_plugin: default
    position: 0
    display_options:
      title: 'Who''s online'
      fields:
        name:
          id: name
          table: users_field_data
          field: name
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: user
          entity_field: name
          plugin_id: field
          label: ''
          exclude: false
          alter:
            alter_text: false
            make_link: false
            absolute: false
            word_boundary: false
            ellipsis: false
            strip_tags: false
            trim: false
            html: false
          element_type: ''
          element_class: ''
          element_label_type: ''
          element_label_class: ''
          element_label_colon: true
          element_wrapper_type: ''
          element_wrapper_class: ''
          element_default_classes: true
          empty: ''
          hide_empty: false
          empty_zero: false
          hide_alter_empty: true
          type: user_name
      pager:
        type: some
        options:
          offset: 0
          items_per_page: 10
      exposed_form:
        type: basic
        options:
          submit_button: Apply
          reset_button: false
          reset_button_label: Reset
          exposed_sorts_label: 'Sort by'
          expose_sort_order: true
          sort_asc_label: Asc
          sort_desc_label: Desc
      access:
        type: perm
        options:
          perm: 'access user profiles'
      cache:
        type: tag
        options: {  }
      empty:
        area_text_custom:
          id: area_text_custom
          table: views
          field: area_text_custom
          relationship: none
          group_type: group
          admin_label: ''
          plugin_id: text_custom
          empty: true
          content: 'There are currently 0 users online.'
          tokenize: false
      sorts:
        access:
          id: access
          table: users_field_data
          field: access
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: user
          entity_field: access
          plugin_id: date
          order: DESC
          expose:
            label: ''
            field_identifier: access
          exposed: false
          granularity: second
      arguments: {  }
      filters:
        status:
          id: status
          table: users_field_data
          field: status
          entity_type: user
          entity_field: status
          plugin_id: boolean
          value: '1'
          group: 1
          expose:
            operator: '0'
            operator_limit_selection: false
            operator_list: {  }
        access:
          id: access
          table: users_field_data
          field: access
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: user
          entity_field: access
          plugin_id: date
          operator: '>='
          value:
            min: ''
            max: ''
            value: '-15 minutes'
            type: offset
          group: 1
          exposed: false
          expose:
            operator_id: access_op
            label: 'Last access'
            description: 'A user is considered online for this long after they have last viewed a page.'
            use_operator: false
            operator: access_op
            operator_limit_selection: false
            operator_list: {  }
            identifier: access
            required: false
            remember: false
            multiple: false
            remember_roles:
              authenticated: authenticated
          is_grouped: false
          group_info:
            label: ''
            description: ''
            identifier: ''
            optional: true
            widget: select
            multiple: false
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items: {  }
      style:
        type: html_list
        options:
          grouping: {  }
          row_class: ''
          default_row_class: true
          type: ul
          wrapper_class: item-list
          class: ''
      row:
        type: fields
      query:
        type: views_query
        options:
          query_comment: ''
          disable_sql_rewrite: false
          distinct: false
          replica: false
          query_tags: {  }
      relationships: {  }
      header:
        result:
          id: result
          table: views
          field: result
          relationship: none
          group_type: group
          admin_label: ''
          plugin_id: result
          empty: false
          content: 'There are currently @total users online.'
      footer: {  }
      display_extenders: {  }
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - user.permissions
      tags: {  }
  who_s_online_block:
    id: who_s_online_block
    display_title: 'Who''s online'
    display_plugin: block
    position: 1
    display_options:
      display_description: 'A list of users that are currently logged in.'
      display_extenders: {  }
      block_description: 'Who''s online'
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - user.permissions
      tags: {  }
+0 −128
Changes for core/modules/user/tests/src/Kernel/WhoIsOnlineBlockTest.php: 0 added lines, 128 removed lines.
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace Drupal\Tests\user\Kernel;

use Drupal\block\Entity\Block;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\user\Traits\UserCreationTrait;
use Drupal\user\Entity\User;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;

/**
 * Tests the Who's Online Block.
 */
#[Group('user')]
#[RunTestsInSeparateProcesses]
class WhoIsOnlineBlockTest extends KernelTestBase {
  use UserCreationTrait;

  /**
   * {@inheritdoc}
   */
  protected static $modules = ['system', 'user', 'block', 'views'];

  /**
   * The block being tested.
   *
   * @var \Drupal\block\BlockInterface
   */
  protected $block;

  /**
   * The block storage.
   *
   * @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface
   */
  protected $controller;

  /**
   * The renderer.
   *
   * @var \Drupal\Core\Render\RendererInterface
   */
  protected $renderer;

  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();
    $this->container->get('theme_installer')->install(['stark']);
    $this->installConfig(['system', 'block', 'views', 'user']);
    $this->installEntitySchema('user');

    $this->controller = $this->container
      ->get('entity_type.manager')
      ->getStorage('block');

    // Create a block with only required values.
    $this->block = $this->controller->create([
      'plugin' => 'views_block:who_s_online-who_s_online_block',
      'region' => 'sidebar_first',
      'id' => 'views_block__who_s_online_who_s_online_block',
      'theme' => \Drupal::configFactory()->get('system.theme')->get('default'),
      'label' => "Who's online",
      'visibility' => [],
      'weight' => 0,
    ]);
    $this->block->save();

    $this->container->get('cache.render')->deleteAll();
    $this->renderer = $this->container->get('renderer');
  }

  /**
   * Tests the Who's Online block.
   */
  public function testWhoIsOnlineBlock(): void {
    // Generate users.
    $user1 = User::create([
      'name' => 'user1',
      'mail' => 'user1@example.com',
      'roles' => [$this->createRole(['access user profiles'])],
    ]);
    $user1->activate();
    $requestTime = \Drupal::time()->getRequestTime();
    $user1->setLastAccessTime($requestTime);
    $user1->save();

    $user2 = User::create([
      'name' => 'user2',
      'mail' => 'user2@example.com',
    ]);
    $user2->activate();
    $user2->setLastAccessTime($requestTime + 1);
    $user2->save();

    $user3 = User::create([
      'name' => 'user3',
      'mail' => 'user2@example.com',
    ]);
    $user3->activate();
    // Insert an inactive user who should not be seen in the block.
    $inactive_time = $requestTime - (60 * 60);
    $user3->setLastAccessTime($inactive_time);
    $user3->save();

    // Test block output.
    \Drupal::currentUser()->setAccount($user1);

    // Test the rendering of a block.
    $entity = Block::load('views_block__who_s_online_who_s_online_block');
    $output = \Drupal::entityTypeManager()
      ->getViewBuilder($entity->getEntityTypeId())
      ->view($entity, 'block');
    $this->setRawContent($this->renderer->renderRoot($output));
    $this->assertRaw('2 users', 'Correct number of online users (2 users).');
    $this->assertText($user1->getAccountName(), 'Active user 1 found in online list.');
    $this->assertText($user2->getAccountName(), 'Active user 2 found in online list.');
    $this->assertNoText($user3->getAccountName(), 'Inactive user not found in online list.');
    // Verify that online users are ordered correctly.
    $raw_content = $this->getRawContent();
    $this->assertGreaterThan(strpos($raw_content, $user2->getAccountName()), strpos($raw_content, $user1->getAccountName()));
  }

}
+11 −7
Changes for core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php: 11 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -47,18 +47,22 @@ protected function setUp(): void {
   * Tests dialog for filter criteria.
   */
  public function testFilterCriteriaDialog(): void {
    // Checks that the admin summary is not double escaped.
    $this->drupalGet('admin/structure/views/view/who_s_online');
    $page = $this->getSession()->getPage();
    $this->assertNotNull($page->findLink('User: Last access (>= -15 minutes)'));

    $this->drupalGet('admin/structure/views/view/test_content_recent');
    $assert_session = $this->assertSession();
    $session = $this->getSession();
    $page = $session->getPage();

    $this->openFilterDialog();
    // Checks that the admin summary is not double escaped.
    $this->drupalGet('admin/structure/views/nojs/add-handler/test_content_recent/block_1/filter');
    $this->getSession()->getPage()->checkField('name[node_field_data.changed]');
    $this->submitForm([], 'Add and configure filter criteria');
    $this->submitForm([
      'options[operator]' => '>',
      'options[value][value]' => '1 day',
      'options[value][type]' => 'offset',
    ], 'Apply');
    $this->assertNotNull($page->findLink('Content: Changed (> 1 day)'));

    $this->openFilterDialog();
    // Add a new filter group.
    $create_new_filter_group = $page->findById('views-add-group-link');
    $this->assertTrue($create_new_filter_group->isVisible(), 'Add group link found.');
+1 −1
Changes for core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ protected function setUp(): void {
   * Tests the filtering on the Views listing page.
   */
  public function testFilterViewsListing(): void {
    $enabled_views_count = 4;
    $enabled_views_count = 2;
    $disabled_views_count = 1;
    $content_views_count = 1;

Loading