diff options
author | Tim-Hinnerk Heuer <tim@innocraft.com> | 2021-08-26 10:20:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-26 10:20:09 +0300 |
commit | 56ead715db5c7bdb5493240e5f5209021633bc1d (patch) | |
tree | 2fd831e7c2b4989129866ad5f98c3ed0247e644e /plugins | |
parent | e817313a4ddd80d8a8854481bd09964588295ca6 (diff) |
hide segmented reports are pre-processed (#17882)
* hide segmented reports are pre-processed
when enable_create_realtime_segments = 0
fixes #15036
* ensure static method because static call fixes #15036
* refactor to use SegmentEditor::isCreateRealtimeSegmentsEnabled() #15036
* hide segmented reports are pre-processed
when enable_create_realtime_segments = 0
fixes #15036
* ensure static method because static call fixes #15036
* update ui test for hidden segmented report text #15036
* add ui-test screenshot #15036
* wait for network #15036
* download processed screenshot #15036
Diffstat (limited to 'plugins')
6 files changed, 37 insertions, 9 deletions
diff --git a/plugins/SegmentEditor/API.php b/plugins/SegmentEditor/API.php index 08b648d781..05151ad03f 100644 --- a/plugins/SegmentEditor/API.php +++ b/plugins/SegmentEditor/API.php @@ -117,7 +117,7 @@ class API extends \Piwik\Plugin\API } // if real-time segments are disabled, then allow user to create pre-processed report - $realTimeSegmentsEnabled = Config::getInstance()->General['enable_create_realtime_segments']; + $realTimeSegmentsEnabled = SegmentEditor::isCreateRealtimeSegmentsEnabled(); if (!$realTimeSegmentsEnabled && !$autoArchive) { throw new Exception( "Real time segments are disabled. You need to enable auto archiving." diff --git a/plugins/SegmentEditor/SegmentEditor.php b/plugins/SegmentEditor/SegmentEditor.php index 3a8a830454..792b8e106d 100644 --- a/plugins/SegmentEditor/SegmentEditor.php +++ b/plugins/SegmentEditor/SegmentEditor.php @@ -316,6 +316,16 @@ class SegmentEditor extends \Piwik\Plugin return Config::getInstance()->General['allow_adding_segments_for_all_websites'] == 1; } + /** + * Returns whether create realtime segments is enabled or not. + * + * @return bool + */ + public static function isCreateRealtimeSegmentsEnabled(): bool + { + return Config::getInstance()->General['enable_create_realtime_segments'] == 1; + } + public function getClientSideTranslationKeys(&$translationKeys) { $translationKeys[] = 'SegmentEditor_CustomSegment'; diff --git a/plugins/SegmentEditor/SegmentSelectorControl.php b/plugins/SegmentEditor/SegmentSelectorControl.php index 6aec61c51f..ac32af6366 100644 --- a/plugins/SegmentEditor/SegmentSelectorControl.php +++ b/plugins/SegmentEditor/SegmentSelectorControl.php @@ -47,6 +47,7 @@ class SegmentSelectorControl extends UIControl $this->segmentDescription = $formatter->getHumanReadable(Request::getRawSegmentFromRequest(), $this->idSite); $this->isAddingSegmentsForAllWebsitesEnabled = SegmentEditor::isAddingSegmentsForAllWebsitesEnabled(); + $this->isCreateRealtimeSegmentsEnabled = SegmentEditor::isCreateRealtimeSegmentsEnabled(); $segments = APIMetadata::getInstance()->getSegmentsMetadata($this->idSite); diff --git a/plugins/SegmentEditor/templates/_segmentSelector.twig b/plugins/SegmentEditor/templates/_segmentSelector.twig index a4848a00b1..aa159ca94d 100644 --- a/plugins/SegmentEditor/templates/_segmentSelector.twig +++ b/plugins/SegmentEditor/templates/_segmentSelector.twig @@ -54,14 +54,18 @@ {% if isAddingSegmentsForAllWebsitesEnabled %}<option value="0">{{ 'SegmentEditor_SegmentDisplayedAllWebsites'|translate }}</option>{% endif %} </select> </strong></div> - {{ 'General_And'|translate }} <div class="auto_archive"><strong> - <select class="auto_archive_select"> - {% if createRealTimeSegmentsIsEnabled %} - <option {% if isBrowserArchivingEnabled %}selected="1"{% endif%} value="0">{{ 'SegmentEditor_AutoArchiveRealTime'|translate }}</option> - {% endif %} - <option {% if not isBrowserArchivingEnabled or not createRealTimeSegmentsIsEnabled %}selected="1"{% endif %} value="1">{{ 'SegmentEditor_AutoArchivePreProcessed'|translate }} </option> - </select> - </strong></div> + {% if isCreateRealtimeSegmentsEnabled %} + {{ 'General_And'|translate }} + <div class="auto_archive"><strong> + <select class="auto_archive_select"> + {% if createRealTimeSegmentsIsEnabled %} + <option {% if isBrowserArchivingEnabled %}selected="1"{% endif%} value="0">{{ 'SegmentEditor_AutoArchiveRealTime'|translate }}</option> + {% endif %} + <option {% if not isBrowserArchivingEnabled or not createRealTimeSegmentsIsEnabled %}selected="1"{% endif %} value="1">{{ 'SegmentEditor_AutoArchivePreProcessed'|translate }} </option> + </select> + </strong> + </div> + {% endif %} </div> <h3 style="margin: 12px 6px;">{{ 'General_Name'|translate }}: <span class="segmentName"></span> <a class="editSegmentName" href="#">{{ 'General_Edit'|translate|lower }}</a></h3> diff --git a/plugins/SegmentEditor/tests/UI/SegmentSelectorEditor_spec.js b/plugins/SegmentEditor/tests/UI/SegmentSelectorEditor_spec.js index a61bd0db2a..2847220768 100644 --- a/plugins/SegmentEditor/tests/UI/SegmentSelectorEditor_spec.js +++ b/plugins/SegmentEditor/tests/UI/SegmentSelectorEditor_spec.js @@ -283,4 +283,14 @@ describe("SegmentSelectorEditorTest", function () { expect(await page.screenshot()).to.matchImage('complex_segment'); }); + + it('should not show "AND segmented reports are pre-processed (faster, requires cron)" when enable_create_realtime_segments = 0', async () => { + testEnvironment.overrideConfig('General', 'enable_create_realtime_segments', 0); + testEnvironment.save(); + await page.goto(url); + await page.click('.segmentationContainer .title'); + await page.click('.add_new_segment'); + await page.waitForNetworkIdle(); + expect(await page.screenshotSelector(selectorsToCapture)).to.matchImage('enabled_create_realtime_segments'); + }); }); diff --git a/plugins/SegmentEditor/tests/UI/expected-screenshots/SegmentSelectorEditorTest_enabled_create_realtime_segments.png b/plugins/SegmentEditor/tests/UI/expected-screenshots/SegmentSelectorEditorTest_enabled_create_realtime_segments.png new file mode 100644 index 0000000000..e963fbb338 --- /dev/null +++ b/plugins/SegmentEditor/tests/UI/expected-screenshots/SegmentSelectorEditorTest_enabled_create_realtime_segments.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1e7fb81540efa149807a564a0d1633527a4c50d5d60381f5977b550d372286ad +size 30024 |