diff --git a/Dockerfile b/Dockerfile index 019ba42971..4801f79c69 100644 --- a/Dockerfile +++ b/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 diff --git a/doc/source/developer/javascript.rst b/doc/source/developer/javascript.rst index 72b88657e4..ae39663e8d 100644 --- a/doc/source/developer/javascript.rst +++ b/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. diff --git a/releasenotes/notes/service-worker-default-b6f6d5c277657ced.yaml b/releasenotes/notes/service-worker-default-b6f6d5c277657ced.yaml new file mode 100644 index 0000000000..a98fc2b07c --- /dev/null +++ b/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`` diff --git a/web/src/registerServiceWorker.js b/web/src/registerServiceWorker.js index 3180adeb70..483e5d54df 100644 --- a/web/src/registerServiceWorker.js +++ b/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 }