From 81295ff0b68f2b07333e85b19f1eca1bddfe9b58 Mon Sep 17 00:00:00 2001 From: Mario Lubenka Date: Sat, 16 Oct 2021 17:13:33 +0200 Subject: [PATCH 1/4] Drop data-original from clipboard data-original attribute was removed. Instead, the original value from data-content is set after success/fail message was displayed. Signed-off-by: Mario Lubenka --- templates/repo/clone_buttons.tmpl | 2 +- web_src/js/features/clipboard.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/templates/repo/clone_buttons.tmpl b/templates/repo/clone_buttons.tmpl index 9eb7fa781d399..0a86e586fc9f3 100644 --- a/templates/repo/clone_buttons.tmpl +++ b/templates/repo/clone_buttons.tmpl @@ -14,7 +14,7 @@ {{end}} {{if or (not $.DisableHTTP) (and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH))}} - {{end}} diff --git a/web_src/js/features/clipboard.js b/web_src/js/features/clipboard.js index 4781f8d6ff4a4..738ac1d4b1021 100644 --- a/web_src/js/features/clipboard.js +++ b/web_src/js/features/clipboard.js @@ -4,16 +4,18 @@ function onSuccess(btn) { if (!btn.dataset.content) return; $(btn).popup('destroy'); + const oldContent = btn.dataset.content; btn.dataset.content = btn.dataset.success; $(btn).popup('show'); - btn.dataset.content = btn.dataset.original; + btn.dataset.content = oldContent; } function onError(btn) { if (!btn.dataset.content) return; + const oldContent = btn.dataset.content; $(btn).popup('destroy'); btn.dataset.content = btn.dataset.error; $(btn).popup('show'); - btn.dataset.content = btn.dataset.original; + btn.dataset.content = oldContent; } export default function initGlobalCopyToClipboardListener() { From 1f7a4d2987e0a15cf442b3b56cec2b833f11ccaf Mon Sep 17 00:00:00 2001 From: Mario Lubenka Date: Fri, 15 Oct 2021 22:46:35 +0200 Subject: [PATCH 2/4] "Copy branch name" button in pull request Signed-off-by: Mario Lubenka --- options/locale/locale_en-US.ini | 3 +++ templates/repo/issue/view_title.tmpl | 9 +++++---- web_src/less/_repository.less | 9 +++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 407ec9f84ee10..22fe9ae2f8339 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -927,6 +927,9 @@ star_guest_user = Sign in to star this repository. copy_link = Copy copy_link_success = Link has been copied copy_link_error = Use ⌘C or Ctrl-C to copy +copy_branch = Copy +copy_branch_success = Branch name has been copied +copy_branch_error = Use ⌘C or Ctrl-C to copy copied = Copied OK unwatch = Unwatch watch = Watch diff --git a/templates/repo/issue/view_title.tmpl b/templates/repo/issue/view_title.tmpl index b6bf965a15fbc..a23407ce84b7e 100644 --- a/templates/repo/issue/view_title.tmpl +++ b/templates/repo/issue/view_title.tmpl @@ -34,6 +34,7 @@ {{if .HeadBranchHTMLURL}} {{$headHref = printf "%s" .HeadBranchHTMLURL $headHref}} {{end}} + {{$headHref = printf "%s %s" $headHref (.i18n.Tr "repo.copy_branch") (.i18n.Tr "repo.copy_branch_success") (.i18n.Tr "repo.copy_branch_error") (.HeadTarget | Escape) (svg "octicon-copy" 14)}} {{$baseHref := .BaseTarget|Escape}} {{if .BaseBranchHTMLURL}} {{$baseHref = printf "%s" .BaseBranchHTMLURL $baseHref}} @@ -42,18 +43,18 @@ {{ $mergedStr:= TimeSinceUnix .Issue.PullRequest.MergedUnix $.Lang }} {{if .Issue.OriginalAuthor }} {{.Issue.OriginalAuthor}} - {{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits $headHref $baseHref $mergedStr | Str2html}} + {{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits $headHref $baseHref $mergedStr | Safe}} {{else}} {{.Issue.PullRequest.Merger.GetDisplayName}} - {{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits $headHref $baseHref $mergedStr | Str2html}} + {{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits $headHref $baseHref $mergedStr | Safe}} {{end}} {{else}} {{if .Issue.OriginalAuthor }} - {{.Issue.OriginalAuthor}} {{$.i18n.Tr "repo.pulls.title_desc" .NumCommits $headHref $baseHref | Str2html}} + {{.Issue.OriginalAuthor}} {{$.i18n.Tr "repo.pulls.title_desc" .NumCommits $headHref $baseHref | Safe}} {{else}} {{.Issue.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.pulls.title_desc" .NumCommits $headHref $baseHref | Str2html}} + {{$.i18n.Tr "repo.pulls.title_desc" .NumCommits $headHref $baseHref | Safe}} {{end}}