From 80db44267ccb688c596e8375523af5cd92864d87 Mon Sep 17 00:00:00 2001 From: zeripath Date: Fri, 6 Mar 2020 03:44:06 +0000 Subject: Add Approval Counts to pulls list (#10238) * Add Approval Counts to pulls list Add simple approvals counts to pulls lists * Remove non-official counts * Add PR features to milestone_issues.tmpl --- templates/repo/issue/list.tmpl | 11 ++++++++++ templates/repo/issue/milestone_issues.tmpl | 34 ++++++++++++++++++++++++++---- templates/user/dashboard/issues.tmpl | 11 ++++++++++ 3 files changed, 52 insertions(+), 4 deletions(-) (limited to 'templates') diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index 60644409c3..05018bacdd 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -202,6 +202,7 @@
+ {{ $approvalCounts := .ApprovalCounts}} {{range .Issues}}
  • {{if $.CanWriteIssuesOrPulls}} @@ -268,6 +269,16 @@ {{end}} {{if .IsPull}} + {{$approveOfficial := call $approvalCounts .ID "approve"}} + {{$rejectOfficial := call $approvalCounts .ID "reject"}} + {{if or (gt $approveOfficial 0) (gt $rejectOfficial 0)}} + {{svg "octicon-check" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}} + {{if or (gt $rejectOfficial 0)}} + {{svg "octicon-x" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}} + {{end}} + {{end}} {{if and (not .PullRequest.HasMerged) (gt (len .PullRequest.ConflictedFiles) 0)}} {{svg "octicon-mirror" 16}} {{$.i18n.Tr (TrN $.i18n.Lang (len .PullRequest.ConflictedFiles) "repo.pulls.num_conflicting_files_1" "repo.pulls.num_conflicting_files_n") (len .PullRequest.ConflictedFiles)}} {{end}} diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index 49712b1d09..6d08df87df 100644 --- a/templates/repo/issue/milestone_issues.tmpl +++ b/templates/repo/issue/milestone_issues.tmpl @@ -177,6 +177,7 @@
  • + {{ $approvalCounts := .ApprovalCounts}} {{range .Issues}} {{ $timeStr:= TimeSinceUnix .CreatedUnix $.Lang }}
  • @@ -185,9 +186,15 @@
  • {{end}} -
    #{{.Index}}
    +
    #{{.Index}}
    {{.Title}} + {{if .IsPull }} + {{if (index $.CommitStatus .PullRequest.ID)}} + {{template "repo/commit_status" (index $.CommitStatus .PullRequest.ID)}} + {{end}} + {{end}} + {{range .Labels}} {{.Name}} {{end}} @@ -201,11 +208,15 @@ {{end}}

    - {{if gt .Poster.ID 0}} - {{$.i18n.Tr .GetLastEventLabel $timeStr .Poster.HomeLink (.Poster.GetDisplayName|Escape) | Safe}} + {{ $timeStr := TimeSinceUnix .GetLastEventTimestamp $.Lang }} + {{if .OriginalAuthor }} + {{$.i18n.Tr .GetLastEventLabelFake $timeStr .OriginalAuthor | Safe}} + {{else if gt .Poster.ID 0}} + {{$.i18n.Tr .GetLastEventLabel $timeStr .Poster.HomeLink (.Poster.GetDisplayName | Escape) | Safe}} {{else}} - {{$.i18n.Tr .GetLastEventLabelFake $timeStr (.Poster.GetDisplayName|Escape) | Safe}} + {{$.i18n.Tr .GetLastEventLabelFake $timeStr (.Poster.GetDisplayName | Escape) | Safe}} {{end}} + {{if .Ref}} {{svg "octicon-git-branch" 16}} {{.Ref}} @@ -227,6 +238,21 @@ {{end}} + {{if .IsPull}} + {{$approveOfficial := call $approvalCounts .ID "approve"}} + {{$rejectOfficial := call $approvalCounts .ID "reject"}} + {{if or (gt $approveOfficial 0) (gt $rejectOfficial 0)}} + {{svg "octicon-check" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}} + {{if or (gt $rejectOfficial 0)}} + {{svg "octicon-x" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}} + {{end}} + {{end}} + {{if and (not .PullRequest.HasMerged) ((len .PullRequest.ConflictedFiles) gt 0)}} + {{svg "octicon-mirror" 16}} {{$.i18n.Tr (TrN $.i18n.Lang (len .PullRequest.ConflictedFiles) "repo.pulls.num_conflicting_files_1" "repo.pulls.num_conflicting_files_n") (len .PullRequest.ConflictedFiles)}} + {{end}} + {{end}}

    {{end}} diff --git a/templates/user/dashboard/issues.tmpl b/templates/user/dashboard/issues.tmpl index de578b2820..447801d849 100644 --- a/templates/user/dashboard/issues.tmpl +++ b/templates/user/dashboard/issues.tmpl @@ -101,6 +101,7 @@
    + {{ $approvalCounts := .ApprovalCounts}} {{range .Issues}} {{ $timeStr:= TimeSinceUnix .CreatedUnix $.Lang }} @@ -170,6 +171,16 @@ {{end}} {{if .IsPull}} + {{$approveOfficial := call $approvalCounts .ID "approve"}} + {{$rejectOfficial := call $approvalCounts .ID "reject"}} + {{if or (gt $approveOfficial 0) (gt $rejectOfficial 0) }} + {{svg "octicon-check" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $approveOfficial "repo.pulls.approve_count_1" "repo.pulls.approve_count_n") $approveOfficial}} + {{if or (gt $rejectOfficial 0)}} + {{svg "octicon-x" 16}} + {{$.i18n.Tr (TrN $.i18n.Lang $rejectOfficial "repo.pulls.reject_count_1" "repo.pulls.reject_count_n") $rejectOfficial}} + {{end}} + {{end}} {{if and (not .PullRequest.HasMerged) (gt (len .PullRequest.ConflictedFiles) 0)}} {{svg "octicon-mirror" 16}} {{$.i18n.Tr (TrN $.i18n.Lang (len .PullRequest.ConflictedFiles) "repo.pulls.num_conflicting_files_1" "repo.pulls.num_conflicting_files_n") (len .PullRequest.ConflictedFiles)}} {{end}} -- cgit v1.2.3