Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@
"message": "$count$ files",
"placeholders": { "count": { "content": "$1", "example": "5" } }
},
"prDiffStatsLinkHint": {
"message": "Click to view file changes"
},
"diffStatsTitle": {
"message": "$add$ additions, $del$ deletions",
"placeholders": {
Expand Down
3 changes: 3 additions & 0 deletions src/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@
"message": "$count$ 个文件",
"placeholders": { "count": { "content": "$1", "example": "5" } }
},
"prDiffStatsLinkHint": {
"message": "点击查看文件变更"
},
"diffStatsTitle": {
"message": "新增 $add$ 行,删除 $del$ 行",
"placeholders": {
Expand Down
3 changes: 3 additions & 0 deletions src/_locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@
"message": "$count$ 個檔案",
"placeholders": { "count": { "content": "$1", "example": "5" } }
},
"prDiffStatsLinkHint": {
"message": "點擊查看檔案變更"
},
"diffStatsTitle": {
"message": "新增 $add$ 行,刪除 $del$ 行",
"placeholders": {
Expand Down
2 changes: 1 addition & 1 deletion src/features/pr-diff-stats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("injectPRDiffStats", () => {
expect(badge7.querySelector(".better-github-diff-stats-add")?.textContent).toBe("+1,234");
expect(badge7.querySelector(".better-github-diff-stats-del")?.textContent).toBe("−56");
expect(badge7.querySelector(".better-github-diff-stats-files")?.textContent).toBe("3 files");
expect(badge7.title).toBe("1,234 additions, 56 deletions across 3 files");
expect(badge7.title).toBe("1,234 additions, 56 deletions across 3 files\nClick to view file changes");

// changedFiles === 1 → singular "file".
const badge8 = document.querySelector("#issue_8 .better-github-diff-stats") as HTMLElement;
Expand Down
8 changes: 7 additions & 1 deletion src/features/pr-diff-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fetchPRDiffStats } from "../lib/github-api";
import { insertInfoRowItem } from "../lib/info-row";
import { buildDiffStatsBadge } from "../lib/diff-stats-badge";
import { clearSkeletons } from "../lib/info-row-skeleton";
import { t } from "../lib/i18n";

const BADGE_CLASS = "better-github-diff-stats";

Expand Down Expand Up @@ -32,7 +33,12 @@ export async function injectPRDiffStats(): Promise<void> {

if (row.querySelector(`.${BADGE_CLASS}`)) continue;

insertInfoRowItem(row, "diff", buildDiffStatsBadge(stat, BADGE_CLASS));
const link = document.createElement("a");
link.href = `/${info.owner}/${info.repo}/pull/${prNumber}/changes`;
const badge = buildDiffStatsBadge(stat, BADGE_CLASS);
badge.title += `\n${t("prDiffStatsLinkHint")}`;
link.appendChild(badge);
insertInfoRowItem(row, "diff", link);
}
} finally {
clearSkeletons("prDiff");
Expand Down
Loading