Skip to content

Commit 08feb6b

Browse files
zeripathwxiaoguanglunnytechknowlogick
authored
Ensure isSSH is set whenever DISABLE_HTTP_GIT is set (#19028) (#19146)
Backport #19028 When DISABLE_HTTP_GIT is set we should always show the SSH button Co-authored-by: wxiaoguang <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 1aa5dc7 commit 08feb6b

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

templates/repo/clone_buttons.tmpl

+19-12
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,24 @@
1919
</button>
2020
{{end}}
2121
{{if not (and $.DisableHTTP $.DisableSSH)}}
22-
<script defer>
23-
const isSSH = localStorage.getItem('repo-clone-protocol') === 'ssh';
24-
const sshButton = document.getElementById('repo-clone-ssh');
25-
const httpsButton = document.getElementById('repo-clone-https');
26-
const input = document.getElementById('repo-clone-url');
27-
if (input) input.value = (isSSH ? sshButton : httpsButton).getAttribute('data-link');
28-
if (sshButton) sshButton.classList[isSSH ? 'add' : 'remove']('primary');
29-
if (httpsButton) httpsButton.classList[isSSH ? 'remove' : 'add']('primary');
30-
setTimeout(() => {
31-
if (sshButton) sshButton.classList.remove('no-transition');
32-
if (httpsButton) httpsButton.classList.remove('no-transition');
33-
}, 100);
22+
<script>
23+
<!-- /* eslint-disable */ -->
24+
window.config.pageData['repoCloneButtons']= {httpsDisabled: {{$.DisableHTTP}}};
25+
</script>
26+
<script>
27+
(() => {
28+
const tmplData = window.config.pageData.repoCloneButtons;
29+
const isSSH = tmplData.httpsDisabled || localStorage.getItem('repo-clone-protocol') === 'ssh';
30+
const sshButton = document.getElementById('repo-clone-ssh');
31+
const httpsButton = document.getElementById('repo-clone-https');
32+
const input = document.getElementById('repo-clone-url');
33+
if (input) input.value = (isSSH ? sshButton : httpsButton).getAttribute('data-link');
34+
if (sshButton) sshButton.classList[isSSH ? 'add' : 'remove']('primary');
35+
if (httpsButton) httpsButton.classList[isSSH ? 'remove' : 'add']('primary');
36+
setTimeout(() => {
37+
if (sshButton) sshButton.classList.remove('no-transition');
38+
if (httpsButton) httpsButton.classList.remove('no-transition');
39+
}, 100);
40+
})();
3441
</script>
3542
{{end}}

0 commit comments

Comments
 (0)