feat(WIP): Rearrange clone panel

This commit restores the state of the pull request from March 2023. The result looks different and still needs to be improved.
This commit is contained in:
Blender Defender 2024-05-18 15:01:23 +02:00
parent 028992429a
commit 8181d3af44
No known key found for this signature in database
GPG Key ID: 888C2079E570ABC1
4 changed files with 101 additions and 20 deletions

View File

@ -1017,6 +1017,8 @@ all_branches = All branches
fork_no_valid_owners = This repository can not be forked because there are no valid owners.
fork.blocked_user = Cannot fork the repository because you are blocked by the repository owner.
use_template = Use this template
clone_https_description = Use Git via the web URL.
clone_ssh_description = Use a password protected SSH key.
open_with_editor = Open with %s
download_zip = Download ZIP
download_tar = Download TAR.GZ

View File

@ -10,6 +10,7 @@
const sshBtn = document.getElementById('repo-clone-ssh');
const value = localStorage.getItem('repo-clone-protocol') || 'https';
const isSSH = value === 'ssh' && sshBtn || value !== 'ssh' && !httpsBtn;
const methodDesc = document.getElementById("repo-clone-method-description");
if (httpsBtn) {
httpsBtn.textContent = window.origin.split(':')[0].toUpperCase();
@ -24,6 +25,10 @@
const btn = isSSH ? sshBtn : httpsBtn;
if (!btn) return;
if (methodDesc) {
methodDesc.innerText = btn.dataset.description;
}
// NOTE: Keep this function in sync with the one in the js folder
function toOriginUrl(urlStr) {
try {

View File

@ -116,26 +116,56 @@
<div class="repo-button-row-right">
<!-- Only show clone panel in repository home page -->
{{if $isHomepage}}
<div class="clone-panel ui action tiny input">
{{template "repo/clone_buttons" .}}
<button class="ui small jump dropdown icon button" data-tooltip-content="{{ctx.Locale.Tr "repo.more_operations"}}">
{{svg "octicon-kebab-horizontal"}}
<div class="menu">
{{if not $.DisableDownloadSourceArchives}}
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.zip" rel="nofollow">{{svg "octicon-file-zip" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.download_zip"}}</a>
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.download_tar"}}</a>
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.bundle" rel="nofollow">{{svg "octicon-package" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.download_bundle"}}</a>
<div class="clone-panel ui action tiny input">
<button class="ui basic small compact jump dropdown icon button primary" data-tooltip-content="{{ctx.Locale.Tr "repo.more_operations"}}">
<!-- {{svg "octicon-kebab-horizontal"}} -->
<div>
{{svg "octicon-code" 16}}
<span>Code</span>
{{svg "octicon-chevron-down"}}
</div>
<div class="menu gt-mt-3 clone-panel-content">
<div class="ui input">
{{svg "octicon-terminal" 16}}
<strong id="clone-heading" class="gt-ml-3">Clone</strong>
</div>
<div class="ui input gt-mb-0">
<!-- there is always at least one button (by context/repo.go) -->
{{if $.CloneButtonShowHTTPS}}
<div class="ui clone tabs" id="repo-clone-https" data-link="{{$.CloneButtonOriginLink.HTTPS}}" data-description="{{ctx.Locale.Tr "repo.clone_https_description"}}">
HTTPS
</div>
{{end}}
{{if .CitiationExist}}
<a class="item" id="cite-repo-button">{{svg "octicon-cross-reference" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.cite_this_repo"}}</a>
{{end}}
{{range .OpenWithEditorApps}}
<a class="item js-clone-url-editor" data-href-template="{{.OpenURL}}">{{.IconHTML}}{{ctx.Locale.Tr "repo.open_with_editor" .DisplayName}}</a>
{{if $.CloneButtonShowSSH}}
<div class="ui clone tabs" id="repo-clone-ssh" data-link="{{$.CloneButtonOriginLink.SSH}}" data-description="{{ctx.Locale.Tr "repo.clone_ssh_description"}}">
SSH
</div>
{{end}}
</div>
</button>
{{template "repo/clone_script" .}}{{/* the script will update `.js-clone-url` and related elements */}}
</div>
<div class="ui input tiny action gt-mt-4 gt-mb-0">
<input id="repo-clone-url" size="30" class="js-clone-url" value="{{$.CloneButtonOriginLink.HTTPS}}" readonly>
<div class="ui basic small compact icon button tooltip" id="clipboard-btn" data-tooltip-content="{{ctx.Locale.Tr "copy_url"}}" data-clipboard-target="#repo-clone-url" aria-label="{{ctx.Locale.Tr "copy_url"}}">
{{svg "octicon-copy" 14}}
</div>
</div>
<div id="repo-clone-method-description" class="ui input text tiny grey gt-mt-3"></div>
{{range .OpenWithEditorApps}}
<a class="item js-clone-url-editor" data-href-template="{{.OpenURL}}">{{.IconHTML}}{{ctx.Locale.Tr "repo.open_with_editor" .DisplayName}}</a>
{{end}}
{{if not $.DisableDownloadSourceArchives}}
<div class="ui divider"></div>
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.zip" rel="nofollow">{{svg "octicon-file-zip" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.download_zip"}}</a>
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.download_tar"}}</a>
<a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.bundle" rel="nofollow">{{svg "octicon-package" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.download_bundle"}}</a>
{{end}}
{{if .CitiationExist}}
<div class="ui divider"></div>
<a class="item" id="cite-repo-button">{{svg "octicon-cross-reference" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.cite_this_repo"}}</a>
{{end}}
</div>
</button>
{{template "repo/clone_script" .}}{{/* the script will update `.js-clone-url` and related elements */}}
</div>
{{template "repo/cite/cite_modal" .}}
{{end}}
{{if and (not $isHomepage) (not .IsViewFile) (not .IsBlame)}}{{/* IsViewDirectory (not home), TODO: split the templates, avoid using "if" tricks */}}

View File

@ -151,12 +151,56 @@
margin-left: -1px; /* make the borders overlap to avoid double borders */
}
.repository .clone-panel > button:first-of-type {
/* .repository .clone-panel > button:first-of-type, */
/* .repository .clone-panel > div:first-of-type {
border-radius: var(--border-radius) 0 0 var(--border-radius) !important;
} */
/* .repository .clone-panel > button:last-of-type, */
/* .repository .clone-panel > div:last-of-type {
border-radius: 0 var(--border-radius) var(--border-radius) 0 !important;
} */
.repository .clone-panel > button {
border-radius: var(--border-radius) !important;
}
.repository .clone-panel > button:last-of-type {
border-radius: 0 var(--border-radius) var(--border-radius) 0 !important;
#clone-heading {
font-size: 1rem;
}
.clone-panel-content {
min-width: 200px;
}
.clone-panel-content::before {
content: "";
left: auto;
right: 9px;
top: -10px;
border: 8px solid #0000;
border-bottom: 8px solid var(--color-shadow);
display: inline-block;
position: absolute;
}
.clone.tabs {
cursor: pointer;
border-bottom: 3px solid;
border-color: transparent;
font-weight: 600;
font-size: 1rem;
padding: 0.5rem;
}
.clone.tabs.primary {
border-color: var(--color-primary);
}
.repository .clone-panel .dropdown .menu {