diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-17 15:08:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-17 15:08:06 +0300 |
commit | f0a387b4a5f08d6739894455664b4d3cb1509cc6 (patch) | |
tree | 3c5b144fbb894189dfb9a61e47c53c54af4415f4 /app/views/pwa | |
parent | 91c2554bcf93c3c41aa830da4dd7a2d4b7483e2d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/views/pwa')
-rw-r--r-- | app/views/pwa/offline.html.haml | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/views/pwa/offline.html.haml b/app/views/pwa/offline.html.haml new file mode 100644 index 00000000000..5eae546bea9 --- /dev/null +++ b/app/views/pwa/offline.html.haml @@ -0,0 +1,31 @@ += link_to root_path do + = render 'shared/logo.svg' +%h1= _('Offline') +.container + %h3= _('You are currently offline, or the GitLab instance is not reachable.') + %p= _("In the background, we're attempting to connect you again.") + -# haml-lint:disable InlineJavaScript + :javascript + window.addEventListener('online', () => { + window.location.reload(); + }); + + async function checkNetworkAndReload() { + try { + const response = await fetch('.'); + // Verify we get a valid response from the server + if (response.status >= 200 && response.status < 500) { + window.location.reload(); + return; + } + } catch { + // Unable to connect to the server, ignore. + } + window.setTimeout(checkNetworkAndReload, 2500); + } + + if (window.location.pathname.endsWith('/-/offline')) { + return; + } + + checkNetworkAndReload(); |