Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2018-11-09 09:04:27 +0300
committerGitHub <noreply@github.com>2018-11-09 09:04:27 +0300
commit6c0b49387d58768d0cbbd0a50ea1b4b4b83b15e1 (patch)
treec9c80921fca2910699395b8675aaed4a8644b2ec /plugins/CorePluginsAdmin
parent3bc57d6e4df80ff1969151d75a378ab2233f8067 (diff)
Add Matomo Tag Manager to core (#13402)
Diffstat (limited to 'plugins/CorePluginsAdmin')
-rw-r--r--plugins/CorePluginsAdmin/Controller.php48
-rw-r--r--plugins/CorePluginsAdmin/CorePluginsAdmin.php13
-rw-r--r--plugins/CorePluginsAdmin/Menu.php12
-rw-r--r--plugins/CorePluginsAdmin/Model/TagManagerTeaser.php85
-rw-r--r--plugins/CorePluginsAdmin/config/test.php19
-rw-r--r--plugins/CorePluginsAdmin/lang/en.json18
-rw-r--r--plugins/CorePluginsAdmin/stylesheets/plugins_admin.less7
-rw-r--r--plugins/CorePluginsAdmin/templates/tagManagerTeaser.twig73
-rw-r--r--plugins/CorePluginsAdmin/tests/Integration/TagManagerTeaserTest.php106
-rw-r--r--plugins/CorePluginsAdmin/tests/UI/.gitignore2
-rw-r--r--plugins/CorePluginsAdmin/tests/UI/TagManagerTeaser_spec.js92
-rw-r--r--plugins/CorePluginsAdmin/tests/UI/expected-screenshots/.gitkeep0
-rw-r--r--plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page.png3
-rw-r--r--plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page_disable.png3
-rw-r--r--plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_super_user_activate_plugin.png3
-rw-r--r--plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_superuser_page.png3
16 files changed, 486 insertions, 1 deletions
diff --git a/plugins/CorePluginsAdmin/Controller.php b/plugins/CorePluginsAdmin/Controller.php
index e9b8c59669..695cfef33f 100644
--- a/plugins/CorePluginsAdmin/Controller.php
+++ b/plugins/CorePluginsAdmin/Controller.php
@@ -20,9 +20,11 @@ use Piwik\Nonce;
use Piwik\Notification;
use Piwik\Piwik;
use Piwik\Plugin;
+use Piwik\Plugins\CorePluginsAdmin\Model\TagManagerTeaser;
use Piwik\Plugins\Marketplace\Marketplace;
use Piwik\Plugins\Marketplace\Controller as MarketplaceController;
use Piwik\Plugins\Marketplace\Plugins;
+use Piwik\Settings\Storage\Backend\PluginSettingsTable;
use Piwik\SettingsPiwik;
use Piwik\Translation\Translator;
use Piwik\Url;
@@ -144,8 +146,52 @@ class Controller extends Plugin\ControllerAdmin
$this->redirectToIndex('Marketplace', 'overview', null, null, null, array('show' => 'themes'));
}
+ public function tagManagerTeaser()
+ {
+ $this->dieIfPluginsAdminIsDisabled();
+ Piwik::checkUserHasSomeAdminAccess();
+
+ $tagManagerTeaser = new TagManagerTeaser(Piwik::getCurrentUserLogin());
+
+ if (!$tagManagerTeaser->shouldShowTeaser()) {
+ $this->redirectToIndex('CoreHome', 'index');
+ return;
+ }
+
+ $nonce = '';
+ if (Piwik::hasUserSuperUserAccess()) {
+ $nonce = Nonce::getNonce(static::ACTIVATE_NONCE);
+ }
+
+ $superUsers = Request::processRequest('UsersManager.getUsersHavingSuperUserAccess', [], []);
+ $emails = implode(',', array_column($superUsers, 'email'));
+
+ $view = new View('@CorePluginsAdmin/tagManagerTeaser');
+ $this->setGeneralVariablesView($view);
+ $view->superUserEmails = $emails;
+ $view->nonce = $nonce;
+ return $view->render();
+ }
+
+ public function disableActivateTagManagerPage()
+ {
+ $this->dieIfPluginsAdminIsDisabled();
+ Piwik::checkUserHasSomeAdminAccess();
+
+ $tagManagerTeaser = new TagManagerTeaser(Piwik::getCurrentUserLogin());
+
+ if (Piwik::hasUserSuperUserAccess()) {
+ $tagManagerTeaser->disableGlobally();
+ } else {
+ $tagManagerTeaser->disableForUser();
+ }
+
+ $this->redirectToIndex('CoreHome', 'index');
+ }
+
private function dieIfPluginsAdminIsDisabled()
{
+ Piwik::checkUserIsNotAnonymous();
if (!CorePluginsAdmin::isPluginsAdminEnabled()) {
throw new \Exception('Enabling, disabling and uninstalling plugins has been disabled by Piwik admins.
Please contact your Piwik admins with your request so they can assist you.');
@@ -395,6 +441,8 @@ class Controller extends Plugin\ControllerAdmin
$redirectTo = Common::getRequestVar('redirectTo', '', 'string');
if (!empty($redirectTo) && $redirectTo === 'marketplace') {
$this->redirectToIndex('Marketplace', 'overview');
+ } elseif (!empty($redirectTo) && $redirectTo === 'tagmanager') {
+ $this->redirectToIndex('TagManager', 'gettingStarted');
} elseif (!empty($redirectTo) && $redirectTo === 'referrer') {
$this->redirectAfterModification($redirectAfter);
} else {
diff --git a/plugins/CorePluginsAdmin/CorePluginsAdmin.php b/plugins/CorePluginsAdmin/CorePluginsAdmin.php
index c12ad281bd..b83efbbb83 100644
--- a/plugins/CorePluginsAdmin/CorePluginsAdmin.php
+++ b/plugins/CorePluginsAdmin/CorePluginsAdmin.php
@@ -12,6 +12,7 @@ use Piwik\Config;
use Piwik\Piwik;
use Piwik\Plugin;
use Piwik\Plugins\CoreHome\SystemSummary;
+use Piwik\Plugins\CorePluginsAdmin\Model\TagManagerTeaser;
class CorePluginsAdmin extends Plugin
{
@@ -24,10 +25,20 @@ class CorePluginsAdmin extends Plugin
'AssetManager.getJavaScriptFiles' => 'getJsFiles',
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'System.addSystemSummaryItems' => 'addSystemSummaryItems',
- 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys'
+ 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys',
+ 'PluginManager.pluginActivated' => 'onPluginActivated'
);
}
+ public function onPluginActivated($pluginName)
+ {
+ if ($pluginName === 'TagManager') {
+ // make sure once activated once, it won't appear when disabling Tag Manager later
+ $tagManagerTeaser = new TagManagerTeaser(Piwik::getCurrentUserLogin());
+ $tagManagerTeaser->disableGlobally();
+ }
+ }
+
public function addSystemSummaryItems(&$systemSummary)
{
$numPlugins = Plugin\Manager::getInstance()->getNumberOfActivatedPluginsExcludingAlwaysActivated();
diff --git a/plugins/CorePluginsAdmin/Menu.php b/plugins/CorePluginsAdmin/Menu.php
index 8e1b57ef40..b858db7e8f 100644
--- a/plugins/CorePluginsAdmin/Menu.php
+++ b/plugins/CorePluginsAdmin/Menu.php
@@ -10,7 +10,10 @@ namespace Piwik\Plugins\CorePluginsAdmin;
use Piwik\Container\StaticContainer;
use Piwik\Menu\MenuAdmin;
+use Piwik\Menu\MenuTop;
use Piwik\Piwik;
+use Piwik\Plugin;
+use Piwik\Plugins\CorePluginsAdmin\Model\TagManagerTeaser;
use Piwik\Plugins\Marketplace\Marketplace;
use Piwik\Plugins\Marketplace\Plugins;
@@ -32,6 +35,15 @@ class Menu extends \Piwik\Plugin\Menu
}
}
+ public function configureTopMenu(MenuTop $menu)
+ {
+ $tagManagerTeaser = new TagManagerTeaser(Piwik::getCurrentUserLogin());
+
+ if ($tagManagerTeaser->shouldShowTeaser()) {
+ $menu->addItem('Tag Manager', null, $this->urlForAction('tagManagerTeaser'));
+ }
+ }
+
public function configureAdminMenu(MenuAdmin $menu)
{
$hasSuperUserAcess = Piwik::hasUserSuperUserAccess();
diff --git a/plugins/CorePluginsAdmin/Model/TagManagerTeaser.php b/plugins/CorePluginsAdmin/Model/TagManagerTeaser.php
new file mode 100644
index 0000000000..54fdb1e9b1
--- /dev/null
+++ b/plugins/CorePluginsAdmin/Model/TagManagerTeaser.php
@@ -0,0 +1,85 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\CorePluginsAdmin\Model;
+
+use Piwik\Plugin;
+use Piwik\Option;
+use Piwik\Piwik;
+use Piwik\Plugins\CorePluginsAdmin\CorePluginsAdmin;
+use Piwik\Settings\Storage\Backend\PluginSettingsTable;
+
+class TagManagerTeaser
+{
+ const DISABLE_GLOBALLY_KEY = 'CorePluginsAdmin.disableTagManagerTeaser';
+
+ /**
+ * @var string
+ */
+ private $login;
+
+ public function __construct($login)
+ {
+ $this->login = $login;
+ }
+
+ public function shouldShowTeaser()
+ {
+ $pluginManager = Plugin\Manager::getInstance();
+
+ return CorePluginsAdmin::isPluginsAdminEnabled()
+ && (!$pluginManager->isPluginActivated('TagManager')
+ || !$pluginManager->isPluginLoaded('TagManager'))
+ && $pluginManager->isPluginInFilesystem('TagManager')
+ && Piwik::isUserHasSomeAdminAccess()
+ && $this->isEnabledGlobally()
+ && $this->isEnabledForUser();
+ }
+
+ public function disableForUser()
+ {
+ $table = $this->getTable();
+ $settings = $table->load();
+ $settings['disable_activate_tag_manager_page'] = 1;
+ $table->save($settings);
+ }
+
+ public function isEnabledForUser()
+ {
+ $pluginSettingsTable = $this->getTable();
+ $settings = $pluginSettingsTable->load();
+
+ return empty($settings['disable_activate_tag_manager_page']);
+ }
+
+ public function disableGlobally()
+ {
+ $this->reset();
+ Option::set(self::DISABLE_GLOBALLY_KEY, 1, true);
+ }
+
+ public function reset()
+ {
+ Option::delete(self::DISABLE_GLOBALLY_KEY);
+
+ // no need to keep any old login entries
+ $this->getTable()->save(array());
+ }
+
+ public function isEnabledGlobally()
+ {
+ $value = Option::get(self::DISABLE_GLOBALLY_KEY);
+ return empty($value);
+ }
+
+ private function getTable()
+ {
+ return new PluginSettingsTable('CorePluginsAdmin', $this->login);
+ }
+
+}
diff --git a/plugins/CorePluginsAdmin/config/test.php b/plugins/CorePluginsAdmin/config/test.php
new file mode 100644
index 0000000000..71cc69dda5
--- /dev/null
+++ b/plugins/CorePluginsAdmin/config/test.php
@@ -0,0 +1,19 @@
+<?php
+
+return array(
+ 'observers.global' => DI\add(array(
+ array('Request.dispatchCoreAndPluginUpdatesScreen', function () {
+ $pluginName = 'TagManager';
+ $unloadTagManager = \Piwik\Container\StaticContainer::get('test.vars.unloadTagManager');
+ $tagManagerTeaser = new \Piwik\Plugins\CorePluginsAdmin\Model\TagManagerTeaser(\Piwik\Piwik::getCurrentUserLogin());
+ if ($unloadTagManager) {
+ $pluginManager = \Piwik\Plugin\Manager::getInstance();
+ if ($pluginManager->isPluginActivated($pluginName)
+ && $pluginManager->isPluginLoaded($pluginName)) {
+ $pluginManager->unloadPlugin($pluginName);
+ }
+ $tagManagerTeaser->reset();
+ }
+ }),
+ ))
+);
diff --git a/plugins/CorePluginsAdmin/lang/en.json b/plugins/CorePluginsAdmin/lang/en.json
index eab5ce5052..8ab8ca0948 100644
--- a/plugins/CorePluginsAdmin/lang/en.json
+++ b/plugins/CorePluginsAdmin/lang/en.json
@@ -57,6 +57,24 @@
"TeaserExtendPiwikByPlugin": "Extend Matomo by %1$sinstalling plugins from the Marketplace%2$s or %3$supload a plugin in .zip format%4$s.",
"TeaserExtendPiwikByTheme": "Enjoy another look & feel by %1$sinstalling a new theme%2$s.",
"InstallingNewPluginViaMarketplaceOrUpload": "You may automatically install plugins from the Marketplace or %1$supload a plugin%2$s in .zip format.",
+ "TagManagerNowAvailableTitle": "Matomo Tag Manager is now available",
+ "TagManagerNowAvailableSubtitle": "Manage all your tags easily through one platform to get the insights you want, the opportunities are endless!",
+ "ActivateTagManagerNow": "Activate Tag Manager now",
+ "TagManagerEmailSuperUserToActivate": "Email Super Users to activate this new feature",
+ "TagManagerTeaserHideSuperUser": "Do not show this page to any user",
+ "TagManagerTeaserHideNonSuperUser": "Not interested, do not show this page again",
+ "TagManagerTeaserEmailSuperUserBody": "Hi,%1$sMatomo Tag Manager is now available within Matomo and I would love to use this new feature. As you have Super User access, could you activate this feature through the Tag Manager page in the top menu?%2$sThe Matomo URL is %3$s.%4$sThanks",
+ "WhatIsTagManager": "What is a Tag Manager?",
+ "WhatIsTagManagerDetails1": "Similar to how a Content Management System (CMS) brings you all the flexibility to publish content for your website without having the technical HTML/CSS knowledge, a Tag Management System (TMS) is your go-to for simplifying the process of embedding first and third-party application tracking tags (also known as snippets or pixels) on your website.",
+ "WhatIsTagManagerDetails2": "Say you want to see the results of your conversions/goals, newsletter signups, social widgets, exit popups and remarketing campaigns; what was once a highly technical and time consuming process is now easily done within the TMS and takes only a few clicks to implement.",
+ "TagManagerLearnMoreInUserGuide": "Learn more in the Tag Manager User Guide",
+ "WhyUsingATagManager": "Why a Tag Manager?",
+ "WhyUsingATagManagerDetails1": "A Tag Manager makes your life easier! You no longer need to wait on a developer to modify any first or third-party snippets on your website as the Tag Manager gives you a stress-free experience to make these changes and deploy your website yourself.",
+ "WhyUsingATagManagerDetails2": "It couldn't be more convenient and it not only lets you bring changes to the market faster, but also reduces cost.",
+ "WhyUsingATagManagerDetails3": "This keeps the marketing teams, digital teams and the IT guys happy... It’s a win-win for everyone!",
+ "AreThereAnyRisks": "Are there any risks?",
+ "AreThereAnyRisksDetails1": "When you activate the Tag Manager, users with admin access will be able to create custom HTML tags, triggers, and variables that may execute JavaScript on your website. These custom templates could be misused to steal, for example, sensitive information from your website visitors (known as %1$sXSS%2$s).",
+ "AreThereAnyRisksDetails2": "You can disable these custom templates under \"Administration => General Settings\" once you have activated the Tag Manager. Alternatively, you can also restrict the usage of these templates to specific users or super users only.",
"Theme": "Theme",
"Themes": "Themes",
"ThemesDescription": "Themes can change the appearance of Matomo user interface, and provide a completely new visual experience to enjoy your analytics reports.",
diff --git a/plugins/CorePluginsAdmin/stylesheets/plugins_admin.less b/plugins/CorePluginsAdmin/stylesheets/plugins_admin.less
index 0adcbc1216..3c30b98226 100644
--- a/plugins/CorePluginsAdmin/stylesheets/plugins_admin.less
+++ b/plugins/CorePluginsAdmin/stylesheets/plugins_admin.less
@@ -142,3 +142,10 @@ table.entityTable tr td a.uninstall {
margin-left: 20px;
}
}
+
+
+.activateTagManager {
+ .dontShowAgainBtn {
+ background-color: @theme-color-text-lighter;
+ }
+}
diff --git a/plugins/CorePluginsAdmin/templates/tagManagerTeaser.twig b/plugins/CorePluginsAdmin/templates/tagManagerTeaser.twig
new file mode 100644
index 0000000000..1aa9f62a85
--- /dev/null
+++ b/plugins/CorePluginsAdmin/templates/tagManagerTeaser.twig
@@ -0,0 +1,73 @@
+{% extends 'dashboard.twig' %}
+
+{% block topcontrols %}
+{% endblock %}
+
+{% block content %}
+<div class="activateTagManager">
+ <div class="row">
+ <div class="col s12" style="text-align: center;">
+ <h2>{{ 'CorePluginsAdmin_TagManagerNowAvailableTitle'|translate }}</h2>
+ <p>{{ 'CorePluginsAdmin_TagManagerNowAvailableSubtitle'|translate }}</p>
+ </div>
+ </div>
+ {% set actionBlock %}
+ <div class="row">
+ <div class="col s12">
+ <div style="text-align: center;">
+ {% if isSuperUser %}
+ <a href="{{ linkTo({'module': 'CorePluginsAdmin', 'action': 'activate', 'nonce': nonce, 'pluginName': 'TagManager', 'redirectTo': 'tagmanager'}) }}"
+ class="btn activateTagManagerPlugin"><span class="icon-rocket"></span> {{ 'CorePluginsAdmin_ActivateTagManagerNow'|translate }} <span class="icon-rocket"></span></a>
+ {% else %}
+ <a href="mailto:{{ superUserEmails|e('url') }}?subject={{ 'CorePluginsAdmin_TagManagerNowAvailableTitle'|translate|e('url') }}&body={{ 'CorePluginsAdmin_TagManagerTeaserEmailSuperUserBody'|translate("\n\n", "\n\n", piwikUrl, "\n\n")|e('url') }}"
+ class="btn activateTagManagerPlugin"><span class="icon-rocket"></span> {{ 'CorePluginsAdmin_TagManagerEmailSuperUserToActivate'|translate }} <span class="icon-rocket"></span></a>
+ {% endif %}
+
+ <a href="{{ linkTo({'module': 'CorePluginsAdmin', 'action': 'disableActivateTagManagerPage'}) }}"
+ class="btn dontShowAgainBtn"><span class="icon-hide"></span>
+ {% if isSuperUser %}{{ 'CorePluginsAdmin_TagManagerTeaserHideSuperUser'|translate }}{% else %}{{ 'CorePluginsAdmin_TagManagerTeaserHideNonSuperUser'|translate }}{% endif %}
+ </a>
+ </div>
+ </div>
+ </div>
+ {% endset %}
+ {{ actionBlock|raw }}
+ <div class="row">
+ <div class="col {% if isSuperUser %}l4{% else %}l6{% endif %} m12 s12">
+ <div piwik-content-block content-title="{{ 'CorePluginsAdmin_WhatIsTagManager'|translate }}">
+ <p>
+ {{ 'CorePluginsAdmin_WhatIsTagManagerDetails1'|translate }}<br /><br />
+ {{ 'CorePluginsAdmin_WhatIsTagManagerDetails2'|translate }}<br /><br />
+ <a href="https://matomo.org/docs/tag-manager" rel="noreferrer noopener">{{ 'CorePluginsAdmin_TagManagerLearnMoreInUserGuide'|translate }}</a>
+ </p>
+ </div>
+ </div>
+ <div class="col {% if isSuperUser %}l4{% else %}l6{% endif %} m12 s12">
+ <div piwik-content-block content-title="{{ 'CorePluginsAdmin_WhyUsingATagManager'|translate }}">
+ <p>
+ {{ 'CorePluginsAdmin_WhyUsingATagManagerDetails1'|translate }}
+ <br /><br />
+ {{ 'CorePluginsAdmin_WhyUsingATagManagerDetails2'|translate }}
+ <br /><br />
+ {{ 'CorePluginsAdmin_WhyUsingATagManagerDetails3'|translate }}
+ <br /><br /><br />
+ <a href="https://matomo.org/docs/tag-manager" rel="noreferrer noopener">{{ 'CorePluginsAdmin_TagManagerLearnMoreInUserGuide'|translate }}</a>
+ </p>
+ </div>
+ </div>
+ {% if isSuperUser %}
+ <div class="col l4 m12 s12">
+ <div piwik-content-block content-title="{{ 'CorePluginsAdmin_AreThereAnyRisks'|translate }}">
+
+ {{ 'CorePluginsAdmin_AreThereAnyRisksDetails1'|translate('<a rel="noreferrer noopener" href="https://en.wikipedia.org/wiki/Cross-site_scripting">', '</a>')|raw }}
+ <br /><br />
+ {{ 'CorePluginsAdmin_AreThereAnyRisksDetails2'|translate }}
+ <br /><br /><br />
+ <a href="https://matomo.org/docs/tag-manager/#website-security" rel="noreferrer noopener">{{ 'CorePluginsAdmin_TagManagerLearnMoreInUserGuide'|translate }}</a>
+ </div>
+ </div>
+ {% endif %}
+ </div>
+ {{ actionBlock|raw }}
+</div>
+{% endblock %}
diff --git a/plugins/CorePluginsAdmin/tests/Integration/TagManagerTeaserTest.php b/plugins/CorePluginsAdmin/tests/Integration/TagManagerTeaserTest.php
new file mode 100644
index 0000000000..7b28bf339e
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/Integration/TagManagerTeaserTest.php
@@ -0,0 +1,106 @@
+<?php
+/**
+ * Matomo - free/libre analytics platform
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Plugins\CorePluginsAdmin\tests\Integration;
+
+use Piwik\Plugin;
+use Piwik\Plugins\CorePluginsAdmin\Model\TagManagerTeaser;
+use Piwik\Tests\Framework\TestCase\IntegrationTestCase;
+
+/**
+ * @group CorePluginsAdmin
+ * @group ApiTest
+ * @group Api
+ * @group Plugins
+ */
+class TagManagerTeaserTest extends IntegrationTestCase
+{
+ /**
+ * @var TagManagerTeaser
+ */
+ private $teaser;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ Plugin\Manager::getInstance()->deactivatePlugin('TagManager');
+
+ $this->teaser = $this->makeTeaser('mylogin');
+ }
+
+ private function makeTeaser($login)
+ {
+ return new TagManagerTeaser($login);
+ }
+
+ public function test_isEnabledGloballyByDefault()
+ {
+ $this->assertTrue($this->teaser->isEnabledGlobally());
+ }
+
+ public function test_disableGlobally()
+ {
+ $this->teaser->disableGlobally();
+ $this->assertFalse($this->teaser->isEnabledGlobally());
+ }
+
+ public function test_reset()
+ {
+ $this->teaser->disableGlobally();
+ $this->assertFalse($this->teaser->isEnabledGlobally());
+ $this->teaser->reset();
+ $this->assertTrue($this->teaser->isEnabledGlobally());
+ }
+
+ public function test_disableGlobally_removesUserSettings()
+ {
+ $this->teaser->disableForUser();
+ $this->assertFalse($this->teaser->isEnabledForUser());
+
+ $this->teaser->disableGlobally();
+
+ $this->assertFalse($this->teaser->isEnabledGlobally());
+ // should reset user enable flags cause disabled globally anyway
+ $this->assertTrue($this->teaser->isEnabledForUser());
+ }
+
+ public function test_isEnabledForCurrentUserByDefault()
+ {
+ $this->assertTrue($this->teaser->isEnabledForUser());
+ }
+
+ public function test_disableForUser()
+ {
+ $this->teaser->disableForUser();
+ $this->assertFalse($this->teaser->isEnabledForUser());
+
+ // still enabled globally
+ $this->assertTrue($this->teaser->isEnabledGlobally());
+
+ // still enabled for other user
+ $otherUser = $this->makeTeaser('foobar123');
+ $this->assertTrue($otherUser->isEnabledForUser());
+ }
+
+ public function test_shouldShowTeaser()
+ {
+ $this->assertTrue($this->teaser->shouldShowTeaser());
+ $this->assertTrue($this->teaser->isEnabledGlobally());
+ }
+
+ public function test_shouldShowTeaser_shouldNotBeShownWhenTagManagerEnabled()
+ {
+ Plugin\Manager::getInstance()->activatePlugin('TagManager');
+ $this->assertFalse($this->teaser->shouldShowTeaser());
+ // should have been disabled automatically
+ $this->assertFalse($this->teaser->isEnabledGlobally());
+ }
+
+
+}
diff --git a/plugins/CorePluginsAdmin/tests/UI/.gitignore b/plugins/CorePluginsAdmin/tests/UI/.gitignore
new file mode 100644
index 0000000000..f39be478e7
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/UI/.gitignore
@@ -0,0 +1,2 @@
+/processed-ui-screenshots
+/screenshot-diffs \ No newline at end of file
diff --git a/plugins/CorePluginsAdmin/tests/UI/TagManagerTeaser_spec.js b/plugins/CorePluginsAdmin/tests/UI/TagManagerTeaser_spec.js
new file mode 100644
index 0000000000..f892f42bed
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/UI/TagManagerTeaser_spec.js
@@ -0,0 +1,92 @@
+/*!
+ * Matomo - free/libre analytics platform
+ *
+ * Screenshot integration tests.
+ *
+ * @link https://matomo.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+describe("TagManagerTeaser", function () {
+ this.timeout(0);
+
+ var urlBase = '?module=CorePluginsAdmin&action=tagManagerTeaser&idSite=1&period=day&date=2010-01-03',
+ pageSelector = '.activateTagManager';
+
+ function setPluginsToLoad(plugins)
+ {
+ testEnvironment.pluginsToLoad = plugins
+ testEnvironment.save();
+ }
+
+ function unloadTagManager()
+ {
+ testEnvironment.unloadTagManager = 1;
+ testEnvironment.save();
+ }
+
+ function setAdminUser()
+ {
+ delete testEnvironment.idSitesViewAccess;
+ delete testEnvironment.idSitesWriteAccess;
+ testEnvironment.idSitesAdminAccess = [1];
+ testEnvironment.save();
+ }
+
+ function reset()
+ {
+ delete testEnvironment.idSitesViewAccess;
+ delete testEnvironment.idSitesWriteAccess;
+ delete testEnvironment.idSitesAdminAccess;
+ delete testEnvironment.idSitesCapabilities;
+ delete testEnvironment.unloadTagManager;
+ testEnvironment.save();
+ }
+
+ beforeEach(function () {
+ setPluginsToLoad(['CorePluginsAdmin']);
+ });
+
+ afterEach(reset);
+
+ function capturePage(done, screenshotName, test, selector)
+ {
+ if (!selector) {
+ selector = pageSelector;
+ }
+ expect.screenshot(screenshotName).to.be.captureSelector(selector, test, done);
+ }
+
+ it('should show teaser to super user', function (done) {
+ unloadTagManager();
+ capturePage(done, 'superuser_page', function (page) {
+ unloadTagManager();
+ page.load(urlBase);
+ });
+ });
+
+ it('should be possible to activate plugin and redirect to tag manager', function (done) {
+ capturePage(done, 'super_user_activate_plugin', function (page) {
+ page.click('.activateTagManager .activateTagManagerPlugin');
+ }, '.pageWrap');
+ });
+
+ it('should show teaser to admin', function (done) {
+ unloadTagManager();
+ setAdminUser();
+ capturePage(done, 'admin_page', function (page) {
+ unloadTagManager();
+ setAdminUser();
+ page.load(urlBase);
+ });
+ });
+
+ it('should be possible to disable page and redirect to home', function (done) {
+ capturePage(done, 'admin_page_disable', function (page) {
+ unloadTagManager();
+ setAdminUser();
+ page.click('.activateTagManager .dontShowAgainBtn');
+ }, '.pageWrap');
+ });
+
+}); \ No newline at end of file
diff --git a/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/.gitkeep b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/.gitkeep
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/.gitkeep
diff --git a/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page.png b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page.png
new file mode 100644
index 0000000000..73344efb78
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cd7ff984c4a1b5d341bdbf221f33f5ba0b82c4d65280f48a93ebd329c8412ae2
+size 156916
diff --git a/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page_disable.png b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page_disable.png
new file mode 100644
index 0000000000..caaeb7edee
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_admin_page_disable.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:72823683d6dcf3c3f423ca4519cfc33c9bc9166a31acde992a737b00bd9ddd2b
+size 142530
diff --git a/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_super_user_activate_plugin.png b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_super_user_activate_plugin.png
new file mode 100644
index 0000000000..7e962c324f
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_super_user_activate_plugin.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d4fcce39e90d28b3c78d311d50a546c7c6a30c52b028e4a3dce38daa4da395a0
+size 208986
diff --git a/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_superuser_page.png b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_superuser_page.png
new file mode 100644
index 0000000000..8a483e976d
--- /dev/null
+++ b/plugins/CorePluginsAdmin/tests/UI/expected-screenshots/TagManagerTeaser_superuser_page.png
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:0351e3a807ae93574d8d303a734a16b226bde1254929f8b3d9d11857f850a93e
+size 202635