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

Add Hide/Show all checks button to commit status check #26284

Merged
merged 44 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7f433d2
improve
yp05327 Aug 2, 2023
b56220e
fix lint
yp05327 Aug 2, 2023
5303f8f
improve
yp05327 Aug 2, 2023
bd2214f
improve
yp05327 Aug 2, 2023
97e60b3
improve
yp05327 Aug 2, 2023
4a189a5
improve tiddy commit status
yp05327 Aug 3, 2023
5efcc51
Merge branch 'main' into improve-commit-status-ui
yp05327 Aug 4, 2023
a2cf202
convert to ctx.Locale.Tr
yp05327 Sep 28, 2023
711c2f8
Update web_src/js/features/repo-issue-pr-status.js
yp05327 Sep 28, 2023
aead5a5
Update templates/repo/commit_statuses.tmpl
yp05327 Sep 28, 2023
339dad1
Update templates/repo/issue/view_content/pull.tmpl
yp05327 Sep 28, 2023
6c38900
Merge branch 'main' into improve-commit-status-ui
yp05327 Sep 28, 2023
e8ddbc9
rename IsTippy into IsPopup
yp05327 Sep 28, 2023
fbcc124
Merge branch 'main' into improve-commit-status-ui
yp05327 Oct 18, 2023
2695093
Update web_src/css/repo.css
yp05327 Oct 18, 2023
9969800
Update web_src/css/repo.css
yp05327 Oct 18, 2023
08b7951
convert max-height to 231px
yp05327 Oct 18, 2023
fef5fc1
convert border-bottom 0 into none
yp05327 Oct 18, 2023
9e4dfa5
remove jQuery
yp05327 Oct 18, 2023
bef80d4
Update templates/repo/pulls/status.tmpl
yp05327 Oct 18, 2023
08f9ccd
improve
yp05327 Oct 18, 2023
3b3f767
improve
yp05327 Oct 23, 2023
f538d0e
Merge branch 'main' into improve-commit-status-ui
silverwind Nov 1, 2023
4a92356
various styling improvments
silverwind Nov 1, 2023
228eb7b
set menu theme
silverwind Nov 1, 2023
483bab0
use data-toggled attribute and improve transition
silverwind Nov 1, 2023
57cbaf7
make popup fit exactly 5 items
silverwind Nov 1, 2023
e873cb4
fit 4 items, add dedicated tippy theme
silverwind Nov 1, 2023
4996b72
document new theme
silverwind Nov 1, 2023
3719769
add comment and move rule
silverwind Nov 1, 2023
a91edb8
remove unused ShowHideButton variable
silverwind Nov 1, 2023
94d328c
update comment
silverwind Nov 1, 2023
ac890d5
clean up tippy.js and remove unused form-fetch-error theme
silverwind Nov 1, 2023
b22407b
Add comment
silverwind Nov 2, 2023
f9893fc
remove unnecessary "root" parameters for "repo/commit_statuses"
wxiaoguang Nov 2, 2023
0025ea9
better tippy width calc
wxiaoguang Nov 2, 2023
95062f1
fix
wxiaoguang Nov 2, 2023
ee19a33
avoid scrollbar flicker when show/hide the checks
wxiaoguang Nov 2, 2023
4e02ba0
fix lint
yp05327 Nov 2, 2023
6743030
Merge branch 'main' into improve-commit-status-ui
yp05327 Nov 2, 2023
a5f5953
fix
wxiaoguang Nov 2, 2023
5b8a735
add background color to box-with-header theme
silverwind Nov 2, 2023
222faec
update comment
silverwind Nov 2, 2023
0bf56ed
Merge branch 'main' into improve-commit-status-ui
GiteaBot Nov 2, 2023
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 @@ -1786,6 +1786,8 @@ pulls.status_checks_failure = Some checks failed
pulls.status_checks_error = Some checks reported errors
pulls.status_checks_requested = Required
pulls.status_checks_details = Details
pulls.status_checks_hide_all = Hide all checks
pulls.status_checks_show_all = Show all checks
pulls.update_branch = Update branch by merge
pulls.update_branch_rebase = Update branch by rebase
pulls.update_branch_success = Branch update was successful
Expand Down
3 changes: 3 additions & 0 deletions routers/web/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ func PrepareMergedViewPullInfo(ctx *context.Context, issue *issues_model.Issue)
if len(commitStatuses) != 0 {
ctx.Data["LatestCommitStatuses"] = commitStatuses
ctx.Data["LatestCommitStatus"] = git_model.CalcCommitStatus(commitStatuses)
ctx.Data["ShowHideButton"] = true
silverwind marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -556,6 +557,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
if len(commitStatuses) > 0 {
ctx.Data["LatestCommitStatuses"] = commitStatuses
ctx.Data["LatestCommitStatus"] = git_model.CalcCommitStatus(commitStatuses)
ctx.Data["ShowHideButton"] = true
}

compareInfo, err := baseGitRepo.GetCompareInfo(pull.BaseRepo.RepoPath(),
Expand Down Expand Up @@ -648,6 +650,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *issues_model.Issue) *git.C
if len(commitStatuses) > 0 {
ctx.Data["LatestCommitStatuses"] = commitStatuses
ctx.Data["LatestCommitStatus"] = git_model.CalcCommitStatus(commitStatuses)
ctx.Data["ShowHideButton"] = true
}

if pb != nil && pb.EnableStatusCheck {
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/branch/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{{if .DefaultBranchBranch.IsProtected}}{{svg "octicon-shield-lock"}}{{end}}
<a class="gt-ellipsis" href="{{.RepoLink}}/src/branch/{{PathEscapeSegments .DefaultBranchBranch.DBBranch.Name}}">{{.DefaultBranchBranch.DBBranch.Name}}</a>
<button class="btn interact-fg gt-px-2" data-clipboard-text="{{.DefaultBranchBranch.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button>
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID)}}
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID) "root" $}}
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
</div>
<p class="info gt-df gt-ac gt-my-2">{{svg "octicon-git-commit" 16 "gt-mr-2"}}<a href="{{.RepoLink}}/commit/{{PathEscape .DefaultBranchBranch.DBBranch.CommitID}}">{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage .RepoLink (.Repository.ComposeMetas ctx)}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DefaultBranchBranch.DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DefaultBranchBranch.DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}</p>
</td>
Expand Down Expand Up @@ -99,7 +99,7 @@
{{if .IsProtected}}{{svg "octicon-shield-lock"}}{{end}}
<a class="gt-ellipsis" href="{{$.RepoLink}}/src/branch/{{PathEscapeSegments .DBBranch.Name}}">{{.DBBranch.Name}}</a>
<button class="btn interact-fg gt-px-2" data-clipboard-text="{{.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button>
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DBBranch.CommitID)}}
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DBBranch.CommitID) "root" $}}
</div>
<p class="info gt-df gt-ac gt-my-2">{{svg "octicon-git-commit" 16 "gt-mr-2"}}<a href="{{$.RepoLink}}/commit/{{PathEscape .DBBranch.CommitID}}">{{ShortSha .DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DBBranch.CommitMessage $.RepoLink ($.Repository.ComposeMetas ctx)}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}} &nbsp;{{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p>
{{end}}
Expand Down
15 changes: 6 additions & 9 deletions templates/repo/commit_statuses.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@
</span>
{{end}}
<div class="tippy-target ui relaxed list divided">
{{range .Statuses}}
<div class="ui item singular-status gt-df">
{{template "repo/commit_status" .}}
<span class="ui gt-ml-3 gt-f1">{{.Context}} <span class="text grey">{{.Description}}</span></span>
{{if .TargetURL}}
<a class="gt-ml-3" href="{{.TargetURL}}" target="_blank" rel="noopener noreferrer">{{ctx.Locale.Tr "repo.pulls.status_checks_details"}}</a>
{{end}}
</div>
{{end}}
{{template "repo/pulls/status" (dict
"CommitStatuses" .Statuses
"CommitStatus" .Status
"IsPopup" true
"is_context_required" .root.is_context_required
)}}
</div>
{{end}}
6 changes: 5 additions & 1 deletion templates/repo/issue/view_content/pull.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
{{- else if .Issue.PullRequest.CanAutoMerge}}green
{{- else}}red{{end}}">{{svg "octicon-git-merge" 40}}</div>
<div class="content">
{{template "repo/pulls/status" .}}
{{template "repo/pulls/status" (dict
"CommitStatus" .LatestCommitStatus
"CommitStatuses" .LatestCommitStatuses
"is_context_required" .is_context_required
)}}
{{$showGeneralMergeForm := false}}
<div class="ui attached merge-section segment {{if not $.LatestCommitStatus}}no-header{{end}} flex-items-block">
{{if .Issue.PullRequest.HasMerged}}
Expand Down
79 changes: 49 additions & 30 deletions templates/repo/pulls/status.tmpl
Original file line number Diff line number Diff line change
@@ -1,34 +1,53 @@
{{if $.LatestCommitStatus}}
{{if not $.Issue.PullRequest.HasMerged}}
<div class="ui top attached header">
{{if eq .LatestCommitStatus.State "pending"}}
{{ctx.Locale.Tr "repo.pulls.status_checking"}}
{{else if eq .LatestCommitStatus.State "success"}}
{{ctx.Locale.Tr "repo.pulls.status_checks_success"}}
{{else if eq .LatestCommitStatus.State "warning"}}
{{ctx.Locale.Tr "repo.pulls.status_checks_warning"}}
{{else if eq .LatestCommitStatus.State "failure"}}
{{ctx.Locale.Tr "repo.pulls.status_checks_failure"}}
{{else if eq .LatestCommitStatus.State "error"}}
{{ctx.Locale.Tr "repo.pulls.status_checks_error"}}
{{else}}
{{ctx.Locale.Tr "repo.pulls.status_checking"}}
{{end}}
</div>
{{end}}
{{/*
Template Attributes:
* CommitStatus: summary of all commit status state
* CommitStatuses: all commit status elements
* IsPopup: whether this template is in a popup
* is_context_required: Used in pull request commit status check table
*/}}

{{if .CommitStatus}}
<div class="{{if .IsPopup}}tippy-commit-status{{else}}pr-commit-status{{end}}">
<div class="ui attached header top">
{{if eq .CommitStatus.State "pending"}}
{{ctx.Locale.Tr "repo.pulls.status_checking"}}
{{else if eq .CommitStatus.State "success"}}
{{ctx.Locale.Tr "repo.pulls.status_checks_success"}}
{{else if eq .CommitStatus.State "warning"}}
{{ctx.Locale.Tr "repo.pulls.status_checks_warning"}}
{{else if eq .CommitStatus.State "failure"}}
{{ctx.Locale.Tr "repo.pulls.status_checks_failure"}}
{{else if eq .CommitStatus.State "error"}}
{{ctx.Locale.Tr "repo.pulls.status_checks_error"}}
{{else}}
{{ctx.Locale.Tr "repo.pulls.status_checking"}}
{{end}}

{{range $.LatestCommitStatuses}}
<div class="ui attached segment pr-status">
{{template "repo/commit_status" .}}
<div class="status-context">
<span>{{.Context}} <span class="text grey">{{.Description}}</span></span>
<div class="ui status-details">
{{if $.is_context_required}}
{{if (call $.is_context_required .Context)}}<div class="ui label">{{ctx.Locale.Tr "repo.pulls.status_checks_requested"}}</div>{{end}}
{{end}}
<span>{{if .TargetURL}}<a href="{{.TargetURL}}">{{ctx.Locale.Tr "repo.pulls.status_checks_details"}}</a>{{end}}</span>
{{if not .IsPopup}}
<div class="ui right">
<button class="hide-all-checks btn interact-fg"
data-show-all="{{ctx.Locale.Tr "repo.pulls.status_checks_show_all"}}"
data-hide-all="{{ctx.Locale.Tr "repo.pulls.status_checks_hide_all"}}">
{{ctx.Locale.Tr "repo.pulls.status_checks_hide_all"}}</button>
</div>
{{end}}
</div>

<div class="ui attached segment commit-status-list">
{{range .CommitStatuses}}
<div class="ui attached segment commit-status-item">
{{template "repo/commit_status" .}}
<div class="status-context">
<span>{{.Context}} <span class="text grey">{{.Description}}</span></span>
<div class="ui status-details">
{{if $.is_context_required}}
{{if (call $.is_context_required .Context)}}<div class="ui label">{{ctx.Locale.Tr "repo.pulls.status_checks_requested"}}</div>{{end}}
{{end}}
<span>{{if .TargetURL}}<a href="{{.TargetURL}}">{{ctx.Locale.Tr "repo.pulls.status_checks_details"}}</a>{{end}}</span>
</div>
</div>
</div>
</div>
{{end}}
{{end}}
</div>
</div>
{{end}}
2 changes: 1 addition & 1 deletion web_src/css/modules/tippy.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

.tippy-content {
position: relative;
padding: 1rem;
padding: 0;
silverwind marked this conversation as resolved.
Show resolved Hide resolved
z-index: 1;
}

Expand Down
50 changes: 43 additions & 7 deletions web_src/css/repo.css
Original file line number Diff line number Diff line change
Expand Up @@ -3074,46 +3074,82 @@ tbody.commit-list {
}
}

.pr-status {
.commit-status-list {
padding: 0 !important;
max-height: 231px;
overflow-x: hidden;
transition: max-height 0.2s;
border-bottom: 0 !important;
}

.pr-commit-status.hide {
border-bottom: 0 !important;
}

.pr-commit-status.hide .ui.attached.header {
border-bottom: none !important;
}

.pr-commit-status.hide .commit-status-list {
max-height: 0;
silverwind marked this conversation as resolved.
Show resolved Hide resolved
}

.commit-status-item {
padding: 0 !important; /* To clear fomantic's padding on .ui.segment elements */
display: flex;
align-items: center;
}

.pr-status .commit-status {
.commit-status-item:first-child {
border-top: none !important;
}

.commit-status-item:last-child {
border-bottom: none !important;
}

.commit-status-item .commit-status {
margin: 1em;
flex-shrink: 0;
}

.pr-status .status-context {
.commit-status-item .status-context {
display: flex;
justify-content: space-between;
width: 100%;
}

.pr-status .status-context > span {
.commit-status-item .status-context > span {
padding: 1em 0;
}

.pr-status .status-details {
.commit-status-item .status-details {
display: flex;
padding-right: 0.5em;
align-items: center;
justify-content: flex-end;
}

@media (max-width: 767.98px) {
.pr-status .status-details {
.commit-status-item .status-details {
flex-direction: column;
align-items: flex-end;
justify-content: center;
}
}

.pr-status .status-details > span {
.commit-status-item .status-details > span {
padding-right: 0.5em; /* To match the alignment with the "required" label */
}

.tippy-commit-status {
max-width: calc(100vw - 16px);
}
yp05327 marked this conversation as resolved.
Show resolved Hide resolved

.tippy-commit-status .ui.attached.header {
border-top: 0 !important;
}

.search-fullname {
color: var(--color-text-light-2);
}
Expand Down
13 changes: 13 additions & 0 deletions web_src/js/features/repo-issue-pr-status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function initRepoPullRequestCommitStatus() {
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
const btn = document.querySelector('.hide-all-checks');
const prCommitStatus = document.querySelector('.pr-commit-status');
if (!btn) return;
btn.addEventListener('click', () => {
if (prCommitStatus.classList.contains('hide')) {
btn.textContent = btn.getAttribute('data-hide-all');
} else {
btn.textContent = btn.getAttribute('data-show-all');
}
prCommitStatus.classList.toggle('hide');
});
}
2 changes: 2 additions & 0 deletions web_src/js/features/repo-legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {initCommentContent, initMarkupContent} from '../markup/content.js';
import {initCompReactionSelector} from './comp/ReactionSelector.js';
import {initRepoSettingBranches} from './repo-settings.js';
import {initRepoPullRequestMergeForm} from './repo-issue-pr-form.js';
import {initRepoPullRequestCommitStatus} from './repo-issue-pr-status.js';
import {hideElem, showElem} from '../utils/dom.js';
import {getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkdownEditor.js';
import {attachRefIssueContextPopup} from './contextpopup.js';
Expand Down Expand Up @@ -546,6 +547,7 @@ export function initRepository() {
initCompReactionSelector($(document));

initRepoPullRequestMergeForm();
initRepoPullRequestCommitStatus();
}

// Pull request
Expand Down