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

Step one for a GitHub like commit status check ui:

![image](22953b88-1f91-4d19-bc57-ad92d33fa11f)

![image](78572a49-c9b0-472b-86a8-8293197e807b)

![image](bc5c8d1c-2ab5-4b03-b8c6-20c34b86d856)

Step two:

![image](938b359e-8823-4192-b82d-55fa40b986fd)

![image](2de5bb8f-40f5-462a-8d6d-bac13a32bc2a)

The design now will list all commit status checks which takes too much
space.
This is a pre-improve for #26247

---------

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
yp05327 2023-11-02 23:49:02 +09:00 committed by GitHub
parent 0ba4ecc3bd
commit dcb648ee71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 138 additions and 86 deletions

View file

@ -66,6 +66,7 @@ export function initCommitStatuses() {
placement: top ? 'top-start' : 'bottom-start',
interactive: true,
role: 'dialog',
theme: 'box-with-header',
});
});
}

View file

@ -0,0 +1,12 @@
export function initRepoPullRequestCommitStatus() {
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 = '');
}
}

View file

@ -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';
@ -546,6 +547,7 @@ export function initRepository() {
initCompReactionSelector($(document));
initRepoPullRequestMergeForm();
initRepoPullRequestCommitStatus();
}
// Pull request

View file

@ -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,
});