Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure isSSH is set whenever DISABLE_HTTP_GIT is set #19022

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion templates/repo/clone_buttons.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,18 @@
{{svg "octicon-paste"}}
</button>
{{end}}
{{if $.DisableHTTP}}
<script defer>
const httpsDisabled = true;
</script>
{{else}}
<script defer>
const httpsDisabled = false;
</script>
{{end}}
{{if not (and $.DisableHTTP $.DisableSSH)}}
<script defer>
const isSSH = localStorage.getItem('repo-clone-protocol') === 'ssh';
const isSSH = httpsDisabled || localStorage.getItem('repo-clone-protocol') === 'ssh';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isSSH = httpsDisabled || localStorage.getItem('repo-clone-protocol') === 'ssh';
const isSSH = {{if $.DisableHTTP}}true || {{end}}localStorage.getItem('repo-clone-protocol') === 'ssh';

A suggestion: this changes this PR to one line vs 10. Feel free to take it or discard, although if discarded then the above code chunk could have some de-duplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that will fail our lint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I tried this orignally)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But how about when they disabled both HTTP and SSH? Just use the UI?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😭 ah, I see.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can bypass the JS linter for some code blocks. See the head.tmpl

image

const sshButton = document.getElementById('repo-clone-ssh');
const httpsButton = document.getElementById('repo-clone-https');
const input = document.getElementById('repo-clone-url');
Expand Down