Skip to content

Commit dd29cb2

Browse files
authored
Allow to star and unstar stored segment (#23771)
* Allow to start/unstar stored segment * Add micro-animation on star/unstar segment * Add tooltips on star/unstar segment depending on user rights + who starred a segment * Reviews tooltips content on all segment actions * Use button to improve a11y on all segment actions * Bugfix segment search - race condition on fast query change * Bugfix segment search - clean search special character again * Improve how the segment list and actions are displayed for anonymous users
1 parent cb03e40 commit dd29cb2

29 files changed

Lines changed: 658 additions & 176 deletions

ā€Žcore/Plugin/Controller.phpā€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ protected function setBasicVariablesNoneAdminView($view)
726726
{
727727
$view->clientSideConfig = PiwikConfig::getInstance()->getClientSideOptions();
728728
$view->isSuperUser = Access::getInstance()->hasSuperUserAccess();
729+
$view->userCurrentRole = Access::getInstance()->getRoleForSite($this->idSite);
729730
$view->hasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
730731
$view->hasSomeViewAccess = Piwik::isUserHasSomeViewAccess();
731732
$view->isUserIsAnonymous = Piwik::isUserIsAnonymous();

ā€Žcore/Updates/5.7.0-b1.phpā€Ž

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/**
4+
* Matomo - free/libre analytics platform
5+
*
6+
* @link https://matomo.org
7+
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
8+
*/
9+
10+
namespace Piwik\Updates;
11+
12+
use Piwik\Updater;
13+
use Piwik\Updater\Migration\Factory as MigrationFactory;
14+
use Piwik\Updates;
15+
16+
class Updates_5_7_0_b1 extends Updates
17+
{
18+
/**
19+
* @var MigrationFactory
20+
*/
21+
private $migration;
22+
23+
public function __construct(MigrationFactory $factory)
24+
{
25+
$this->migration = $factory;
26+
}
27+
28+
public function getMigrations(Updater $updater)
29+
{
30+
return [
31+
$this->migration->db->addColumns('segment', [
32+
'starred' => 'TINYINT(1) NOT NULL DEFAULT 0',
33+
'starred_by' => 'VARCHAR(100) NULL DEFAULT NULL',
34+
]),
35+
];
36+
}
37+
38+
public function doUpdate(Updater $updater)
39+
{
40+
$updater->executeMigrations(__FILE__, $this->getMigrations($updater));
41+
}
42+
}

ā€Žcore/Version.phpā€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class Version
2222
* The current Matomo version.
2323
* @var string
2424
*/
25-
public const VERSION = '5.7.0-alpha';
25+
public const VERSION = '5.7.0-b1';
2626

2727
public const MAJOR_VERSION = 5;
2828

ā€Žlang/en.jsonā€Ž

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@
2929
"BrokenDownReportDocumentation": "It is broken down into various reports, which are displayed in sparklines at the bottom of the page. You can enlarge the graphs by clicking on the report you'd like to see.",
3030
"Cancel": "Cancel",
3131
"CannotUnzipFile": "Cannot unzip file %1$s: %2$s",
32+
"CanNotEditGlobalSegment": "This is a global segment. Only super users can edit global segments.",
33+
"CanNotStarGlobalSegment": "This is a global segment. Only super users can star global segments.",
34+
"CanNotUnstarGlobalSegment": "This is a global segment. Only super users can unstar global segments.",
35+
"CanEditGlobalSegment": "This is a global segment. Any changes will apply across all websites.",
36+
"CanStarGlobalSegment": "This is a global segment. Adding to Starred will apply across all websites.",
37+
"CanUnstarGlobalSegment": "This is a global segment. Removing from Starred will apply across all websites.",
38+
"CanNotEditSiteSegment": "You can only edit the segments you created yourself.",
39+
"CanNotStarSiteSegment": "You can only add to Starred the segments you created yourself.",
40+
"CanNotUnstarSiteSegment": "You can only remove from Starred the segments you created yourself.",
41+
"CanEditSiteSegment": "Edit the segment for this website.",
42+
"CanStarSiteSegment": "Add to Starred segments for this website.",
43+
"CanUnstarSiteSegment": "Remove from Starred segments for this website.",
3244
"ChangeInX": "Change in %1$s",
3345
"ChangePassword": "Change password",
3446
"ChangeTagCloudView": "Please note, that you can view the report in other ways than as a tag cloud. Use the controls at the bottom of the report to do so.",
@@ -464,6 +476,9 @@
464476
"SmtpServerAddress": "SMTP server address",
465477
"SmtpUsername": "SMTP username",
466478
"Source": "Source",
479+
"Star": "Star",
480+
"StarredBy": "Starred by",
481+
"StarredByYou": "Starred by you",
467482
"StatisticsAreNotRecorded": "Matomo Visitor Tracking is currently disabled! Re-enable tracking by setting record_statistics = 1 in your config/config.ini.php file.",
468483
"Subtotal": "Subtotal",
469484
"Summary": "Summary",

ā€Žphpstan-baseline.neonā€Ž

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4658,11 +4658,6 @@ parameters:
46584658
count: 1
46594659
path: plugins/ScheduledReports/ScheduledReports.php
46604660

4661-
-
4662-
message: "#^Negated boolean expression is always true\\.$#"
4663-
count: 1
4664-
path: plugins/SegmentEditor/API.php
4665-
46664661
-
46674662
message: "#^Parameter \\#2 \\$idSites of class Piwik\\\\Segment constructor expects array, int\\|null given\\.$#"
46684663
count: 1

ā€Žplugins/CoreHome/vue/dist/CoreHome.umd.jsā€Ž

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ā€Žplugins/CoreHome/vue/dist/CoreHome.umd.min.jsā€Ž

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ā€Žplugins/CoreHome/vue/src/Comparisons/Comparisons.store.tsā€Ž

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,21 @@ export default class ComparisonsStore {
216216
);
217217
}
218218

219+
removeSegmentComparisonByDefinition(segmentDefinition: string): void {
220+
if (!this.isComparisonEnabled()) {
221+
throw new Error('Comparison disabled.');
222+
}
223+
let segmentIndex = null;
224+
this.getSegmentComparisons().forEach((segment: SegmentComparison, index: number) => {
225+
if (segment && segment.params && segment.params.segment === segmentDefinition) {
226+
segmentIndex = index;
227+
}
228+
});
229+
if (segmentIndex !== null) {
230+
this.removeSegmentComparison(segmentIndex);
231+
}
232+
}
233+
219234
addSegmentComparison(params: { [name: string]: string }): void {
220235
if (!this.isComparisonEnabled()) {
221236
throw new Error('Comparison disabled.');

ā€Žplugins/CoreVue/types/index.d.tsā€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ declare global {
171171
languageName: string;
172172
isPagesComparisonApiDisabled: boolean; // can be set to avoid checks on Api.getPagesComparisonsDisabledFor
173173
userLogin?: string;
174+
userCurrentRole: string;
175+
isUserAnonymous: boolean;
174176
userHasSomeAdminAccess: boolean;
175177
requiresPasswordConfirmation: boolean;
176178
disableTrackingMatomoAppLinks: boolean;

ā€Žplugins/Morpheus/templates/_jsGlobalVariables.twigā€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
6969
piwik.hasSuperUserAccess = {{ hasSuperUserAccess|default(0)|e('js')}};
7070
piwik.userHasSomeAdminAccess = {{ userHasSomeAdminAccess|json_encode|raw }};
71+
piwik.userCurrentRole = "{{ userCurrentRole|default('view')|e('js') }}";
72+
piwik.isUserIsAnonymous = {{ isUserIsAnonymous|default(0)|e('js') }};
7173
piwik.userCapabilities = {{ userCapabilities|default([])|json_encode|raw }};
7274
piwik.config = {};
7375
{% if clientSideConfig is defined %}

0 commit comments

Comments
Ā (0)
⚔