Browse Source

Merge "Disable service workers by default"

Zuul 2 months ago
parent
commit
d010bec30a

+ 2
- 2
Dockerfile View File

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

+ 4
- 3
doc/source/developer/javascript.rst View File

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

+ 6
- 0
releasenotes/notes/service-worker-default-b6f6d5c277657ced.yaml View File

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

+ 2
- 1
web/src/registerServiceWorker.js View File

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

Loading…
Cancel
Save