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

Rearrange Clone Panel #23231

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions templates/repo/clone_script.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 {
Expand Down
64 changes: 47 additions & 17 deletions templates/repo/home.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
{{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>
<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}}
{{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 */}}
Expand Down
50 changes: 47 additions & 3 deletions web_src/css/repo.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 > 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;
}

#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 {
Expand Down
Loading