Browse Source

Merge "Disable service workers by default"

changes/48/635148/1
Zuul 3 years ago committed by Gerrit Code Review
parent
commit
d010bec30a
  1. 4
      Dockerfile
  2. 7
      doc/source/developer/javascript.rst
  3. 6
      releasenotes/notes/service-worker-default-b6f6d5c277657ced.yaml
  4. 3
      web/src/registerServiceWorker.js

4
Dockerfile

@ -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

7
doc/source/developer/javascript.rst

@ -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.

6
releasenotes/notes/service-worker-default-b6f6d5c277657ced.yaml

@ -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``

3
web/src/registerServiceWorker.js

@ -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
}

Loading…
Cancel
Save