diff options
author | Tim-Hinnerk Heuer <tim@innocraft.com> | 2021-09-04 10:20:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-04 10:20:24 +0300 |
commit | 5d5e630e06b7941d22fc338ee964e30f06ad74af (patch) | |
tree | b18d74e10e3467c7604e64b62b81ba471e55e6ce | |
parent | 7e0b0e602068a558a84f1e16fde5e7e6cb0b7fa4 (diff) |
show users more informative information on error (#17900)
* show users more informative information on error
fixes #15135
* add rel="noreferrer noopener" #15135
* show faq section only outside of cloud #15036
* privatise variables
contributing to View::showMoreFaqInfo #15135
Co-authored-by: Stefan Giehl <stefan@matomo.org>
-rw-r--r-- | core/Config.php | 6 | ||||
-rw-r--r-- | core/View.php | 9 | ||||
-rw-r--r-- | lang/en.json | 1 | ||||
-rw-r--r-- | plugins/CoreHome/CoreHome.php | 1 | ||||
-rw-r--r-- | plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.html | 1 | ||||
-rw-r--r-- | plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.js | 8 | ||||
-rw-r--r-- | plugins/CoreHome/templates/_indexContent.twig | 2 | ||||
-rw-r--r-- | plugins/CoreHome/templates/getDefaultIndexView.twig | 2 | ||||
-rw-r--r-- | plugins/Morpheus/templates/admin.twig | 2 | ||||
-rw-r--r-- | plugins/Morpheus/templates/ajaxMacros.twig | 4 |
10 files changed, 29 insertions, 7 deletions
diff --git a/core/Config.php b/core/Config.php index f1230fd223..aad607e0c3 100644 --- a/core/Config.php +++ b/core/Config.php @@ -13,6 +13,8 @@ use Exception; use Piwik\Application\Kernel\GlobalSettingsProvider; use Piwik\Container\StaticContainer; use Piwik\Exception\MissingFilePermissionException; +use Piwik\Plugins\CoreAdminHome\Controller; +use Piwik\Plugins\CorePluginsAdmin\CorePluginsAdmin; use Piwik\ProfessionalServices\Advertising; /** @@ -183,10 +185,12 @@ class Config return array( 'action_url_category_delimiter' => $general['action_url_category_delimiter'], 'action_title_category_delimiter' => $general['action_title_category_delimiter'], + 'are_ads_enabled' => Advertising::isAdsEnabledInConfig($general), 'autocomplete_min_sites' => $general['autocomplete_min_sites'], 'datatable_export_range_as_day' => $general['datatable_export_range_as_day'], 'datatable_row_limits' => $this->getDatatableRowLimits(), - 'are_ads_enabled' => Advertising::isAdsEnabledInConfig($general) + 'enable_general_settings_admin' => Controller::isGeneralSettingsAdminEnabled(), + 'enable_plugins_admin' => CorePluginsAdmin::isPluginsAdminEnabled(), ); } diff --git a/core/View.php b/core/View.php index 36596e9997..c5c3b14899 100644 --- a/core/View.php +++ b/core/View.php @@ -11,11 +11,11 @@ namespace Piwik; use Exception; use Piwik\AssetManager\UIAssetCacheBuster; use Piwik\Container\StaticContainer; -use Piwik\Session\SessionAuth; +use Piwik\Plugins\CoreAdminHome\Controller; +use Piwik\Plugins\CorePluginsAdmin\CorePluginsAdmin; use Piwik\View\ViewInterface; use Piwik\View\SecurityPolicy; use Twig\Environment; -use Twig\Error\Error; /** * Transition for pre-Piwik 0.4.4 @@ -153,6 +153,11 @@ class View implements ViewInterface $this->piwik_version = Version::VERSION; $this->userLogin = Piwik::getCurrentUserLogin(); $this->isSuperUser = Access::getInstance()->hasSuperUserAccess(); + // following is used in ajaxMacros called macro (showMoreHelp as passed in other templates) - requestErrorDiv + $isGeneralSettingsAdminEnabled = Controller::isGeneralSettingsAdminEnabled(); + $isPluginsAdminEnabled = CorePluginsAdmin::isPluginsAdminEnabled(); + // simplify template usage + $this->showMoreFaqInfo = $this->isSuperUser && ($isGeneralSettingsAdminEnabled || $isPluginsAdminEnabled); try { $this->piwikUrl = SettingsPiwik::getPiwikUrl(); diff --git a/lang/en.json b/lang/en.json index 3775c7b320..5c0406fed4 100644 --- a/lang/en.json +++ b/lang/en.json @@ -171,6 +171,7 @@ "EncryptedSmtpTransport": "Enter the transport layer encryption required by your SMTP server.", "Error": "Error", "ErrorRequest": "Oops… there was a problem during the request. Maybe the server had a temporary issue, or maybe you requested a report with too much data. Please try again. If this error occurs repeatedly please %1$scontact your Matomo administrator%2$s for assistance.", + "ErrorRequestFaqLink": "See the steps to resolve this issue in the FAQ.", "Errors": "Errors", "EvolutionOverPeriod": "Evolution over the period", "EvolutionSummaryGeneric": "%1$s in %2$s compared to %3$s in %4$s. Evolution: %5$s", diff --git a/plugins/CoreHome/CoreHome.php b/plugins/CoreHome/CoreHome.php index 332538fcff..120ecf5b3c 100644 --- a/plugins/CoreHome/CoreHome.php +++ b/plugins/CoreHome/CoreHome.php @@ -438,6 +438,7 @@ class CoreHome extends \Piwik\Plugin $translationKeys[] = 'General_LoadingData'; $translationKeys[] = 'General_Error'; $translationKeys[] = 'General_ErrorRequest'; + $translationKeys[] = 'General_ErrorRequestFaqLink'; $translationKeys[] = 'General_YourChangesHaveBeenSaved'; $translationKeys[] = 'General_LearnMore'; $translationKeys[] = 'General_ChooseDate'; diff --git a/plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.html b/plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.html index 0146d0fb56..c29f0bbbd1 100644 --- a/plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.html +++ b/plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.html @@ -6,6 +6,7 @@ <div class="notification system notification-error"> {{ 'General_ErrorRequest'|translate:(''):('') }} + <ng-bind-html ng-bind-html="errorFaqLink"></ng-bind-html> </div> </div> diff --git a/plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.js b/plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.js index 4614f01bbf..a9812701bc 100644 --- a/plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.js +++ b/plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.js @@ -22,6 +22,8 @@ piwikWidgetLoader.$inject = ['piwik', 'piwikUrl', '$http', '$compile', '$q', '$location', 'notifications', '$rootScope', '$timeout', 'piwikComparisonsService']; function piwikWidgetLoader(piwik, piwikUrl, $http, $compile, $q, $location, notifications, $rootScope, $timeout, piwikComparisonsService){ + var isGeneralSettingsAdminEnabled = piwik.config['enable_general_settings_admin']; + var isPluginsAdminEnabled = piwik.config['enable_plugins_admin']; return { restrict: 'A', transclude: true, @@ -35,6 +37,12 @@ return function (scope, element, attrs, ngModel) { scope.widgetName = attrs.widgetName; + if (piwik.hasSuperUserAccess && (isGeneralSettingsAdminEnabled || isPluginsAdminEnabled)) { + scope.errorFaqLink = '<a rel="noreferrer noopener" target="_blank" href="https://matomo.org/faq/troubleshooting/faq_19489/">' + + _pk_translate('General_ErrorRequestFaqLink') + '</a>'; + } else { + scope.errorFaqLink = ''; + } if (!attrs.widgetName) { scope.loadingMessage = _pk_translate('General_LoadingData'); diff --git a/plugins/CoreHome/templates/_indexContent.twig b/plugins/CoreHome/templates/_indexContent.twig index 671c26e782..34ec6d0d7f 100644 --- a/plugins/CoreHome/templates/_indexContent.twig +++ b/plugins/CoreHome/templates/_indexContent.twig @@ -7,7 +7,7 @@ {{ postEvent("Template.nextToCalendar") }} {% render dashboardSettingsControl %} {% include "@CoreHome/_headerMessage.twig" %} - {{ ajax.requestErrorDiv(emailSuperUser|default('')) }} + {{ ajax.requestErrorDiv(emailSuperUser|default(''), false, '', showMoreFaqInfo) }} </div> {{ ajax.loadingDiv() }} diff --git a/plugins/CoreHome/templates/getDefaultIndexView.twig b/plugins/CoreHome/templates/getDefaultIndexView.twig index f5626eeda2..8d61b91b96 100644 --- a/plugins/CoreHome/templates/getDefaultIndexView.twig +++ b/plugins/CoreHome/templates/getDefaultIndexView.twig @@ -10,7 +10,7 @@ {% endblock %} {% block content %} - {{ ajax.requestErrorDiv(emailSuperUser|default(''), areAdsForProfessionalServicesEnabled, currentModule) }} + {{ ajax.requestErrorDiv(emailSuperUser|default(''), areAdsForProfessionalServicesEnabled, currentModule, showMoreFaqInfo) }} {{ ajax.loadingDiv() }} <div id="content" class="home"> diff --git a/plugins/Morpheus/templates/admin.twig b/plugins/Morpheus/templates/admin.twig index 26adf951ff..02167cdde6 100644 --- a/plugins/Morpheus/templates/admin.twig +++ b/plugins/Morpheus/templates/admin.twig @@ -27,7 +27,7 @@ </div> {% import 'ajaxMacros.twig' as ajax %} - {{ ajax.requestErrorDiv(emailSuperUser|default(''), areAdsForProfessionalServicesEnabled, currentModule) }} + {{ ajax.requestErrorDiv(emailSuperUser|default(''), areAdsForProfessionalServicesEnabled, currentModule, showMoreFaqInfo) }} {{ postEvent("Template.beforeContent", "admin", currentModule, currentAction) }} <div class="page"> diff --git a/plugins/Morpheus/templates/ajaxMacros.twig b/plugins/Morpheus/templates/ajaxMacros.twig index da40e5bf91..79eda2d30d 100644 --- a/plugins/Morpheus/templates/ajaxMacros.twig +++ b/plugins/Morpheus/templates/ajaxMacros.twig @@ -13,7 +13,7 @@ </div> {% endmacro %} -{% macro requestErrorDiv(emailSuperUser, areAdsForProfessionalServicesEnabled = false, currentModule = '') %} +{% macro requestErrorDiv(emailSuperUser, areAdsForProfessionalServicesEnabled = false, currentModule = '', showMoreHelp = false) %} <div id="loadingError"> <div class="alert alert-danger"> @@ -26,7 +26,9 @@ <br /><br /> {{ 'General_NeedMoreHelp'|translate }} + {% if showMoreHelp %} <a rel="noreferrer noopener" target="_blank" href="https://matomo.org/faq/troubleshooting/faq_19489/">{{ 'General_Faq'|translate }}</a> – + {% endif %} <a rel="noreferrer noopener" target="_blank" href="https://forum.matomo.org/">{{ 'Feedback_CommunityHelp'|translate }}</a> {%- if areAdsForProfessionalServicesEnabled %} |