mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-19 23:28:14 +00:00
"Copy branch name" button in pull request (#17323)
* 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 <mario.lubenka@googlemail.com> * "Copy branch name" button in pull request Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com> * Update templates/repo/issue/view_title.tmpl Co-authored-by: silverwind <me@silverwind.io> * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
de61816623
commit
0208ea0248
|
@ -927,6 +927,9 @@ star_guest_user = Sign in to star this repository.
|
||||||
copy_link = Copy
|
copy_link = Copy
|
||||||
copy_link_success = Link has been copied
|
copy_link_success = Link has been copied
|
||||||
copy_link_error = Use ⌘C or Ctrl-C to copy
|
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
|
copied = Copied OK
|
||||||
unwatch = Unwatch
|
unwatch = Unwatch
|
||||||
watch = Watch
|
watch = Watch
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<input id="repo-clone-url" value="{{if $.PageIsWiki}}{{$.WikiCloneLink.SSH}}{{else}}{{$.CloneLink.SSH}}{{end}}" readonly>
|
<input id="repo-clone-url" value="{{if $.PageIsWiki}}{{$.WikiCloneLink.SSH}}{{else}}{{$.CloneLink.SSH}}{{end}}" readonly>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if or (not $.DisableHTTP) (and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH))}}
|
{{if or (not $.DisableHTTP) (and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH))}}
|
||||||
<button class="ui basic icon button poping up" 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">
|
<button class="ui basic icon button poping up" id="clipboard-btn" 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">
|
||||||
{{svg "octicon-paste"}}
|
{{svg "octicon-paste"}}
|
||||||
</button>
|
</button>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -32,28 +32,29 @@
|
||||||
{{if .Issue.IsPull}}
|
{{if .Issue.IsPull}}
|
||||||
{{$headHref := .HeadTarget|Escape}}
|
{{$headHref := .HeadTarget|Escape}}
|
||||||
{{if .HeadBranchHTMLURL}}
|
{{if .HeadBranchHTMLURL}}
|
||||||
{{$headHref = printf "<a href=\"%s\">%s</a>" .HeadBranchHTMLURL $headHref}}
|
{{$headHref = printf "<a href=\"%s\">%s</a>" (.HeadBranchHTMLURL | Escape) $headHref}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{$headHref = printf "%s <a class=\"poping up\" data-content=\"%s\" data-success=\"%s\" data-error=\"%s\" data-clipboard-text=\"%s\" data-variation=\"inverted tiny\">%s</a>" $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}}
|
{{$baseHref := .BaseTarget|Escape}}
|
||||||
{{if .BaseBranchHTMLURL}}
|
{{if .BaseBranchHTMLURL}}
|
||||||
{{$baseHref = printf "<a href=\"%s\">%s</a>" .BaseBranchHTMLURL $baseHref}}
|
{{$baseHref = printf "<a href=\"%s\">%s</a>" (.BaseBranchHTMLURL | Escape) $baseHref}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .Issue.PullRequest.HasMerged}}
|
{{if .Issue.PullRequest.HasMerged}}
|
||||||
{{ $mergedStr:= TimeSinceUnix .Issue.PullRequest.MergedUnix $.Lang }}
|
{{ $mergedStr:= TimeSinceUnix .Issue.PullRequest.MergedUnix $.Lang }}
|
||||||
{{if .Issue.OriginalAuthor }}
|
{{if .Issue.OriginalAuthor }}
|
||||||
{{.Issue.OriginalAuthor}}
|
{{.Issue.OriginalAuthor}}
|
||||||
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits $headHref $baseHref $mergedStr | Str2html}}</span>
|
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits $headHref $baseHref $mergedStr | Safe}}</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a {{if gt .Issue.PullRequest.Merger.ID 0}}href="{{.Issue.PullRequest.Merger.HomeLink}}"{{end}}>{{.Issue.PullRequest.Merger.GetDisplayName}}</a>
|
<a {{if gt .Issue.PullRequest.Merger.ID 0}}href="{{.Issue.PullRequest.Merger.HomeLink}}"{{end}}>{{.Issue.PullRequest.Merger.GetDisplayName}}</a>
|
||||||
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits $headHref $baseHref $mergedStr | Str2html}}</span>
|
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits $headHref $baseHref $mergedStr | Safe}}</span>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{if .Issue.OriginalAuthor }}
|
{{if .Issue.OriginalAuthor }}
|
||||||
<span id="pull-desc" class="pull-desc">{{.Issue.OriginalAuthor}} {{$.i18n.Tr "repo.pulls.title_desc" .NumCommits $headHref $baseHref | Str2html}}</span>
|
<span id="pull-desc" class="pull-desc">{{.Issue.OriginalAuthor}} {{$.i18n.Tr "repo.pulls.title_desc" .NumCommits $headHref $baseHref | Safe}}</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span id="pull-desc" class="pull-desc">
|
<span id="pull-desc" class="pull-desc">
|
||||||
<a {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.GetDisplayName}}</a>
|
<a {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.GetDisplayName}}</a>
|
||||||
{{$.i18n.Tr "repo.pulls.title_desc" .NumCommits $headHref $baseHref | Str2html}}
|
{{$.i18n.Tr "repo.pulls.title_desc" .NumCommits $headHref $baseHref | Safe}}
|
||||||
</span>
|
</span>
|
||||||
{{end}}
|
{{end}}
|
||||||
<span id="pull-desc-edit" style="display: none">
|
<span id="pull-desc-edit" style="display: none">
|
||||||
|
|
|
@ -4,16 +4,18 @@
|
||||||
function onSuccess(btn) {
|
function onSuccess(btn) {
|
||||||
if (!btn.dataset.content) return;
|
if (!btn.dataset.content) return;
|
||||||
$(btn).popup('destroy');
|
$(btn).popup('destroy');
|
||||||
|
const oldContent = btn.dataset.content;
|
||||||
btn.dataset.content = btn.dataset.success;
|
btn.dataset.content = btn.dataset.success;
|
||||||
$(btn).popup('show');
|
$(btn).popup('show');
|
||||||
btn.dataset.content = btn.dataset.original;
|
btn.dataset.content = oldContent;
|
||||||
}
|
}
|
||||||
function onError(btn) {
|
function onError(btn) {
|
||||||
if (!btn.dataset.content) return;
|
if (!btn.dataset.content) return;
|
||||||
|
const oldContent = btn.dataset.content;
|
||||||
$(btn).popup('destroy');
|
$(btn).popup('destroy');
|
||||||
btn.dataset.content = btn.dataset.error;
|
btn.dataset.content = btn.dataset.error;
|
||||||
$(btn).popup('show');
|
$(btn).popup('show');
|
||||||
btn.dataset.content = btn.dataset.original;
|
btn.dataset.content = oldContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -686,6 +686,15 @@
|
||||||
code {
|
code {
|
||||||
color: var(--color-primary);
|
color: var(--color-primary);
|
||||||
}
|
}
|
||||||
|
a[data-clipboard-text] {
|
||||||
|
cursor: pointer;
|
||||||
|
svg {
|
||||||
|
vertical-align: middle;
|
||||||
|
position: relative;
|
||||||
|
top: -2px;
|
||||||
|
right: 1px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.pull {
|
.pull {
|
||||||
|
|
Loading…
Reference in a new issue