Skip to content

Commit

Permalink
Ensure isSSH is set whenever DISABLE_HTTP_GIT is set (go-gitea#19028)
Browse files Browse the repository at this point in the history
When DISABLE_HTTP_GIT is set we should always show the SSH button
  • Loading branch information
wxiaoguang authored and Stelios Malathouras committed Mar 28, 2022
1 parent 438f848 commit 2125221
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions templates/repo/clone_buttons.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

0 comments on commit 2125221

Please sign in to comment.