aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwxiaoguang2022-03-09 12:42:29 +0800
committerGitHub2022-03-09 12:42:29 +0800
commitc21735b49a5dd8ab6a2f8f6085d650dcfb411fad (patch)
tree08477b56c5147e64efc69396dce00d8e75e1ca6c
parentea46142bcea6084e50a11baf048f8eb8862285c7 (diff)
Ensure isSSH is set whenever DISABLE_HTTP_GIT is set (#19028)
When DISABLE_HTTP_GIT is set we should always show the SSH button
-rw-r--r--templates/repo/clone_buttons.tmpl31
1 files changed, 19 insertions, 12 deletions
diff --git a/templates/repo/clone_buttons.tmpl b/templates/repo/clone_buttons.tmpl
index 29d3fe76d..d4b822521 100644
--- a/templates/repo/clone_buttons.tmpl
+++ b/templates/repo/clone_buttons.tmpl
@@ -19,17 +19,24 @@
</button>
{{end}}
{{if not (and $.DisableHTTP $.DisableSSH)}}
- <script defer>
- const isSSH = localStorage.getItem('repo-clone-protocol') === 'ssh';
- const sshButton = document.getElementById('repo-clone-ssh');
- const httpsButton = document.getElementById('repo-clone-https');
- const input = document.getElementById('repo-clone-url');
- if (input) input.value = (isSSH ? sshButton : httpsButton).getAttribute('data-link');
- if (sshButton) sshButton.classList[isSSH ? 'add' : 'remove']('primary');
- if (httpsButton) httpsButton.classList[isSSH ? 'remove' : 'add']('primary');
- setTimeout(() => {
- if (sshButton) sshButton.classList.remove('no-transition');
- if (httpsButton) httpsButton.classList.remove('no-transition');
- }, 100);
+ <script>
+ <!-- /* eslint-disable */ -->
+ window.config.pageData['repoCloneButtons']= {httpsDisabled: {{$.DisableHTTP}}};
+ </script>
+ <script>
+ (() => {
+ const tmplData = window.config.pageData.repoCloneButtons;
+ const isSSH = tmplData.httpsDisabled || localStorage.getItem('repo-clone-protocol') === 'ssh';
+ const sshButton = document.getElementById('repo-clone-ssh');
+ const httpsButton = document.getElementById('repo-clone-https');
+ const input = document.getElementById('repo-clone-url');
+ if (input) input.value = (isSSH ? sshButton : httpsButton).getAttribute('data-link');
+ if (sshButton) sshButton.classList[isSSH ? 'add' : 'remove']('primary');
+ if (httpsButton) httpsButton.classList[isSSH ? 'remove' : 'add']('primary');
+ setTimeout(() => {
+ if (sshButton) sshButton.classList.remove('no-transition');
+ if (httpsButton) httpsButton.classList.remove('no-transition');
+ }, 100);
+ })();
</script>
{{end}}