fix(projects): pin the worktree actions right and put the count on the heading
Two layout defects the screenshots caught that the DOM tests could not. 1. `.proj-wt-row` was declared twice — my two-line-card rule earlier in the file, the original flex rule later. Same specificity, so the later copy won and the Open button sat against the text instead of at the card's right edge. Folded the grid into the ORIGINAL rule and left a note where the duplicate was. One rule per selector; a second declaration of a layout property is a silent override waiting to happen. 2. The unpushed count rendered as its own line under "Recent commits". The design has it ON the heading, because it qualifies that heading rather than making a separate statement. renderGitLog now takes the heading element and writes the badge there, clearing any previous badge first so a re-render cannot stack duplicates. Both were invisible to the existing assertions: they checked that the elements exist and carry the right text, which was true in each case. Added a test for the no-duplicate-badge path; the right-edge alignment is a pure CSS outcome and is verified by screenshot, not by the suite.
This commit is contained in:
@@ -100,8 +100,16 @@ function renderCommitRow(c: CommitLogEntry): HTMLElement {
|
||||
}
|
||||
|
||||
/** Render a GitLogResult into a container (clears first). Empty → an inert note. */
|
||||
export function renderGitLog(container: HTMLElement, log: GitLogResult): void {
|
||||
export function renderGitLog(
|
||||
container: HTMLElement,
|
||||
log: GitLogResult,
|
||||
labelEl?: HTMLElement,
|
||||
): void {
|
||||
container.textContent = ''
|
||||
// Design: the count sits ON the section heading, not on a line of its own —
|
||||
// it qualifies "Recent commits", it is not a separate statement.
|
||||
const badgeHost = labelEl ?? container
|
||||
badgeHost.querySelector('.proj-commitlog-count')?.remove()
|
||||
if (log.commits.length === 0) {
|
||||
container.append(el('div', 'proj-empty', 'No commits yet.'))
|
||||
return
|
||||
@@ -110,9 +118,9 @@ export function renderGitLog(container: HTMLElement, log: GitLogResult): void {
|
||||
// readable before the eye has walked the rows looking for rails.
|
||||
const unpushedCount = log.commits.filter((c) => c.unpushed === true).length
|
||||
if (unpushedCount > 0 && log.upstream !== undefined) {
|
||||
const badge = el('div', 'proj-commitlog-count', `↑ ${unpushedCount} unpushed`)
|
||||
const badge = el('span', 'proj-commitlog-count', `↑ ${unpushedCount} unpushed`)
|
||||
badge.title = `${unpushedCount} commit(s) not on ${log.upstream}`
|
||||
container.append(badge)
|
||||
badgeHost.append(badge)
|
||||
}
|
||||
|
||||
const list = el('div', 'proj-commitlog-list')
|
||||
@@ -150,7 +158,11 @@ export interface GitLogHandle {
|
||||
* the log, then swap in the rows. A fetch failure degrades to a short inert
|
||||
* message (never throws). destroy() removes the node and cancels the swap.
|
||||
*/
|
||||
export function mountGitLog(container: HTMLElement, repoPath: string): GitLogHandle {
|
||||
export function mountGitLog(
|
||||
container: HTMLElement,
|
||||
repoPath: string,
|
||||
labelEl?: HTMLElement,
|
||||
): GitLogHandle {
|
||||
let destroyed = false
|
||||
|
||||
container.textContent = ''
|
||||
@@ -164,7 +176,7 @@ export function mountGitLog(container: HTMLElement, repoPath: string): GitLogHan
|
||||
container.append(el('div', 'proj-empty', 'Could not read recent commits.'))
|
||||
return
|
||||
}
|
||||
renderGitLog(container, log)
|
||||
renderGitLog(container, log, labelEl)
|
||||
})()
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user