Skip to content
Snippets Groups Projects
Commit 11faddc8 authored by Alberto Paderno's avatar Alberto Paderno
Browse files

Issue #3479235: Remove the Tour Example module

parent 3b1b6c61
No related branches found
No related tags found
1 merge request!86Issue #3479235: Remove the Tour Example module
Pipeline #304059 passed
......@@ -147,7 +147,6 @@ function _examples_toolbar_routes() {
'tabledrag_example' => 'tabledrag_example.description',
'tablesort_example' => 'tablesort_example.description',
'testing_example' => 'testing_example.description',
'tour_example' => 'tour_example.description',
];
}
......
# This file defines the tour for our example page. There should be one tour
# file for each tour that you create. These tour files should be placed in a
# module's 'config' folder and named using the pattern
# 'tour.tour.{tour-id}.yml'.
#
# Each tour file has two parts: 1) The tour properties, and 2) the tip
# definitions.
#
#
# TOUR PROPERTIES
#
# The tour properties define information that applies to the tour as a whole.
# Properties that you can define for your tours include the following:
#
# id: Each tour should have a unique ID. This id is used in the
# filename and appears as an ID in the HTML.
# module: The machine name of the module containing your tour.
# label: A human readable name for the tour.
# status: A boolean, defining whether the tour is enabled.
# langcode: A two-letter language code defining the language of your tour.
# routes: An array of routes for which the tour is active. Specify these
# as an array with route_name and optional route_params (also an
# array). Route names are found in each module's routing.yml file.
#
#
# TIP DEFINITIONS
#
# Here, you define each tip that you want to appear in your tour. Each of
# the tips have properties that must be defined, including the following:
#
# id: Each tip needs a unique ID. This appears as an ID in the HTML.
# plugin: The Tour API uses plugins for defining different types of
# tips. The 'text' plugin (for making text tooltips) is provided
# in core, but developers can define additional plugins for tips
# containing images, video, or other interactions.
# label: The label for the tip. This will be rendered in a <h3> element.
# body: The body of the tip. HTML markup is allowed.
# weight: Tips within a tour are ordered by weight, beginning with the
# lowest number. Negative values are acceptable.
# position: Defines the position of the tip, relative to its target.
# Acceptable values include: 'auto', 'auto-start', 'auto-end',
# 'top', 'top-start', 'top-end', 'bottom', 'bottom-start',
# 'bottom-end', 'right', 'right-start', 'right-end', 'left',
# 'left-start', 'left-end'. Default: auto.
# selector: The HTML element you want to attach the tip to. You can use
# classes (.class-name), ID's (#id-name), a combination of both,
# and even complex elements like (.action-links
# a[href="/admin/structure/forum/add/forum"])
#
# If you omit, the tip will be shown as modal instead of being
# targeted to an element.
#
id: tour-example
module: tour_example
label: 'Tour an example admin page'
langcode: en
routes:
- route_name: tour_example.description
tips:
introduction:
id: introduction
plugin: text
label: 'Introduction'
body: 'This is an example tour. Click "next" to continue through the tour.'
weight: 1
first-item:
id: first-item
plugin: text
label: 'First Item'
body: 'Tours are helpful for walking users through an unfamiliar admin interface.'
weight: 2
position: bottom
selector: '#tour-target-1'
second-item:
id: second-item
plugin: text
label: 'Second Item'
body: 'Individual tips can be positioned anywhere on the page.'
weight: 3
position: top
selector: '#tour-target-2'
third-item:
id: third-item
plugin: text
label: 'Third Item'
body: 'You can click the X in the top right corner of this box to close the tour at any time.'
weight: 4
position: bottom
selector: '#tour-target-3'
fourth-item:
id: fourth-item
plugin: text
label: 'Fourth Item'
body: 'When the tour is over, click "End Tour".'
weight: 5
position: left
selector: '#tour-target-4'
<?php
namespace Drupal\tour_example\Controller;
use Drupal\examples\Utility\DescriptionTemplateTrait;
/**
* Controller routines for tour example routes.
*
* This is where our tour page is defined.
*
* @ingroup tour_example
*/
class TourExampleController {
use DescriptionTemplateTrait;
/**
* {@inheritdoc}
*/
protected function getModuleName() {
return 'tour_example';
}
}
{#
Description text for the Tour Example.
Note that we have defined some 'buttons.' These page elements are targets for
the tour we're demonstrating.
The id of the target elements are used in the tour definition file as targets
for the various tour steps.
#}
{% trans %}
<h2>The Tour:</h2>
<p>Click the 'Tour' icon in the admin menu bar to start.</p>
<div id="button-container">
<div class="button" id="tour-target-1">First item.</div>
<div class="button" id="tour-target-2">Second item.</div>
<div class="button" id="tour-target-3">Third item.</div>
<div class="button" id="tour-target-4">Fourth item.</div>
</div>
<h2>About Tours</h2>
<p>The Tour module allows you you make instructional tours of user interfaces.</p>
<p>The Tour module comes with Drupal and makes it easy for developers to add
&quot;Tours&quot; for guiding users through unfamiliar user interfaces.</p>
<p>Each tour is comprised of a series of tooltips that provide contextual
information about an interface. The user can start a tour by clicking the
&quot;Tour&quot; icon on the right side of the Drupal toolbar. The tour icon is only
visible when there is a tour available on the current page.</p>
<p>The Tour module provides the Tour API, which makes it easy for developers to
add tours to their modules. In most cases, adding a tour is as simple as
creating a YAML file in the config directory in their module, containing the
expected data. For a detailed example of such a file, see
config/install/tour.tour.tour-example.yml.</p>
<p>If you are interested in building tours through a user interface, you may
want to look at the Tour UI module: <a href="https://drupal.org/project/tour_ui">https://drupal.org/project/tour_ui</a></p>
<p>The Tour module uses the Shepherd JavaScript library for its underlying
functionality. You can find more information about Shepherd at
<a href="https://shepherdjs.dev/">https://shepherdjs.dev/</a></p>
{% endtrans %}
<?php
namespace Drupal\Tests\tour_example\Functional;
use Drupal\Core\Url;
use Drupal\Tests\tour\Functional\TourTestBasic;
/**
* Regression tests for the tour_example module.
*
* We use TourTestBasic to get some built-in tour tip testing assertions.
*
* @ingroup tour_example
*
* @group tour_example
* @group examples
*/
class TourExampleTest extends TourTestBasic {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = ['tour_example'];
/**
* The installation profile to use with this test.
*
* @var string
*/
protected $profile = 'minimal';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
$this->defaultTheme = 'stark';
parent::setUp();
}
/**
* Main test.
*
* Make sure the Tour Example link is on the front page. Make sure all the
* tour tips exist on the page. Make sure all the corresponding target
* elements exist for tour tips that have targets.
*/
public function testTourExample() {
$assert = $this->assertSession();
// Create a user with the permissions we need in order to display the
// toolbar and run a tour from it.
$this->drupalLogin($this->createUser([
'access content',
'access toolbar',
'access tour',
]));
// Test for a link to the tour_example in the Tools menu.
$this->drupalGet(Url::fromRoute('<front>'));
$assert->statusCodeEquals(200);
$assert->linkByHrefExists('examples/tour-example');
// Verify anonymous user can successfully access the tour_examples page.
$this->drupalGet(Url::fromRoute('tour_example.description'));
$assert->statusCodeEquals(200);
// Get all the tour elements. These are the IDs of each tour tip. See them
// in config/install/tour.tour.tour-example.yml.
$tip_ids = [
'introduction' => '',
'first-item' => '#tour-target-1',
'second-item' => '#tour-target-2',
'third-item' => '#tour-target-3',
'fourth-item' => '#tour-target-4',
];
// Ensure that we have the right number of buttons.
// First tip does not have accompanying button, so we have less buttons
// than tour items.
$this->assertCount(count($tip_ids) - 1, $this->cssSelect('#button-container .button'));
// Ensure each item exists.
foreach ($tip_ids as $tip_id => $tip_selector) {
if (!$tip_selector) {
continue;
}
$this->assertNotEmpty($this->cssSelect($tip_selector),
"Tip id: $tip_id $tip_selector"
);
}
// Verify that existing tour tips have corresponding target page elements.
$this->assertTourTips();
}
}
name: 'Tour Example'
type: module
description: 'Demonstrates how to create a tour'
package: Example modules
core_version_requirement: ^10.3 || ^11.0
dependencies:
- drupal:tour
- drupal:toolbar
- examples:examples
tour_example.description:
title: Tour Example
route_name: tour_example.description
<?php
/**
* @file
* Module file for tour_example.
*/
/**
* @defgroup tour_example Example: Tour
* @ingroup examples
* @{
* The Tour module allows you you make instructional tours of user interfaces.
*
* The Tour module comes with Drupal 8 and makes it easy for developers to add
* "Tours" for guiding users through unfamiliar user interfaces.
*
* Each tour is comprised of a series of tooltips that provide contextual
* information about an interface. The user can start a tour by clicking the
* "Tour" icon on the right side of the Drupal 8 toolbar. The tour icon is only
* visible when there is a tour available on the current page.
*
* The Tour module provides the Tour API, which makes it easy for developers to
* add tours to their modules. In most cases, adding a tour is as simple as
* creating a YAML file in the config directory in their module, containing the
* expected data. For a detailed example of such a file, see
* config/install/tour.tour.tour-example.yml.
*
* If you are interested in building tours through a user interface, you may
* want to look at the Tour UI module: https://drupal.org/project/tour_ui
*
* The Tour module uses the Joyride jQuery plugin for its underlying
* functionality. You can find more information about Joyride at
* https://github.com/zurb/joyride
*/
/**
* @} End of "defgroup tour_example".
*/
tour_example.description:
path: '/examples/tour-example'
options:
_admin_route: TRUE
defaults:
_controller: '\Drupal\tour_example\Controller\TourExampleController::description'
_title: 'Tour Example'
requirements:
_access: 'TRUE'
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