Merge pull request #17549 from desktop/commit-summary-expansion-lines-changed

Commit Summary Expansion: Replace added/deleted lines tooltip with plain text
This commit is contained in:
tidy-dev 2023-10-18 07:54:08 -04:00 committed by GitHub
commit 467e62b6c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 30 deletions

View file

@ -12,7 +12,6 @@ import { CommitAttribution } from '../lib/commit-attribution'
import { Tokenizer, TokenResult } from '../../lib/text-token-parser'
import { wrapRichTextCommitMessage } from '../../lib/wrap-rich-text-commit-message'
import { IChangesetData } from '../../lib/git'
import { TooltippedContent } from '../lib/tooltipped-content'
import uniqWith from 'lodash/uniqWith'
import { LinkButton } from '../lib/link-button'
import { UnreachableCommitsTab } from './unreachable-commits-dialog'
@ -544,34 +543,29 @@ export class ExpandableCommitSummary extends React.Component<
}
private renderLinesChanged() {
const linesAdded = this.props.changesetData.linesAdded
const linesDeleted = this.props.changesetData.linesDeleted
if (linesAdded + linesDeleted === 0) {
const { changesetData, selectedCommits, isExpanded } = this.props
const { linesAdded, linesDeleted } = changesetData
if (
(linesAdded === 0 && linesDeleted === 0) ||
selectedCommits.length > 1
) {
return null
}
const linesAddedPlural = linesAdded === 1 ? 'line' : 'lines'
const linesDeletedPlural = linesDeleted === 1 ? 'line' : 'lines'
const linesAddedTitle = `${linesAdded} ${linesAddedPlural} added`
const linesDeletedTitle = `${linesDeleted} ${linesDeletedPlural} deleted`
return (
<>
<TooltippedContent
tagName="div"
className="ecs-meta-item without-truncation lines-added"
tooltip={linesAddedTitle}
>
+{linesAdded}
</TooltippedContent>
<TooltippedContent
tagName="div"
className="ecs-meta-item without-truncation lines-deleted"
tooltip={linesDeletedTitle}
>
-{linesDeleted}
</TooltippedContent>
</>
<div className="ecs-meta-item lines-added-deleted">
<div className="lines-added">
{!isExpanded ? <>+{linesAdded}</> : <>{linesAdded} added lines</>}
</div>
<div className="lines-deleted">
{!isExpanded ? (
<>-{linesDeleted}</>
) : (
<>{linesDeleted} removed lines</>
)}
</div>
</div>
)
}

View file

@ -171,12 +171,18 @@
}
}
&.lines-added {
color: var(--color-new);
}
&.lines-added-deleted {
div {
padding-right: var(--spacing-half);
}
&.lines-deleted {
color: var(--color-deleted);
.lines-added {
color: var(--color-new);
}
.lines-deleted {
color: var(--color-deleted);
}
}
.tags {