Merge "Disable service workers by default"

This commit is contained in:
Zuul 2019-02-05 19:16:34 +00:00 committed by Gerrit Code Review
commit d010bec30a
4 changed files with 14 additions and 6 deletions

View File

@ -17,8 +17,8 @@ FROM opendevorg/python-builder as builder
# Optional location of Zuul API endpoint.
ARG REACT_APP_ZUUL_API
# Optional flag to disable React Service Worker. (set to true to disable)
ARG REACT_APP_DISABLE_SERVICE_WORKER
# Optional flag to enable React Service Worker. (set to true to enable)
ARG REACT_APP_ENABLE_SERVICE_WORKER
COPY . /tmp/src
RUN /tmp/src/tools/install-js-tools.sh

View File

@ -193,6 +193,7 @@ As long as `yarn`_ is installed, the installation of zuul will run
.. _Patternfly: https://www.patternfly.org/
.. _create-react-app: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md
In some cases there is the need to disable the service worker which does
advanced caching. In order to do that set the environment variable
``REACT_APP_DISABLE_SERVICE_WORKER=true`` during installation.
By default, zuul-web provides a Progressive Web Application but does
not run a Service Worker. For deployers who would like to enable one,
set the environment variable
``REACT_APP_ENABLE_SERVICE_WORKER=true`` during installation.

View File

@ -0,0 +1,6 @@
---
upgrade:
- |
Service Workers are now disabled by default in the Javascript
dashboard. Deployers who wish to enable them need to set
``REACT_APP_ENABLE_SERVICE_WORKER``

View File

@ -21,8 +21,9 @@ const isLocalhost = Boolean(
)
export default function register () {
if (process.env.REACT_APP_DISABLE_SERVICE_WORKER === 'true') {
if (process.env.REACT_APP_ENABLE_SERVICE_WORKER !== 'true') {
console.log('Disabled service worker')
unregister()
return
}