Skip to content

Commit b9dda50

Browse files
authored
Merge branch 'master' into allow-block_list_migrate-mirror_8040
2 parents 8372dd1 + 7bc0c8c commit b9dda50

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

templates/repo/home.tmpl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@
111111
{{if eq $n 0}}
112112
<div class="ui action tiny input" id="clone-panel">
113113
{{if not $.DisableHTTP}}
114-
<button class="ui basic clone button" id="repo-clone-https" data-link="{{.CloneLink.HTTPS}}">
114+
<button class="ui basic clone button no-transition" id="repo-clone-https" data-link="{{.CloneLink.HTTPS}}">
115115
{{if UseHTTPS}}HTTPS{{else}}HTTP{{end}}
116116
</button>
117117
{{end}}
118118
{{if and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH)}}
119-
<button class="ui basic clone button" id="repo-clone-ssh" data-link="{{.CloneLink.SSH}}">
119+
<button class="ui basic clone button no-transition" id="repo-clone-ssh" data-link="{{.CloneLink.SSH}}">
120120
SSH
121121
</button>
122122
{{end}}
@@ -125,6 +125,19 @@
125125
{{else if and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH)}}
126126
<input id="repo-clone-url" value="{{$.CloneLink.SSH}}" readonly>
127127
{{end}}
128+
<script defer>
129+
const isSSH = localStorage.getItem('repo-clone-protocol') === 'ssh';
130+
const sshButton = document.getElementById('repo-clone-ssh');
131+
const httpsButton = document.getElementById('repo-clone-https');
132+
const input = document.getElementById('repo-clone-url');
133+
if (input) input.value = (isSSH ? sshButton : httpsButton).dataset.link;
134+
if (sshButton) sshButton.classList[isSSH ? 'add' : 'remove']('primary');
135+
if (httpsButton) httpsButton.classList[isSSH ? 'remove' : 'add']('primary');
136+
setTimeout(() => {
137+
if (sshButton) sshButton.classList.remove('no-transition');
138+
if (httpsButto) httpsButton.classList.remove('no-transition');
139+
}, 100);
140+
</script>
128141
{{if or (not $.DisableHTTP) (and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH))}}
129142
<button class="ui basic icon button poping up clipboard" id="clipboard-btn" data-original="{{.i18n.Tr "repo.copy_link"}}" data-success="{{.i18n.Tr "repo.copy_link_success"}}" data-error="{{.i18n.Tr "repo.copy_link_error"}}" data-content="{{.i18n.Tr "repo.copy_link"}}" data-variation="inverted tiny" data-clipboard-target="#repo-clone-url">
130143
{{svg "octicon-clippy"}}

web_src/js/index.js

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,16 +1138,16 @@ async function initRepository() {
11381138
$('#repo-clone-ssh').on('click', function () {
11391139
$('.clone-url').text($(this).data('link'));
11401140
$('#repo-clone-url').val($(this).data('link'));
1141-
$(this).addClass('blue');
1142-
$('#repo-clone-https').removeClass('blue');
1141+
$(this).addClass('primary');
1142+
$('#repo-clone-https').removeClass('primary');
11431143
localStorage.setItem('repo-clone-protocol', 'ssh');
11441144
});
11451145
$('#repo-clone-https').on('click', function () {
11461146
$('.clone-url').text($(this).data('link'));
11471147
$('#repo-clone-url').val($(this).data('link'));
1148-
$(this).addClass('blue');
1148+
$(this).addClass('primary');
11491149
if ($('#repo-clone-ssh').length > 0) {
1150-
$('#repo-clone-ssh').removeClass('blue');
1150+
$('#repo-clone-ssh').removeClass('primary');
11511151
localStorage.setItem('repo-clone-protocol', 'https');
11521152
}
11531153
});
@@ -2520,22 +2520,6 @@ $(document).ready(async () => {
25202520
initTableSort();
25212521
initNotificationsTable();
25222522

2523-
// Repo clone url.
2524-
if ($('#repo-clone-url').length > 0) {
2525-
switch (localStorage.getItem('repo-clone-protocol')) {
2526-
case 'ssh':
2527-
if ($('#repo-clone-ssh').length > 0) {
2528-
$('#repo-clone-ssh').trigger('click');
2529-
} else {
2530-
$('#repo-clone-https').trigger('click');
2531-
}
2532-
break;
2533-
default:
2534-
$('#repo-clone-https').trigger('click');
2535-
break;
2536-
}
2537-
}
2538-
25392523
const routes = {
25402524
'div.user.settings': initUserSettings,
25412525
'div.repository.settings.collaboration': initRepositoryCollaboration

web_src/less/helpers.less

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
.rounded-left { border-radius: var(--border-radius) 0 0 var(--border-radius) !important; }
2525
.rounded-right { border-radius: 0 var(--border-radius) var(--border-radius) 0 !important; }
2626

27+
.no-transition { transition: none !important; }
28+
2729
.bg-red { background: var(--color-red) !important; }
2830
.bg-orange { background: var(--color-orange) !important; }
2931
.bg-yellow { background: var(--color-yellow) !important; }

0 commit comments

Comments
 (0)