Skip to content
Snippets Groups Projects
Commit 33cd459e authored by Stephen Mustgrave's avatar Stephen Mustgrave
Browse files

Issue #2040833 by wiifm, ridhimaabrol24, nick_schuch, ranjith_kumar_k_u,...

Issue #2040833 by wiifm, ridhimaabrol24, nick_schuch, ranjith_kumar_k_u, tim-e, nielsonm, Farnoosh: Write tour integration for Dblog page
parent add2c6cb
No related branches found
No related tags found
No related merge requests found
Pipeline #165161 passed with warnings
langcode: en
status: true
dependencies:
module:
- dblog
id: dblog
label: 'Database log'
routes:
- route_name: dblog.overview
tips:
dblog-intro:
id: dblog-about
plugin: text
label: 'Recent log messages'
body: "System events such as errors, failed login attempts and content updates are stored as messages in the site's database. On the <em>Recent log messages</em> page you find a chronological list of recorded messages that you can filter and view. You should check the log messages on a regular basis to ensure the site is working properly"
weight: 1
dblog-filter-clear:
id: dblog-filter-clear
plugin: text
label: 'Clearing messages'
body: 'Click on the <em>Delete</em> tab on the top left to delete all the log messages from the database.'
weight: 2
dblog-filter:
id: dblog-filter
plugin: text
label: 'Filtering messages'
body: 'Use the exposed form to <em>Filter log messages</em> by <em>Type</em> (usually the name of the module that generated the message) or <em>Severity</em> (emergency, critical, notice, etc).'
weight: 3
selector: '#views-exposed-form-watchdog-page'
dblog-table-sort:
id: dblog-table-sort
plugin: text
label: 'Sorting messages'
body: 'Click on the table headers <em>Type</em>, <em>Date</em>, <em>Message</em>, or <em>User</em> to sort the list of messages.'
weight: 4
selector: '.views-table thread'
dblog-recognize-message:
id: dblog-recognize-message
plugin: text
label: 'Recognizing messages'
body: 'The severity of the message is made visible with colors and icons.'
weight: 5
dblog-table-view:
id: dblog-table-view
plugin: text
label: 'Viewing messages'
body: 'Click on the message to get more details such as the location (page that generated the message), the referrer and the hostname where the request originated from.'
weight: 6
selector: '.admin-dblog tbody > tr td a'
dblog-more-information:
id: dblog-more-information
plugin: text
label: 'More information'
# URLs are created dynamically based on routes.
# @see tour_tour_tips_alter().
body: 'For more information, see [help.page.dblog]<a href="https://www.drupal.org/documentation/modules/dblog">the online documentation</a>. On the <a href="[site:url]admin/config/development/logging">configuration</a> page you define which and how many messages should be stored.'
weight: 99
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\system\Functional;
use Drupal\Tests\dblog\Functional\FakeLogEntries;
use Drupal\Tests\tour\Functional\TourTestBase;
/**
......@@ -11,12 +12,14 @@ use Drupal\Tests\tour\Functional\TourTestBase;
*/
class SystemPageTourTests extends TourTestBase {
use FakeLogEntries;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = ['block', 'tour', 'system'];
protected static $modules = ['block', 'tour', 'system', 'dblog'];
/**
* {@inheritdoc}
......@@ -25,25 +28,29 @@ class SystemPageTourTests extends TourTestBase {
parent::setUp();
$this->adminUser = $this->drupalCreateUser([
'administer themes',
'administer modules',
'access site reports',
'access tour',
]);
$this->drupalLogin($this->adminUser);
$this->drupalPlaceBlock('local_actions_block');
$this->generateLogEntries(1);
}
/**
* Test tips appear for various system pages.
*/
public function testUserRelatedPages(): void {
public function testSystemRelatedPages(): void {
$this->testAppearanceTour();
$this->testExtendTour();
$this->testDblogTour();
}
/**
* Tests appearance tour tip availability.
*/
protected function testAppearanceTour(): void {
$this->drupalGet('appearance');
$this->drupalGet('admin/appearance');
$this->assertTourTips();
}
......@@ -55,4 +62,12 @@ class SystemPageTourTests extends TourTestBase {
$this->assertTourTips();
}
/**
* Tests modules extend tour tip availability.
*/
protected function testDblogTour(): void {
$this->drupalGet('admin/reports/dblog');
$this->assertTourTips();
}
}
......@@ -85,3 +85,10 @@ function tour_update_10303(): void {
function tour_update_10304(): void {
import_new_tour_config('content-language');
}
/**
* Import dblog tour configuration.
*/
function tour_update_10305(): void {
import_new_tour_config('dblog');
}
......@@ -7,6 +7,7 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\tour\Entity\Tour;
/**
......@@ -104,7 +105,7 @@ function tour_page_bottom(array &$page_bottom): void {
if (!empty($tours)) {
$page_bottom['tour'] = \Drupal::entityTypeManager()
->getViewBuilder('tour')
->viewMultiple($tours, 'full');
->viewMultiple($tours);
}
}
}
......@@ -127,7 +128,7 @@ function tour_tour_update($entity): void {
* Implements hook_tour_tips_alter().
*/
function tour_tour_tips_alter(array &$tour_tips, EntityInterface $entity): void {
if (Drupal::service('module_handler')->moduleExists('language')) {
if (\Drupal::service('module_handler')->moduleExists('language')) {
foreach ($tour_tips as $tour_tip) {
if ($tour_tip->get('id') == 'language-overview') {
if (Drupal::service('module_handler')->moduleExists('locale')) {
......@@ -163,4 +164,21 @@ function tour_tour_tips_alter(array &$tour_tips, EntityInterface $entity): void
}
}
}
if (\Drupal::service('module_handler')->moduleExists('dblog')) {
foreach ($tour_tips as $tour_tip) {
if ($tour_tip->get('id') == 'dblog-more-information') {
$body = $tour_tip->get('body');
// Tips can reference the help page conditionally, only create the link
// if the help module is enabled, else remove it.
if (\Drupal::moduleHandler()->moduleExists('help')) {
$body = str_replace('[help.page.dblog]', '<a href="' . Url::fromRoute('help.page', ['name' => 'dblog'])->toString() . '">the help text</a> and ', $body);
}
else {
$body = str_replace('[help.page.dblog]', '', $body);
}
$tour_tip->set('body', $body);
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment