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 all 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
2 changes: 1 addition & 1 deletion templates/repo/commit_page.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{{end}}
<div class="ui top attached header clearing segment gt-relative commit-header {{$class}}">
<div class="gt-df gt-mb-4 gt-fw">
<h3 class="gt-mb-0 gt-f1"><span class="commit-summary" title="{{.Commit.Summary}}">{{RenderCommitMessage $.Context .Commit.Message $.RepoLink ($.Repository.ComposeMetas ctx)}}</span>{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses "root" $}}</h3>
<h3 class="gt-mb-0 gt-f1"><span class="commit-summary" title="{{.Commit.Summary}}">{{RenderCommitMessage $.Context .Commit.Message $.RepoLink ($.Repository.ComposeMetas ctx)}}</span>{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses}}</h3>
{{if not $.PageIsWiki}}
<div>
<a class="ui primary tiny button" href="{{.SourcePath}}">
Expand Down
12 changes: 2 additions & 10 deletions templates/repo/commit_statuses.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@
{{template "repo/commit_status" .Status}}
</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}}
<div class="tippy-target">
{{template "repo/pulls/status" (dict "CommitStatuses" .Statuses "CommitStatus" .Status)}}
</div>
{{end}}
2 changes: 1 addition & 1 deletion templates/repo/commits_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
{{if IsMultilineCommitMessage .Message}}
<button class="ui button js-toggle-commit-body ellipsis-button" aria-expanded="false">...</button>
{{end}}
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $}}
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}}
{{if IsMultilineCommitMessage .Message}}
<pre class="commit-body gt-hidden">{{RenderCommitBody $.Context .Message $commitRepoLink ($.Repository.ComposeMetas ctx)}}</pre>
{{end}}
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/commits_list_small.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{{$commitLink:= printf "%s/commit/%s" $.comment.Issue.PullRequest.BaseRepo.Link (PathEscape .ID.String)}}

<span class="shabox gt-df gt-ac gt-float-right">
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses "root" $.root}}
{{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}}
{{$class := "ui sha label"}}
{{if .Signature}}
{{$class = (print $class " isSigned")}}
Expand Down
9 changes: 8 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,14 @@
{{- else if .Issue.PullRequest.CanAutoMerge}}green
{{- else}}red{{end}}">{{svg "octicon-git-merge" 40}}</div>
<div class="content">
{{template "repo/pulls/status" .}}
<div class="ui attached segment fitted">
silverwind marked this conversation as resolved.
Show resolved Hide resolved
{{template "repo/pulls/status" (dict
"CommitStatus" .LatestCommitStatus
"CommitStatuses" .LatestCommitStatuses
"ShowHideChecks" true
"is_context_required" .is_context_required
)}}
</div>
{{$showGeneralMergeForm := false}}
<div class="ui attached merge-section segment {{if not $.LatestCommitStatus}}no-header{{end}} flex-items-block">
{{if .Issue.PullRequest.HasMerged}}
Expand Down
67 changes: 42 additions & 25 deletions templates/repo/pulls/status.tmpl
Original file line number Diff line number Diff line change
@@ -1,34 +1,51 @@
{{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
* ShowHideChecks: whether use a button to show/hide the checks
* is_context_required: Used in pull request commit status check table
*/}}

{{if .CommitStatus}}
<div class="commit-status-panel">
<div class="ui top attached header commit-status-header">
{{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>
{{if .ShowHideChecks}}
<div class="ui right">
<button class="commit-status-hide-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="commit-status-list">
{{range .CommitStatuses}}
<div class="commit-status-item">
{{template "repo/commit_status" .}}
<div class="status-context gt-ellipsis">{{.Context}} <span class="text light-2">{{.Description}}</span></div>
<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>
{{end}}
{{end}}
</div>
</div>
{{end}}
2 changes: 1 addition & 1 deletion templates/repo/view_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{{template "repo/shabox_badge" dict "root" $ "verification" .LatestCommitVerification}}
{{end}}
</a>
{{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses "root" $}}
{{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}}
{{$commitLink:= printf "%s/commit/%s" .RepoLink (PathEscape .LatestCommit.ID.String)}}
<span class="grey commit-summary" title="{{.LatestCommit.Summary}}"><span class="message-wrapper">{{RenderCommitMessageLinkSubject $.Context .LatestCommit.Message $.RepoLink $commitLink ($.Repository.ComposeMetas ctx)}}</span>
{{if IsMultilineCommitMessage .LatestCommit.Message}}
Expand Down
2 changes: 1 addition & 1 deletion templates/shared/issuelist.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<a class="gt-no-underline issue-title" href="{{if .Link}}{{.Link}}{{else}}{{$.Link}}/{{.Index}}{{end}}">{{RenderEmoji $.Context .Title | RenderCodeBlock}}</a>
{{if .IsPull}}
{{if (index $.CommitStatuses .PullRequest.ID)}}
{{template "repo/commit_statuses" dict "Status" (index $.CommitLastStatus .PullRequest.ID) "Statuses" (index $.CommitStatuses .PullRequest.ID) "root" $}}
{{template "repo/commit_statuses" dict "Status" (index $.CommitLastStatus .PullRequest.ID) "Statuses" (index $.CommitStatuses .PullRequest.ID)}}
{{end}}
{{end}}
<span class="labels-list gt-ml-2">
Expand Down
57 changes: 35 additions & 22 deletions web_src/css/modules/tippy.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}

[data-tippy-root] {
max-width: calc(100vw - 10px);
max-width: calc(100vw - 32px);
}

.tippy-box {
Expand All @@ -18,37 +18,59 @@
font-size: 1rem;
}

.tippy-content {
position: relative;
padding: 1rem; /* if you need different padding, use different data-theme */
z-index: 1;
}

/* tooltip theme for text tooltips */

.tippy-box[data-theme="tooltip"] {
background-color: var(--color-tooltip-bg);
color: var(--color-tooltip-text);
border: none;
}

.tippy-box[data-theme="tooltip"] .tippy-content {
padding: 0.5rem 1rem;
}

.tippy-box[data-theme="tooltip"] .tippy-svg-arrow-inner,
.tippy-box[data-theme="tooltip"] .tippy-svg-arrow-outer {
fill: var(--color-tooltip-bg);
}

/* menu theme for .ui.menu */

.tippy-box[data-theme="menu"] {
background-color: var(--color-menu);
color: var(--color-text);
}

.tippy-box[data-theme="form-fetch-error"] {
border-color: var(--color-error-border);
background-color: var(--color-error-bg);
color: var(--color-error-text);
.tippy-box[data-theme="menu"] .tippy-content {
padding: 0;
}

.tippy-content {
position: relative;
padding: 1rem;
z-index: 1;
.tippy-box[data-theme="menu"] .tippy-svg-arrow-inner {
fill: var(--color-menu);
}

.tippy-box[data-theme="tooltip"] .tippy-content {
padding: 0.5rem 1rem;
}
/* box-with-header theme to look like .ui.attached.segment. can contain .ui.attached.header */

.tippy-box[data-theme="menu"] .tippy-content {
.tippy-box[data-theme="box-with-header"] .tippy-content {
background: var(--color-box-body);
padding: 0;
silverwind marked this conversation as resolved.
Show resolved Hide resolved
}

.tippy-box[data-theme="box-with-header"][data-placement^="top"] .tippy-svg-arrow-inner {
fill: var(--color-box-body);
}

.tippy-box[data-theme="box-with-header"][data-placement^="bottom"] .tippy-svg-arrow-inner {
fill: var(--color-box-header);
}

.tippy-box[data-placement^="top"] > .tippy-svg-arrow {
bottom: 0;
}
Expand Down Expand Up @@ -107,12 +129,3 @@
.tippy-svg-arrow-inner {
fill: var(--color-body);
}

.tippy-box[data-theme="tooltip"] .tippy-svg-arrow-inner,
.tippy-box[data-theme="tooltip"] .tippy-svg-arrow-outer {
fill: var(--color-tooltip-bg);
}

.tippy-box[data-theme="menu"] .tippy-svg-arrow-inner {
fill: var(--color-menu);
}
38 changes: 22 additions & 16 deletions web_src/css/repo.css
Original file line number Diff line number Diff line change
Expand Up @@ -3074,43 +3074,49 @@ tbody.commit-list {
}
}

.pr-status {
padding: 0 !important; /* To clear fomantic's padding on .ui.segment elements */
display: flex;
align-items: center;
.commit-status-header {
border: none !important; /* reset the default ".ui.attached.header" styles, to use the outer border */
margin: 0 !important;
}

.pr-status .commit-status {
margin: 1em;
flex-shrink: 0;
.commit-status-list {
max-height: 195px; /* fit exactly 4 items */
overflow-x: hidden;
transition: max-height .2s;
}

.pr-status .status-context {
.commit-status-item {
padding: 14px 10px !important;
display: flex;
justify-content: space-between;
width: 100%;
gap: 8px;
align-items: center;
border-top: 1px solid var(--color-secondary);
}

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

.pr-status .status-context > span {
padding: 1em 0;
.commit-status-item .status-context {
color: var(--color-text);
flex: 1;
}

.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 */
}

Expand Down
1 change: 1 addition & 0 deletions web_src/js/features/repo-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export function initCommitStatuses() {
placement: top ? 'top-start' : 'bottom-start',
interactive: true,
role: 'dialog',
theme: 'box-with-header',
});
});
}
12 changes: 12 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,12 @@
export function initRepoPullRequestCommitStatus() {
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
for (const btn of document.querySelectorAll('.commit-status-hide-checks')) {
const panel = btn.closest('.commit-status-panel');
const list = panel.querySelector('.commit-status-list');
btn.addEventListener('click', () => {
list.style.maxHeight = list.style.maxHeight ? '' : '0px'; // toggle
list.style.overflow = 'hidden'; // hide scrollbar when hiding
btn.textContent = btn.getAttribute(list.style.maxHeight ? 'data-show-all' : 'data-hide-all');
});
list.addEventListener('animationend', () => list.style.overflow = '');
}
}
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
2 changes: 1 addition & 1 deletion web_src/js/modules/tippy.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function createTippy(target, opts = {}) {
},
arrow: `<svg width="16" height="7"><path d="m0 7 8-7 8 7Z" class="tippy-svg-arrow-outer"/><path d="m0 8 8-7 8 7Z" class="tippy-svg-arrow-inner"/></svg>`,
role: 'menu', // HTML role attribute, only tooltips should use "tooltip"
theme: other.role || 'menu', // CSS theme, we support either "tooltip" or "menu"
theme: other.role || 'menu', // CSS theme, either "tooltip", "menu" or "box-with-header"
plugins: [followCursor],
...other,
});
Expand Down