From b5992a8a2b295627a3b5d1ccd2b0dc6cba248c57 Mon Sep 17 00:00:00 2001 From: Lani Field Date: Thu, 18 Jun 2020 17:54:26 +1200 Subject: [PATCH 01/24] feat: Add site config extension. - add boolean to indicate if display should be disabled - add tab with checkbox in settings panel to provide override value --- src/Extensions/EnvBarSiteConfigExtension.php | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/Extensions/EnvBarSiteConfigExtension.php diff --git a/src/Extensions/EnvBarSiteConfigExtension.php b/src/Extensions/EnvBarSiteConfigExtension.php new file mode 100644 index 0000000..2a03bad --- /dev/null +++ b/src/Extensions/EnvBarSiteConfigExtension.php @@ -0,0 +1,48 @@ + + * @version 1.1.0 + * @package Signify\EnvBar\Extensions + */ +class EnvBarSiteConfigExtension extends DataExtension +{ + /** + * Add override column to SiteConfig db record. + * + * @var string[] + */ + private static $db = [ + 'EnvBarOverride' => 'Boolean', + ]; + + /** + * Add Checkbox field for override value to new Environment Indicator tab + * in CMS Settings. + * + * @param FieldList $fields + * @return void + * @throws BadMethodCallException + */ + public function updateCMSFields(FieldList $fields) + { + $fields->addFieldsToTab('Root.EnvironmentIndicator', [ + CheckboxField::create( + 'EnvBarOverride', + 'Tick to turn off the environment indicator bar displayed by default' + ), + ]); + } +} From e3d6074854da5010bb9ec1e1e1bed716cdf9eb96 Mon Sep 17 00:00:00 2001 From: Lani Field Date: Thu, 18 Jun 2020 17:58:28 +1200 Subject: [PATCH 02/24] feat: Add yml to apply site config extension. --- _config/environmentindicatorconfig.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/_config/environmentindicatorconfig.yml b/_config/environmentindicatorconfig.yml index 4ddf89f..60130d8 100644 --- a/_config/environmentindicatorconfig.yml +++ b/_config/environmentindicatorconfig.yml @@ -9,4 +9,7 @@ After: "framework/*, cms/*" --- SilverStripe\CMS\Controllers\ContentController: extensions: - - Signify\EnvBar\Extensions\EnvBarExtension \ No newline at end of file + - Signify\EnvBar\Extensions\EnvBarExtension +SilverStripe\SiteConfig\SiteConfig: + extensions: + - Signify\EnvBar\Extensions\EnvBarSiteConfigExtension \ No newline at end of file From 91932a7498a12579afc2164e63f97acb79c661bc Mon Sep 17 00:00:00 2001 From: Lani Field Date: Thu, 18 Jun 2020 17:59:08 +1200 Subject: [PATCH 03/24] feat: Modify afterCallActionHandler function. - add condition to check for site config override and return original html without insertion of EnvBar if true --- src/Extensions/EnvBarExtension.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Extensions/EnvBarExtension.php b/src/Extensions/EnvBarExtension.php index b956fc9..732f134 100644 --- a/src/Extensions/EnvBarExtension.php +++ b/src/Extensions/EnvBarExtension.php @@ -7,6 +7,7 @@ use SilverStripe\ORM\FieldType\DBHTMLText; use SilverStripe\Security\Permission; use SilverStripe\Security\Security; +use SilverStripe\SiteConfig\SiteConfig; use SilverStripe\Versioned\Versioned; use SilverStripe\View\Requirements; @@ -60,6 +61,9 @@ public function afterCallActionHandler($request, $action, $result) if (!($result instanceof DBHTMLText)) { return $result; } + if (SiteConfig::current_site_config()->EnvBarOverride) { + return $result; + } $html = $result->getValue(); $envBar = $this->generateEnvBar()->getValue(); $html = preg_replace( From 0af768f15c5ae0d9247fa2a72898f5782cf9dd28 Mon Sep 17 00:00:00 2001 From: Lani Field Date: Thu, 18 Jun 2020 19:35:11 +1200 Subject: [PATCH 04/24] style: Reword EnvBarOverride field label. --- src/Extensions/EnvBarSiteConfigExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Extensions/EnvBarSiteConfigExtension.php b/src/Extensions/EnvBarSiteConfigExtension.php index 2a03bad..b6c4612 100644 --- a/src/Extensions/EnvBarSiteConfigExtension.php +++ b/src/Extensions/EnvBarSiteConfigExtension.php @@ -41,7 +41,7 @@ public function updateCMSFields(FieldList $fields) $fields->addFieldsToTab('Root.EnvironmentIndicator', [ CheckboxField::create( 'EnvBarOverride', - 'Tick to turn off the environment indicator bar displayed by default' + 'Tick to turn off the environment indicator bar' ), ]); } From c7719f1079b3357c92a00d0477de89ffdd60562a Mon Sep 17 00:00:00 2001 From: Lani Field Date: Thu, 18 Jun 2020 19:36:29 +1200 Subject: [PATCH 05/24] feat: Add disable_auto_insert config variable check and $EnvBar template variable. - allow developer to configure to fit themes where the auto insert would be inappropriate --- src/Extensions/EnvBarExtension.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Extensions/EnvBarExtension.php b/src/Extensions/EnvBarExtension.php index 732f134..8e7985e 100644 --- a/src/Extensions/EnvBarExtension.php +++ b/src/Extensions/EnvBarExtension.php @@ -3,6 +3,7 @@ namespace Signify\EnvBar\Extensions; use SilverStripe\Control\Director; +use SilverStripe\Core\Config\Config; use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\FieldType\DBHTMLText; use SilverStripe\Security\Permission; @@ -64,6 +65,9 @@ public function afterCallActionHandler($request, $action, $result) if (SiteConfig::current_site_config()->EnvBarOverride) { return $result; } + if (Config::inst()->get(__CLASS__, 'disable_auto_insert')) { + return $result; + } $html = $result->getValue(); $envBar = $this->generateEnvBar()->getValue(); $html = preg_replace( @@ -125,6 +129,21 @@ public function getCanAccess() } } + /** + * Get EnvBar html as a template variable. + * + * @return DBHTMLText + */ + public function getEnvBar() + { + if ( + Config::inst()->get(__CLASS__, 'disable_auto_insert') + && !(SiteConfig::current_site_config()->EnvBarOverride) + ) { + return $this->generateEnvBar(); + } + } + /** * Generate the HTML to inject using the EnvBar.ss template. * From 8315c4f3a96487759d5c887f2fe02c534d0ce4a4 Mon Sep 17 00:00:00 2001 From: Lani Field Date: Thu, 18 Jun 2020 19:39:20 +1200 Subject: [PATCH 06/24] docs: Update documentation and changelog. - add usage instructions for CMS override setting - add developer instructions for yml configuration and template variable usage --- CHANGELOG.md | 11 +++++++++-- README.md | 20 +++++++++++++++++--- docs/en/img/Override_Setting.png | Bin 0 -> 14506 bytes 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 docs/en/img/Override_Setting.png diff --git a/CHANGELOG.md b/CHANGELOG.md index 466c55f..fb7729a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ # Changelog -1.0.0 (2020-02-03) -- Initial release \ No newline at end of file +1.1.0 (2020-06-18) +- Add override to settings to disable automatic frontend display +- Add yml config and template variable to enable developer repositioning + +1.0.0 (2020-05-26) +- Initial release + +(2020-02-03) +- Initial development \ No newline at end of file diff --git a/README.md b/README.md index b8e3c56..c3f9f0b 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,20 @@ __Composer:__ ## Documentation -No further configuration is required. +No further configuration is required, however customisation is optional. -Customisation can be achieved by editing the EnvBar.ss template or the envbar- .js and .css files. Functional tests are available in the tests directory. These will need to be updated if you modify the template. +### Developer + +To disable the automatic placement of the bar as the first element of the body (if, for example, you have a fixed notification bar in your theme design), please add the following to a yml file in your site _config directory: + +```yml +Signify\EnvBar\Extensions\EnvBarExtension: + disable_auto_insert: true +``` + +You can then use the template variable `$EnvBar` in a more suitable position (recommended placement is in the Page.ss file or an include that is visible sitewide). + +Customisation of the content and/or appearance can be achieved by editing the EnvBar.ss template or the envbar- .js and .css files. Functional tests are available in the tests directory. These will need to be updated if you modify the template. * [Changelog](CHANGELOG.md) * [Contributing](CONTRIBUTING.md) @@ -34,7 +45,10 @@ Customisation can be achieved by editing the EnvBar.ss template or the envbar- . ## Usage -This module performs an informative function only. No special usage instructions are available. +This module performs an informative function only. + +There is a setting in the CMS to disable the bar from being visible on the frontend. +![Override Setting](docs/en/img/Override Setting.png) ![Live Published Anonymous](docs/en/img/Live_Pub_Anon.png) ![Live Published Editor](docs/en/img/Live_Pub_Edit.png) diff --git a/docs/en/img/Override_Setting.png b/docs/en/img/Override_Setting.png new file mode 100644 index 0000000000000000000000000000000000000000..11b77a1475fcd295f5de34dfff64d0db5e28acda GIT binary patch literal 14506 zcmb_?cUV(hvo8puQdK~dY60n}R0&lP5Rl$OiGb7)dgx6>P>>>3dM}{`fe>0i>Ae#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D5=nG!h{N_f@z?{qUT zX8F6$L_m1me2Z19W^!<2Yp*W+Dc&G7rA+R}wa$8~$>%;^6(dWyYtc|HFFk`|PDmn} zMQtVpCsDRr16p@`MBZ_}#(+EeQRgW>pv2@Wp0{YgHw~hwyf6u!*kfTT9E6kw+GBG+ z)`*T-`Ja1VOn4TXI~z%yv7E7ObMm%vw@PXl>lnV!`XWk?A*n?of(JV}Bk6;<->iZn zV8(Q31+u}VW5SXWMw-`Dg{bPeNS{W{%3z^7=;A80iSCgdV#I|FZfc|hwPB@1SAkQ{S@nFQc zQGPeoEep$3^&p2{6>z1QZ!&2;8etMKzLr)eNKvxqpEP((AxU4_DF6>S*G|7P<|;|s zggBJSjVJolNJVS0;i*wzz^CCJ2{(RSj&1rnKw85bZdLT<2T2ThGcOFbD&aUYZ0R>g z1i(vi7HI&x^nb5MIyFy5_&Qj(@j! zXa9?BZW|vgIOQw+xXa@bX8^m<*Z63wNT>dT@zj;qKfZ{t`fJHwW;}i?e%dNLuAmq= znx0i0UF)G4_BnPpFvCejYSk=KNZ`pyPE97cuh@*;3h-wR69s!u(ocr!H47}s2LT>v`OLhx9Ewt& zy^-ACTKEbe3<4oNCRJKNdvE*DwegqEx;V!g5!Q_C`V^Mwc+r2|uRI0h(g3h2fVjTa zjYc7gtgAZ2&pz^9tCb@h z0x_EjxgZp=xPC`1YQtSnA)Hk_L*OcYXJ?MV*OF8_Pp;1Q*!{Fs5RjEa$a|bo&d*UM RS1(B^$f~?5e);yp{{jPq8<7A2 literal 0 HcmV?d00001 From cd967cb807e4486ef4f3b9fa39232d10e56d00f8 Mon Sep 17 00:00:00 2001 From: sig-lani <67132697+sig-lani@users.noreply.github.com> Date: Fri, 19 Jun 2020 17:02:52 +1200 Subject: [PATCH 07/24] Update README.md Fix link to Override Setting screenshot --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c3f9f0b..0fd5665 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Customisation of the content and/or appearance can be achieved by editing the En This module performs an informative function only. There is a setting in the CMS to disable the bar from being visible on the frontend. -![Override Setting](docs/en/img/Override Setting.png) +![Override Setting](docs/en/img/Override_Setting.png) ![Live Published Anonymous](docs/en/img/Live_Pub_Anon.png) ![Live Published Editor](docs/en/img/Live_Pub_Edit.png) From e2cbb18e30392ee320b385b6ab0d22773315ca84 Mon Sep 17 00:00:00 2001 From: Lani Field Date: Sun, 21 Jun 2020 15:33:26 +1200 Subject: [PATCH 08/24] Update EnvBarExtension.php documentation Modifies the documentation to use SilverStripe namespacing in params and returns. Also minor changes to formatting of doc blocks for stylistics preference. --- src/Extensions/EnvBarExtension.php | 48 +++++++++++++++++------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/Extensions/EnvBarExtension.php b/src/Extensions/EnvBarExtension.php index b956fc9..f5001ac 100644 --- a/src/Extensions/EnvBarExtension.php +++ b/src/Extensions/EnvBarExtension.php @@ -20,24 +20,25 @@ * and user access (member permissions) and returns values to populate the * EnvBar. * - * It also contains methods to modify the HTTPResponse before and after the - * @see SilverStripe\Control\RequestHandler inserting the CSS and HTML required - * to produce the EnvBar. + * It also contains methods to modify the @see SilverStripe\Control\HTTPResponse + * before and after the @see SilverStripe\Control\RequestHandler + * inserting the CSS and HTML required to produce the EnvBar. * * @package Signify\EnvBar\Extensions - * @author Lani Field - * @version 1.0.0 + * @author Lani Field + * @version 1.0.1 * - * @param HTTPRequest $request - * @return HTTPResponse $result with the EnvBar CSS and HTML inserted. + * @param SilverStripe\Control\HTTPRequest $request + * @return SilverStripe\Control\HTTPResponse $result + * with the EnvBar CSS and HTML inserted. */ class EnvBarExtension extends DataExtension { /** * Load the CSS requirement. * - * @param HTTPRequest $request - * @param string $action + * @param SilverStripe\Control\HTTPRequest $request + * @param string $action * @return void * @see SilverStripe\Control\RequestHandler::handleAction */ @@ -49,10 +50,12 @@ public function beforeCallActionHandler($request, $action) /** * Rewrite the HTML of the viewed page to insert the EnvBar. * - * @param HTTPRequest $request - * @param string $action - * @param DBHTMLText $result from the original RequestHandler - * @return HTTPResponse $result with the EnvBar CSS and HTML inserted + * @param SilverStripe\Control\HTTPRequest $request + * @param string $action + * @param SilverStripe\ORM\FieldType\DBHTMLText $result + * from the original RequestHandler + * @return SilverStripe\ORM\FieldType\DBHTMLText $result + * with the EnvBar HTML inserted * @see SilverStripe\Control\RequestHandler::handleAction */ public function afterCallActionHandler($request, $action, $result) @@ -74,8 +77,10 @@ public function afterCallActionHandler($request, $action, $result) /** * Check the environment type. * - * @return string "dev" if the site is in dev mode, "test" if the site is - * in test mode (e.g. QA or UAT), "live" otherwise (e.g. Production) + * @return string + * "dev" if the site is in dev mode, + * "test" if the site is in test mode (e.g. QA or UAT), + * "live" otherwise (e.g. Production) */ public function getEnvironment() { @@ -91,9 +96,10 @@ public function getEnvironment() /** * Check the version of the page being viewed. * - * @return string "published" if it is the current live version in this - * environment, "draft" if it is a modified or unpublished version, - * "not staged" otherwise + * @return string + * "published" if it is the current live version in this environment, + * "draft" if it is a modified or unpublished version, + * "not staged" otherwise */ public function getPageStatus() { @@ -109,7 +115,9 @@ public function getPageStatus() /** * Check whether CurrentUser has access to edit pages. * - * @return boolean "true" if the user can edit pages, "false" otherwise + * @return boolean + * "true" if the user can edit pages, + * "false" otherwise */ public function getCanAccess() { @@ -124,7 +132,7 @@ public function getCanAccess() /** * Generate the HTML to inject using the EnvBar.ss template. * - * @return DBHTMLText + * @return SilverStripe\ORM\FieldType\DBHTMLText */ private function generateEnvBar() { From 0d6a63ba4808f40cd2b5ccff6475100067be998a Mon Sep 17 00:00:00 2001 From: Lani Field Date: Sun, 21 Jun 2020 15:51:16 +1200 Subject: [PATCH 09/24] Update README.md Add Scrutinizer Code Quality badge. Remove codecov badge. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b8e3c56..de3f14d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Build Status](https://travis-ci.org/signify-nz/silverstripe-environmentindicator.svg?branch=master)](https://travis-ci.org/signify-nz/silverstripe-environmentindicator) -[![codecov](https://codecov.io/gh/signify-nz/silverstripe-environmentindicator/branch/master/graph/badge.svg)](https://codecov.io/gh/signify-nz/silverstripe-environmentindicator) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/signify-nz/silverstripe-environmentindicator/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/signify-nz/silverstripe-environmentindicator/?branch=master) # Environment Indicator From afc85c7b5db6d8dd311c25cbeaceebd51551e8b4 Mon Sep 17 00:00:00 2001 From: Lani Field Date: Sun, 21 Jun 2020 16:12:30 +1200 Subject: [PATCH 10/24] fix: Correct type issues in DocBlocks --- src/Extensions/EnvBarExtension.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Extensions/EnvBarExtension.php b/src/Extensions/EnvBarExtension.php index f5001ac..8ecd456 100644 --- a/src/Extensions/EnvBarExtension.php +++ b/src/Extensions/EnvBarExtension.php @@ -28,8 +28,8 @@ * @author Lani Field * @version 1.0.1 * - * @param SilverStripe\Control\HTTPRequest $request - * @return SilverStripe\Control\HTTPResponse $result + * @param \SilverStripe\Control\HTTPRequest $request + * @return \SilverStripe\Control\HTTPResponse $result * with the EnvBar CSS and HTML inserted. */ class EnvBarExtension extends DataExtension @@ -37,7 +37,7 @@ class EnvBarExtension extends DataExtension /** * Load the CSS requirement. * - * @param SilverStripe\Control\HTTPRequest $request + * @param \SilverStripe\Control\HTTPRequest $request * @param string $action * @return void * @see SilverStripe\Control\RequestHandler::handleAction @@ -50,11 +50,11 @@ public function beforeCallActionHandler($request, $action) /** * Rewrite the HTML of the viewed page to insert the EnvBar. * - * @param SilverStripe\Control\HTTPRequest $request + * @param \SilverStripe\Control\HTTPRequest $request * @param string $action - * @param SilverStripe\ORM\FieldType\DBHTMLText $result + * @param \SilverStripe\ORM\FieldType\DBHTMLText $result * from the original RequestHandler - * @return SilverStripe\ORM\FieldType\DBHTMLText $result + * @return \SilverStripe\ORM\FieldType\DBHTMLText $result * with the EnvBar HTML inserted * @see SilverStripe\Control\RequestHandler::handleAction */ @@ -132,7 +132,7 @@ public function getCanAccess() /** * Generate the HTML to inject using the EnvBar.ss template. * - * @return SilverStripe\ORM\FieldType\DBHTMLText + * @return \SilverStripe\ORM\FieldType\DBHTMLText */ private function generateEnvBar() { From 399f2a32e3d1e0da8495e08895c3f65a775e129e Mon Sep 17 00:00:00 2001 From: sig-lani <67132697+sig-lani@users.noreply.github.com> Date: Tue, 23 Jun 2020 17:20:45 +1200 Subject: [PATCH 11/24] fix: Remove whitespaces found at end of lines --- src/Extensions/EnvBarSiteConfigExtension.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Extensions/EnvBarSiteConfigExtension.php b/src/Extensions/EnvBarSiteConfigExtension.php index b6c4612..0e744ae 100644 --- a/src/Extensions/EnvBarSiteConfigExtension.php +++ b/src/Extensions/EnvBarSiteConfigExtension.php @@ -9,10 +9,10 @@ /** * Add override boolean to the site config settings - * @see SilverStripe\SiteConfig\SiteConfig + * @see SilverStripe\SiteConfig\SiteConfig * to allow CMS admin to disable automatic display of the Environment Indicator * bar on the frontend pages. - * + * * @author Lani Field * @version 1.1.0 * @package Signify\EnvBar\Extensions @@ -21,7 +21,7 @@ class EnvBarSiteConfigExtension extends DataExtension { /** * Add override column to SiteConfig db record. - * + * * @var string[] */ private static $db = [ @@ -31,10 +31,10 @@ class EnvBarSiteConfigExtension extends DataExtension /** * Add Checkbox field for override value to new Environment Indicator tab * in CMS Settings. - * - * @param FieldList $fields - * @return void - * @throws BadMethodCallException + * + * @param FieldList $fields + * @return void + * @throws BadMethodCallException */ public function updateCMSFields(FieldList $fields) { From 974173142cb8750b4911f7f3bf90d2164f0938dc Mon Sep 17 00:00:00 2001 From: sig-lani <67132697+sig-lani@users.noreply.github.com> Date: Tue, 23 Jun 2020 18:39:43 +1200 Subject: [PATCH 12/24] Update travis.yml Modify tests to better reflect current status of PHP and SilverStripe. Also loosen script to check tests directory (to allow for more unit tests to run in future). --- .travis.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3f9d86a..dbcb082 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,18 +6,27 @@ services: env: global: + - COMPOSER_ROOT_VERSION=4.3.x-dev - TRAVIS_NODE_VERSION="10" matrix: include: - - php: 5.6 - env: DB=MYSQL RECIPE_VERSION=4.3.x-dev PHPUNIT_TEST=1 - - php: 7.0 + - php: 7.1 env: DB=PGSQL RECIPE_VERSION=4.3.x-dev PHPUNIT_TEST=1 - php: 7.1 env: DB=MYSQL RECIPE_VERSION=4.3.x-dev PHPUNIT_TEST=1 PHPCS_TEST=1 + - php: 7.1 + env: DB=MYSQL RECIPE_VERSION=4.4.x-dev PHPUNIT_TEST=1 - php: 7.2 env: DB=PGSQL RECIPE_VERSION=4.4.x-dev PHPUNIT_TEST=1 + - php: 7.2 + env: DB=MYSQL RECIPE_VERSION=4.4.x-dev PHPUNIT_TEST=1 PHPCS_TEST=1 + - php: 7.2 + env: DB=MYSQL RECIPE_VERSION=4.5.x-dev PHPUNIT_TEST=1 + - php: 7.3 + env: DB=PGSQL RECIPE_VERSION=4.5.x-dev PHPUNIT_TEST=1 + - php: 7.3 + env: DB=MYSQL RECIPE_VERSION=4.5.x-dev PHPUNIT_TEST=1 PHPCS_TEST=1 - php: 7.3 env: DB=MYSQL RECIPE_VERSION=4.x-dev PHPUNIT_COVERAGE_TEST=1 @@ -30,11 +39,11 @@ before_script: - composer validate - composer require --no-update silverstripe/recipe-cms:"$RECIPE_VERSION" - - if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.1.x-dev; fi + - if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:^2 --no-update; fi - composer install --prefer-source --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile script: - - if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/EnvBarExtensionTest.php; fi + - if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/; fi - if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi - if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/ *.php; fi From 437f0d89c6c68e3d7dcd954beaf667f3c37c8a6e Mon Sep 17 00:00:00 2001 From: Lani Field Date: Fri, 10 Jul 2020 14:24:13 +1200 Subject: [PATCH 13/24] refactor: Modify site config field from EnvBarOverride to EnvBarDisplay --- src/Extensions/EnvBarExtension.php | 16 +++++++++------- src/Extensions/EnvBarSiteConfigExtension.php | 9 +++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Extensions/EnvBarExtension.php b/src/Extensions/EnvBarExtension.php index 8e7985e..42b5874 100644 --- a/src/Extensions/EnvBarExtension.php +++ b/src/Extensions/EnvBarExtension.php @@ -49,7 +49,8 @@ public function beforeCallActionHandler($request, $action) } /** - * Rewrite the HTML of the viewed page to insert the EnvBar. + * Rewrite the HTML of the viewed page to insert the EnvBar if the + * two conditions (display and auto-insert enabled) have been met. * * @param HTTPRequest $request * @param string $action @@ -59,15 +60,15 @@ public function beforeCallActionHandler($request, $action) */ public function afterCallActionHandler($request, $action, $result) { - if (!($result instanceof DBHTMLText)) { - return $result; - } - if (SiteConfig::current_site_config()->EnvBarOverride) { + // Check if display is turned on in the CMS + if (!SiteConfig::current_site_config()->EnvBarDisplay) { return $result; } + // Check if automatic placement has been turned off in a _config yml if (Config::inst()->get(__CLASS__, 'disable_auto_insert')) { return $result; } + $html = $result->getValue(); $envBar = $this->generateEnvBar()->getValue(); $html = preg_replace( @@ -76,6 +77,7 @@ public function afterCallActionHandler($request, $action, $result) $html ); $result->setValue($html); + return $result; } @@ -130,7 +132,7 @@ public function getCanAccess() } /** - * Get EnvBar html as a template variable. + * Get EnvBar HTML as a template variable. * * @return DBHTMLText */ @@ -138,7 +140,7 @@ public function getEnvBar() { if ( Config::inst()->get(__CLASS__, 'disable_auto_insert') - && !(SiteConfig::current_site_config()->EnvBarOverride) + && SiteConfig::current_site_config()->EnvBarDisplay ) { return $this->generateEnvBar(); } diff --git a/src/Extensions/EnvBarSiteConfigExtension.php b/src/Extensions/EnvBarSiteConfigExtension.php index 0e744ae..c8416a6 100644 --- a/src/Extensions/EnvBarSiteConfigExtension.php +++ b/src/Extensions/EnvBarSiteConfigExtension.php @@ -25,7 +25,7 @@ class EnvBarSiteConfigExtension extends DataExtension * @var string[] */ private static $db = [ - 'EnvBarOverride' => 'Boolean', + 'EnvBarDisplay' => 'Boolean', ]; /** @@ -40,9 +40,10 @@ public function updateCMSFields(FieldList $fields) { $fields->addFieldsToTab('Root.EnvironmentIndicator', [ CheckboxField::create( - 'EnvBarOverride', - 'Tick to turn off the environment indicator bar' - ), + 'EnvBarDisplay', + 'Display the environment indicator bar?' + )->setDescription('Check to show the environment indicator bar on' + . ' all pages being viewed in this environment.'), ]); } } From ef0e452256244ead6d2a4e49660d87fb23e9d40b Mon Sep 17 00:00:00 2001 From: Lani Field Date: Fri, 10 Jul 2020 14:28:08 +1200 Subject: [PATCH 14/24] test: Add tests for CMS display control functionality --- tests/EnvBarSiteConfigExtensionTest.php | 98 +++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 tests/EnvBarSiteConfigExtensionTest.php diff --git a/tests/EnvBarSiteConfigExtensionTest.php b/tests/EnvBarSiteConfigExtensionTest.php new file mode 100644 index 0000000..2f95168 --- /dev/null +++ b/tests/EnvBarSiteConfigExtensionTest.php @@ -0,0 +1,98 @@ +setField('EnvBarDisplay', 1); + + $url = $this->objFromFixture( + 'SilverStripe\CMS\Model\SiteTree', + 'default' + )->URLSegment; + + $user = $this->objFromFixture( + 'SilverStripe\Security\Member', + 'admin' + ); + + $this->EnvBarVisible( + $url, + $user + ); + } + + /** + * Test EnvBar NOT present when display is disabled in CMS + */ + public function testDisplayDisabled() + { + SiteConfig::current_site_config()->setField('EnvBarDisplay', 0); + + $url = $this->objFromFixture( + 'SilverStripe\CMS\Model\SiteTree', + 'default' + )->URLSegment; + + $user = $this->objFromFixture( + 'SilverStripe\Security\Member', + 'admin' + ); + + $this->EnvBarNotVisible( + $url, + $user + ); + } + + + /** + * Test EnvBar is present somewhere on page + */ + public function EnvBarVisible($url, $user) + { + if ($user) { + $this->logInAs($user); + } + $testPage = $this->get($url); + $this->assertContains( + '.page__envbar', + $testPage->getBody() + ); + if ($user) { + $this->logOut(); + } + } + + /** + * Test EnvBar is not injected into the page + */ + public function EnvBarNotVisible($url, $user) + { + if ($user) { + $this->logInAs($user); + } + $testPage = $this->get($url); + $this->assertNotContains( + '.page__envbar', + $testPage->getBody() + ); + if ($user) { + $this->logOut(); + } + } +} From 187f91a211215064adb68576037a0e05d6c7134d Mon Sep 17 00:00:00 2001 From: Lani Field Date: Fri, 10 Jul 2020 14:29:11 +1200 Subject: [PATCH 15/24] test: Modify list of tests run by travis --- .travis.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index dbcb082..56a54f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,28 +7,19 @@ services: env: global: - COMPOSER_ROOT_VERSION=4.3.x-dev - - TRAVIS_NODE_VERSION="10" matrix: include: - - php: 7.1 - env: DB=PGSQL RECIPE_VERSION=4.3.x-dev PHPUNIT_TEST=1 - php: 7.1 env: DB=MYSQL RECIPE_VERSION=4.3.x-dev PHPUNIT_TEST=1 PHPCS_TEST=1 - - php: 7.1 - env: DB=MYSQL RECIPE_VERSION=4.4.x-dev PHPUNIT_TEST=1 - - php: 7.2 - env: DB=PGSQL RECIPE_VERSION=4.4.x-dev PHPUNIT_TEST=1 - php: 7.2 env: DB=MYSQL RECIPE_VERSION=4.4.x-dev PHPUNIT_TEST=1 PHPCS_TEST=1 - - php: 7.2 - env: DB=MYSQL RECIPE_VERSION=4.5.x-dev PHPUNIT_TEST=1 - php: 7.3 - env: DB=PGSQL RECIPE_VERSION=4.5.x-dev PHPUNIT_TEST=1 + env: DB=PGSQL RECIPE_VERSION=4.5.x-dev PHPUNIT_TEST=1 PHPCS_TEST=1 - php: 7.3 env: DB=MYSQL RECIPE_VERSION=4.5.x-dev PHPUNIT_TEST=1 PHPCS_TEST=1 - php: 7.3 - env: DB=MYSQL RECIPE_VERSION=4.x-dev PHPUNIT_COVERAGE_TEST=1 + env: DB=MYSQL RECIPE_VERSION=4.x-dev PHPUNIT_TEST=1 PHPUNIT_COVERAGE_TEST=1 PHPCS_TEST=1 before_install: - mysql -e 'CREATE DATABASE IF NOT EXISTS test;' From 588acffd7bfecd8476ca290df28f2446d679eaf4 Mon Sep 17 00:00:00 2001 From: Lani Field Date: Mon, 24 Aug 2020 16:15:00 +1200 Subject: [PATCH 16/24] fix: Change EnvBarDisplay default value to 1 --- tests/EnvBarExtensionTest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/EnvBarExtensionTest.yml b/tests/EnvBarExtensionTest.yml index b00e17d..d3ef759 100644 --- a/tests/EnvBarExtensionTest.yml +++ b/tests/EnvBarExtensionTest.yml @@ -3,6 +3,7 @@ SilverStripe\SiteConfig\SiteConfig: Title: Test site CanViewType: Anyone CanEditType: LoggedInUsers + EnvBarDisplay: 1 SilverStripe\Security\Group: admins: From df30167cbc9ecffd1cfbe5097a537c4631007c90 Mon Sep 17 00:00:00 2001 From: Lani Field Date: Mon, 24 Aug 2020 16:39:31 +1200 Subject: [PATCH 17/24] fix: Change EnvBarDisplay default value to true --- tests/EnvBarExtensionTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/EnvBarExtensionTest.yml b/tests/EnvBarExtensionTest.yml index d3ef759..37ab931 100644 --- a/tests/EnvBarExtensionTest.yml +++ b/tests/EnvBarExtensionTest.yml @@ -3,7 +3,7 @@ SilverStripe\SiteConfig\SiteConfig: Title: Test site CanViewType: Anyone CanEditType: LoggedInUsers - EnvBarDisplay: 1 + EnvBarDisplay: true SilverStripe\Security\Group: admins: From 0fcd61ca56fd8ab1de616e1ef0929a17f33f1719 Mon Sep 17 00:00:00 2001 From: Lani Field Date: Mon, 24 Aug 2020 16:58:23 +1200 Subject: [PATCH 18/24] fix: Modify test to show or hide EnvBar via CMS checkbox --- tests/EnvBarSiteConfigExtensionTest.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/EnvBarSiteConfigExtensionTest.php b/tests/EnvBarSiteConfigExtensionTest.php index 2f95168..ea48307 100644 --- a/tests/EnvBarSiteConfigExtensionTest.php +++ b/tests/EnvBarSiteConfigExtensionTest.php @@ -18,8 +18,6 @@ class EnvBarSiteConfigExtensionTest extends FunctionalTest */ public function testDisplayEnabled() { - SiteConfig::current_site_config()->setField('EnvBarDisplay', 1); - $url = $this->objFromFixture( 'SilverStripe\CMS\Model\SiteTree', 'default' @@ -41,8 +39,6 @@ public function testDisplayEnabled() */ public function testDisplayDisabled() { - SiteConfig::current_site_config()->setField('EnvBarDisplay', 0); - $url = $this->objFromFixture( 'SilverStripe\CMS\Model\SiteTree', 'default' @@ -68,6 +64,7 @@ public function EnvBarVisible($url, $user) if ($user) { $this->logInAs($user); } + SiteConfig::current_site_config()->setField('EnvBarDisplay', 'true'); $testPage = $this->get($url); $this->assertContains( '.page__envbar', @@ -86,6 +83,7 @@ public function EnvBarNotVisible($url, $user) if ($user) { $this->logInAs($user); } + SiteConfig::current_site_config()->setField('EnvBarDisplay', 'false'); $testPage = $this->get($url); $this->assertNotContains( '.page__envbar', From f26f2e1a4d4e43db43fda304a8e8a41b4e4b77d9 Mon Sep 17 00:00:00 2001 From: GuySartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Tue, 1 Dec 2020 16:59:44 +1300 Subject: [PATCH 19/24] chore: Use stable versions of SilverStripe in CI The travis tests are failing to build due to unresolvable requirements - it seems likely this is a result of using unstable versions of SilverStripe. --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3f9d86a..3836a77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,15 +11,15 @@ env: matrix: include: - php: 5.6 - env: DB=MYSQL RECIPE_VERSION=4.3.x-dev PHPUNIT_TEST=1 + env: DB=MYSQL RECIPE_VERSION=~4.3.0 PHPUNIT_TEST=1 - php: 7.0 - env: DB=PGSQL RECIPE_VERSION=4.3.x-dev PHPUNIT_TEST=1 + env: DB=PGSQL RECIPE_VERSION=~4.3.0 PHPUNIT_TEST=1 - php: 7.1 - env: DB=MYSQL RECIPE_VERSION=4.3.x-dev PHPUNIT_TEST=1 PHPCS_TEST=1 + env: DB=MYSQL RECIPE_VERSION=~4.3.0 PHPUNIT_TEST=1 PHPCS_TEST=1 - php: 7.2 - env: DB=PGSQL RECIPE_VERSION=4.4.x-dev PHPUNIT_TEST=1 + env: DB=PGSQL RECIPE_VERSION=~4.4.0 PHPUNIT_TEST=1 - php: 7.3 - env: DB=MYSQL RECIPE_VERSION=4.x-dev PHPUNIT_COVERAGE_TEST=1 + env: DB=MYSQL RECIPE_VERSION=^4 PHPUNIT_COVERAGE_TEST=1 before_install: - mysql -e 'CREATE DATABASE IF NOT EXISTS test;' From 6857783dfe444729f0d745de33be5b15cd9cd192 Mon Sep 17 00:00:00 2001 From: GuySartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Tue, 1 Dec 2020 17:09:17 +1300 Subject: [PATCH 20/24] chore: Update PHP versions in travis config. The tests using PHP 5.6 and PHP 7.0 do not build because the version of SilverStripe being built does not support PHP<7.1 Also add PHP 7.4. --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3836a77..1a72a95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,15 +10,13 @@ env: matrix: include: - - php: 5.6 - env: DB=MYSQL RECIPE_VERSION=~4.3.0 PHPUNIT_TEST=1 - - php: 7.0 - env: DB=PGSQL RECIPE_VERSION=~4.3.0 PHPUNIT_TEST=1 - php: 7.1 env: DB=MYSQL RECIPE_VERSION=~4.3.0 PHPUNIT_TEST=1 PHPCS_TEST=1 - php: 7.2 env: DB=PGSQL RECIPE_VERSION=~4.4.0 PHPUNIT_TEST=1 - php: 7.3 + env: DB=MYSQL RECIPE_VERSION=^4 + - php: 7.4 env: DB=MYSQL RECIPE_VERSION=^4 PHPUNIT_COVERAGE_TEST=1 before_install: From f294b64c5c767d7262356e89eec7b8b677cbebd4 Mon Sep 17 00:00:00 2001 From: GuySartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Tue, 1 Dec 2020 17:13:58 +1300 Subject: [PATCH 21/24] chore: Require stable version of postgresql silverstripe/postgresql 2.1.x-dev was not resolving to an installable package. Prefer using a stable tagged version. Also remove --no-suggest while we're at it, as this is deprecated in composer 2. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1a72a95..76bf913 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,8 +28,8 @@ before_script: - composer validate - composer require --no-update silverstripe/recipe-cms:"$RECIPE_VERSION" - - if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.1.x-dev; fi - - composer install --prefer-source --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile + - if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:^2.1.0; fi + - composer install --prefer-source --no-interaction --no-progress --optimize-autoloader --verbose --profile script: - if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/EnvBarExtensionTest.php; fi From d358920106572b60095f8acc96f6ccebf4d53f22 Mon Sep 17 00:00:00 2001 From: Lani Field Date: Wed, 16 Dec 2020 09:44:26 +1300 Subject: [PATCH 22/24] fix: Modify testDisplayDisabled to request draft staged page. --- tests/EnvBarSiteConfigExtensionTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/EnvBarSiteConfigExtensionTest.php b/tests/EnvBarSiteConfigExtensionTest.php index ea48307..65f5146 100644 --- a/tests/EnvBarSiteConfigExtensionTest.php +++ b/tests/EnvBarSiteConfigExtensionTest.php @@ -39,10 +39,11 @@ public function testDisplayEnabled() */ public function testDisplayDisabled() { - $url = $this->objFromFixture( + $page = $this->objFromFixture( 'SilverStripe\CMS\Model\SiteTree', 'default' - )->URLSegment; + ); + $url = $page->URLSegment . '?stage=Stage'; $user = $this->objFromFixture( 'SilverStripe\Security\Member', From 696523876d15f4e1e33b7d3f4629d24742bedb84 Mon Sep 17 00:00:00 2001 From: Steve Piner Date: Thu, 28 Apr 2022 17:47:28 +1200 Subject: [PATCH 23/24] feat: Allow plugins for composer 2. --- composer.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6df944d..a8bdf62 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,11 @@ } }, "config": { - "process-timeout": 600 + "process-timeout": 600, + "allow-plugins": { + "composer/installers": true, + "silverstripe/vendor-plugin": true + } }, "prefer-stable": true, "minimum-stability": "dev" From 97c8d23e45d9572d9aa7af55bee07dbe72da1e22 Mon Sep 17 00:00:00 2001 From: Steve Piner Date: Thu, 28 Apr 2022 17:50:57 +1200 Subject: [PATCH 24/24] test: Fix SiteConfig tests. --- tests/EnvBarSiteConfigExtensionTest.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/EnvBarSiteConfigExtensionTest.php b/tests/EnvBarSiteConfigExtensionTest.php index 65f5146..9df5239 100644 --- a/tests/EnvBarSiteConfigExtensionTest.php +++ b/tests/EnvBarSiteConfigExtensionTest.php @@ -18,10 +18,11 @@ class EnvBarSiteConfigExtensionTest extends FunctionalTest */ public function testDisplayEnabled() { - $url = $this->objFromFixture( + $page = $this->objFromFixture( 'SilverStripe\CMS\Model\SiteTree', 'default' - )->URLSegment; + ); + $url = $page->URLSegment . '?stage=Stage'; $user = $this->objFromFixture( 'SilverStripe\Security\Member', @@ -65,10 +66,10 @@ public function EnvBarVisible($url, $user) if ($user) { $this->logInAs($user); } - SiteConfig::current_site_config()->setField('EnvBarDisplay', 'true'); + SiteConfig::current_site_config()->setField('EnvBarDisplay', true); $testPage = $this->get($url); $this->assertContains( - '.page__envbar', + 'page__envbar', $testPage->getBody() ); if ($user) { @@ -84,10 +85,10 @@ public function EnvBarNotVisible($url, $user) if ($user) { $this->logInAs($user); } - SiteConfig::current_site_config()->setField('EnvBarDisplay', 'false'); + SiteConfig::current_site_config()->setField('EnvBarDisplay', false); $testPage = $this->get($url); $this->assertNotContains( - '.page__envbar', + 'page__envbar', $testPage->getBody() ); if ($user) {