Skip to content

Commit 557287c

Browse files
JulianMaurinclaude
andcommitted
feat: deep-link the logs link to the batch-filtered activity log on batch PRs
Batch PRs get their logs link back, pointing at the activity log with the batch_pull filter (the batch's own lifecycle events) instead of the per-PR event log. The link stays on closed batch PRs — the batch's event history is the post-mortem trail. preset=Past1month widens the activity log's default 1-hour window, which would render empty for any batch older than an hour; same convention as the dashboard's own queue → activity-log deep link. MRGFY-7878 Test plan: - npx jest (279 passing) — open batch PR (queue=batch_pr, logs=batch_pull), closed batch PR (logs only), non-batch PRs keep the per-PR event-log link. - npx biome check — clean. Depends-On: Mergifyio/monorepo#36623 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QyefSTmdtUKXCSbYRJvSQu Change-Id: I5c6a720156143892c507ecfc3921f14c400a5b8b
1 parent 8a71382 commit 557287c

2 files changed

Lines changed: 42 additions & 14 deletions

File tree

src/__tests__/queue.test.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -901,32 +901,40 @@ describe("batch-PR informational links", () => {
901901
.map((a) => a.textContent.trim())
902902
.filter((t) => t === "queue" || t === "logs");
903903
}
904-
function queueHrefOf(row) {
904+
function hrefOf(row, label) {
905905
return [...row.querySelectorAll("a")]
906-
.find((a) => a.textContent.trim() === "queue")
906+
.find((a) => a.textContent.trim() === label)
907907
?.getAttribute("href");
908908
}
909909

910-
test("open batch PR: queue link deep-links via batch_pr, no logs link", () => {
910+
const BATCH_ACTIVITY_LOG_HREF =
911+
"https://dashboard.mergify.com/activity-log?login=acme&repository=widget&batch_pull=42&preset=Past1month";
912+
913+
test("open batch PR: queue link deep-links via batch_pr, logs link via batch_pull", () => {
911914
setPrDom({ draft: true, author: "mergify", baseRef: "develop" });
912915
const row = buildMergifyRow();
913-
expect(linkLabels(row)).toEqual(["queue"]);
914-
expect(queueHrefOf(row)).toBe(
916+
expect(linkLabels(row)).toEqual(["queue", "logs"]);
917+
expect(hrefOf(row, "queue")).toBe(
915918
"https://dashboard.mergify.com/queues/status?login=acme&repository=widget&branch=develop&batch_pr=42",
916919
);
920+
expect(hrefOf(row, "logs")).toBe(BATCH_ACTIVITY_LOG_HREF);
917921
});
918922

919-
test("closed batch PR: no queue link and no logs link", () => {
923+
test("closed batch PR: no queue link, logs link via batch_pull", () => {
920924
setPrDom({ closed: true, author: "mergify" });
921925
const row = buildMergifyRow();
922-
expect(linkLabels(row)).toEqual([]);
926+
expect(linkLabels(row)).toEqual(["logs"]);
927+
expect(hrefOf(row, "logs")).toBe(BATCH_ACTIVITY_LOG_HREF);
923928
});
924929

925-
test("open non-batch PR keeps both the queue and logs links", () => {
930+
test("open non-batch PR keeps both the queue and per-PR event-log links", () => {
926931
setPrDom({ author: "octocat", baseRef: "develop" });
927932
const row = buildMergifyRow();
928933
expect(linkLabels(row)).toEqual(["queue", "logs"]);
929-
expect(queueHrefOf(row)).toContain("pull-request-number=42");
934+
expect(hrefOf(row, "queue")).toContain("pull-request-number=42");
935+
expect(hrefOf(row, "logs")).toBe(
936+
"https://dashboard.mergify.com/event-logs?login=acme&repository=widget&pullRequestNumber=42",
937+
);
930938
});
931939

932940
test("closed human PR is unaffected — keeps both links", () => {

src/queue.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,23 +535,43 @@ function appendCommandButtons(container) {
535535
// Append the queue and logs links via the caller's appendLink(href, text, svg),
536536
// honoring batch-PR restrictions: the queue link points at the batch peek
537537
// drawer while the batch PR is open and is dropped once it closes (the batch
538-
// has drained — nothing to open); the logs link is omitted on batch PRs
539-
// entirely (not supported for batches yet).
538+
// has drained — nothing to open); the logs link points at the batch-filtered
539+
// activity log on batch PRs — kept on closed ones, where the batch's event
540+
// history is the post-mortem trail.
540541
function appendBatchAwareLinks(appendLink) {
541542
const batch = isBatchPrContext();
542543
if (!batch || isPullRequestOpen()) {
543544
appendLink(getMergeQueueLink(), "queue", QUEUE_ICON_SVG);
544545
}
545-
if (!batch) {
546-
appendLink(getEventLogLink(), "logs", LOGS_ICON_SVG);
547-
}
546+
appendLink(
547+
batch ? getBatchActivityLogLink() : getEventLogLink(),
548+
"logs",
549+
LOGS_ICON_SVG,
550+
);
548551
}
549552

550553
export function getEventLogLink() {
551554
const data = getPullRequestData();
552555
return `https://dashboard.mergify.com/event-logs?login=${data.org}&repository=${data.repo}&pullRequestNumber=${data.pull}`;
553556
}
554557

558+
// Activity log pivoted to a batch's own lifecycle events via its batch_pull
559+
// filter — a batch PR has no per-PR event log, so this replaces
560+
// getEventLogLink() on batch PRs. preset=Past1month widens the page's default
561+
// 1-hour window, which would render empty for any batch older than an hour
562+
// (a drained batch's post-mortem being the main use); same convention as the
563+
// dashboard's own queue → activity-log deep link.
564+
export function getBatchActivityLogLink() {
565+
const data = getPullRequestData();
566+
const params = new URLSearchParams({
567+
login: data.org,
568+
repository: data.repo,
569+
batch_pull: data.pull,
570+
preset: "Past1month",
571+
});
572+
return `https://dashboard.mergify.com/activity-log?${params}`;
573+
}
574+
555575
// Base branch of the current PR, read from the classic PR UI. The
556576
// `.commit-ref.base-ref` span is titled "owner/repo:branch"; ref names can't
557577
// contain ":", so everything after the first colon is the branch (which may

0 commit comments

Comments
 (0)