Skip to content

Commit

Permalink
Merge branch '5.x-dev' into dev-13900
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkleiner committed Dec 20, 2024
2 parents 7585e39 + f0dab35 commit 855edcc
Show file tree
Hide file tree
Showing 33 changed files with 1,842 additions and 177 deletions.
8 changes: 4 additions & 4 deletions core/Updates/5.2.0-b6.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ public function __construct(MigrationFactory $factory)

public function getMigrations(Updater $updater)
{
$startOfCurrentYear = Date::now()->toString('Y') . '-01-01';
$startOfCurrentMonth = Date::now()->toString('Y-m') . '-01';

$commandToExecute = sprintf(
'./console core:invalidate-report-data --dates=%s,today --plugin=Actions.Actions_hits',
$startOfCurrentYear
$startOfCurrentMonth
);

$migrations = [
new CustomMigration(function () use ($startOfCurrentYear) {
new CustomMigration(function () use ($startOfCurrentMonth) {
$invalidator = StaticContainer::get(ArchiveInvalidator::class);
$invalidator->scheduleReArchiving('all', 'Actions', 'Actions_hits', Date::factory($startOfCurrentYear));
$invalidator->scheduleReArchiving('all', 'Actions', 'Actions_hits', Date::factory($startOfCurrentMonth));
}, $commandToExecute)
];

Expand Down
7 changes: 7 additions & 0 deletions plugins/CorePluginsAdmin/SettingsMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class SettingsMetadata
{
public const PASSWORD_PLACEHOLDER = '******';

public const EMPTY_ARRAY = '__empty__';

/**
* @param Settings[] $settingsInstances
* @param array $settingValues array('pluginName' => array('settingName' => 'settingValue'))
Expand All @@ -34,6 +36,11 @@ public function setPluginSettings($settingsInstances, $settingValues)

$fieldConfig = $setting->configureField();

// empty arrays are sent as __empty__ value, so we need to convert it here back to an array
if ($setting->getType() === FieldConfig::TYPE_ARRAY && $value === self::EMPTY_ARRAY) {
$value = [];
}

if (
isset($value) && (
$fieldConfig->uiControl !== FieldConfig::UI_CONTROL_PASSWORD ||
Expand Down
26 changes: 26 additions & 0 deletions plugins/CorePluginsAdmin/tests/Integration/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class ApiTest extends IntegrationTestCase
],
];

private $testSystemSettingsEmptyValuePayload = [
'ExampleSettingsPlugin' => [
['name' => 'browsers', 'value' => '__empty__'],
],
];

protected static function beforeTableDataCached()
{
parent::beforeTableDataCached();
Expand Down Expand Up @@ -113,6 +119,26 @@ public function testGetSystemSettingsRedactsPasswordValues()
self::assertTrue(password_verify('newPassword', $pluginSettings->getSetting('password')->getValue()));
}

public function testSetSystemSettingsCorrectlySetsEmptyValue()
{
$pluginSettings = StaticContainer::get(\Piwik\Plugins\ExampleSettingsPlugin\SystemSettings::class);
$settings = $this->getPluginSettings('ExampleSettingsPlugin', 'browsers');
$defaultValue = ['firefox', 'chromium', 'safari'];

self::assertEquals('browsers', $settings['name']);
self::assertEquals($defaultValue, $settings['value']);
self::assertEquals($defaultValue, $pluginSettings->getSetting('browsers')->getValue());

$settingValues = $this->testSystemSettingsEmptyValuePayload;
\Piwik\Plugins\CorePluginsAdmin\API::getInstance()->setSystemSettings($settingValues, self::TEST_PASSWORD);

$newSettings = $this->getPluginSettings('ExampleSettingsPlugin', 'browsers');

self::assertEquals('browsers', $newSettings['name']);
self::assertEquals([], $newSettings['value']);
self::assertEquals([], $pluginSettings->getSetting('browsers')->getValue());
}

private function getPluginSettings(string $pluginName, string $settingName): array
{
$settings = \Piwik\Plugins\CorePluginsAdmin\API::getInstance()->getSystemSettings();
Expand Down
32 changes: 18 additions & 14 deletions plugins/CorePluginsAdmin/vue/dist/CorePluginsAdmin.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ export default defineComponent({
postValue = '1';
}

if (Array.isArray(postValue) && postValue.length === 0) {
postValue = '__empty__';
}

values[pluginName].push({
name: settingName,
value: postValue,
Expand Down
1 change: 1 addition & 0 deletions plugins/MultiSites/MultiSites.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public function getClientSideTranslationKeys(&$translations)
$translations[] = 'MultiSites_TotalHits';
$translations[] = 'MultiSites_TotalPageviews';
$translations[] = 'MultiSites_TotalVisits';
$translations[] = 'MultiSites_AllWebsitesDashboardErrorMessage';
}

public function getStylesheetFiles(&$stylesheets)
Expand Down
3 changes: 3 additions & 0 deletions plugins/MultiSites/images/kpi_divider_horizontal.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions plugins/MultiSites/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"SingleWebsitesDashboardDocumentation": "This report gives you an informational overview for a specific website, containing the most general metrics about your visitors.",
"AllWebsitesDashboardDocumentation": "This report gives you an informational overview for each of your websites, containing the most general metrics about your visitors.",
"AllWebsitesDashboardTitle": "All Websites",
"AllWebsitesDashboardErrorMessage": "Data is currently unavailable. This could be due to a temporary server issue or the report containing too much data. Please try again later. If the problem continues, please contact your Matomo administrator for assistance.",
"EvolutionComparisonIncomplete": "The currently selected time period is %1$s complete.",
"EvolutionComparisonProportional": "When the previous period was also %1$s complete, there would have been an estimated %2$s %3$s\n(out of a total of %4$s %3$s in the previous period).",
"EvolutionComparisonDay": "%1$s %2$s this day compared to %3$s %2$s in the previous partial period (%4$s) Evolution: %5$s",
Expand Down
63 changes: 63 additions & 0 deletions plugins/MultiSites/tests/UI/AllWebsitesDashboard_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,67 @@ describe('AllWebsitesDashboard', function () {
expect(await page.screenshotSelector('#main')).to.matchImage('evolution_change');
});
});

describe('Responsive View', function () {
this.title = parentSuite.title; // to make sure the screenshot prefix is the same

it('should display correctly in tablet view', async function () {
await page.webpage.setViewport({ width: 768, height: 1024 });
await page.goto(dashboardUrl);
await page.waitForNetworkIdle();

await page.evaluate(() => {
window.CoreHome.Matomo.on('MultiSites.DashboardKPIs.updated', function(data) {
data.kpis.badges.hits = '<strong>Plan:</strong> 600K hits/month';
data.kpis.badges.pageviews = 'Weird Pageview Badge';
data.kpis.badges.revenue = 'Awesome Revenue Badge';
data.kpis.badges.visits = 'Terrific Visits Badge';
})
});

// change period to trigger reload of KPIS
await page.click('.move-period-prev');
await page.click('.move-period-next');
await page.waitForNetworkIdle();

expect(await page.screenshotSelector('#main')).to.matchImage('dashboard_tablet');
});

it('should display correctly in mobile view', async function () {
await page.webpage.setViewport({ width: 352, height: 1024 });

expect(await page.screenshotSelector('#main')).to.matchImage('dashboard_mobile');
});

it('should display correctly in tablet view without revenue', async function () {
testEnvironment.pluginsToUnload = ['Goals'];
testEnvironment.save();

await page.webpage.setViewport({ width: 768, height: 1024 });
await page.goto(dashboardUrl);
await page.waitForNetworkIdle();

await page.evaluate(() => {
window.CoreHome.Matomo.on('MultiSites.DashboardKPIs.updated', function(data) {
data.kpis.badges.hits = '<strong>Plan:</strong> 600K hits/month';
data.kpis.badges.pageviews = 'Weird Pageview Badge';
data.kpis.badges.revenue = 'Awesome Revenue Badge';
data.kpis.badges.visits = 'Terrific Visits Badge';
})
});

// change period to trigger reload of KPIS
await page.click('.move-period-prev');
await page.click('.move-period-next');
await page.waitForNetworkIdle();

expect(await page.screenshotSelector('#main')).to.matchImage('dashboard_tablet_no_revenue');
});

it('should display correctly in mobile view without revenue', async function () {
await page.webpage.setViewport({ width: 352, height: 1024 });

expect(await page.screenshotSelector('#main')).to.matchImage('dashboard_mobile_no_revenue');
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 855edcc

Please sign in to comment.