Skip to content

Commit c21735b

Browse files
authored
Ensure isSSH is set whenever DISABLE_HTTP_GIT is set (#19028)
When DISABLE_HTTP_GIT is set we should always show the SSH button
1 parent ea46142 commit c21735b

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

templates/repo/clone_buttons.tmpl

Lines changed: 19 additions & 12 deletions
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)