feat(formatters): add updateKey for suite/deployment/comment edit-in-place

This commit is contained in:
RhenCloud 2026-08-15 18:18:52 +08:00
parent 3af50496a7
commit 2f8a87048e
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
4 changed files with 12 additions and 0 deletions

View file

@ -21,6 +21,7 @@ export function formatCheckSuite(
showEmoji: boolean, showEmoji: boolean,
): NeutralMessage { ): NeutralMessage {
const suite = payload.check_suite as { const suite = payload.check_suite as {
id?: number;
head_branch?: string; head_branch?: string;
head_sha?: string; head_sha?: string;
conclusion?: string; conclusion?: string;
@ -78,6 +79,7 @@ export function formatCheckSuite(
suite.html_url ?? suite.html_url ??
(baseUrl && suite.head_sha ? `${baseUrl}/commit/${suite.head_sha}/checks` : undefined), (baseUrl && suite.head_sha ? `${baseUrl}/commit/${suite.head_sha}/checks` : undefined),
color: GITHUB_COLORS[colorKey], color: GITHUB_COLORS[colorKey],
updateKey: repo && suite.id != null ? `check_suite:${repo}:${suite.id}` : undefined,
fields, fields,
}, },
t, t,

View file

@ -16,6 +16,7 @@ export function formatIssueComment(
html_url?: string; html_url?: string;
}; };
const comment = payload.comment as { const comment = payload.comment as {
id?: number;
body?: string; body?: string;
html_url?: string; html_url?: string;
}; };
@ -35,6 +36,7 @@ export function formatIssueComment(
}), }),
url: comment.html_url ?? issue.html_url, url: comment.html_url ?? issue.html_url,
color: GITHUB_COLORS.issue_comment, color: GITHUB_COLORS.issue_comment,
updateKey: repo && comment.id != null ? `issue_comment:${repo}:${comment.id}` : undefined,
description: `${t("events.issue_comment.action_comment", { emoji: em("💬"), action: al })}\n\n> ${commentBody}${truncated ? "..." : ""}`, description: `${t("events.issue_comment.action_comment", { emoji: em("💬"), action: al })}\n\n> ${commentBody}${truncated ? "..." : ""}`,
}, },
t, t,

View file

@ -42,6 +42,7 @@ export function formatDeployment(
showEmoji: boolean, showEmoji: boolean,
): NeutralMessage { ): NeutralMessage {
const deployment = payload.deployment as { const deployment = payload.deployment as {
id?: number;
environment?: string; environment?: string;
ref?: string; ref?: string;
sha?: string; sha?: string;
@ -88,6 +89,7 @@ export function formatDeployment(
}), }),
url: deployment.html_url ?? deployment.statuses_url, url: deployment.html_url ?? deployment.statuses_url,
color: GITHUB_COLORS.deployment_pending, color: GITHUB_COLORS.deployment_pending,
updateKey: repo && deployment.id != null ? `deployment:${repo}:${deployment.id}` : undefined,
fields, fields,
}, },
t, t,
@ -109,6 +111,7 @@ export function formatDeploymentStatus(
description?: string; description?: string;
}; };
const deployment = payload.deployment as { const deployment = payload.deployment as {
id?: number;
sha?: string; sha?: string;
ref?: string; ref?: string;
environment?: string; environment?: string;
@ -163,6 +166,7 @@ export function formatDeploymentStatus(
author, author,
title: t("events.deployment.title", { repo: repo ?? t("common.repository"), env, state }), title: t("events.deployment.title", { repo: repo ?? t("common.repository"), env, state }),
color: GITHUB_COLORS[colorKey], color: GITHUB_COLORS[colorKey],
updateKey: repo && deployment.id != null ? `deployment:${repo}:${deployment.id}` : undefined,
fields, fields,
}, },
t, t,

View file

@ -11,6 +11,7 @@ export function formatPullRequestReview(
): NeutralMessage { ): NeutralMessage {
const action = (payload.action as string) ?? "submitted"; const action = (payload.action as string) ?? "submitted";
const review = payload.review as { const review = payload.review as {
id?: number;
state?: string; state?: string;
body?: string; body?: string;
html_url?: string; html_url?: string;
@ -50,6 +51,7 @@ export function formatPullRequestReview(
}), }),
url: review.html_url, url: review.html_url,
color: GITHUB_COLORS[colorKey], color: GITHUB_COLORS[colorKey],
updateKey: repo && review.id != null ? `pull_request_review:${repo}:${review.id}` : undefined,
description: descriptionParts.join("\n"), description: descriptionParts.join("\n"),
}, },
t, t,
@ -66,6 +68,7 @@ export function formatPullRequestReviewComment(
): NeutralMessage { ): NeutralMessage {
const action = (payload.action as string) ?? "created"; const action = (payload.action as string) ?? "created";
const comment = payload.comment as { const comment = payload.comment as {
id?: number;
body?: string; body?: string;
path?: string; path?: string;
position?: number | null; position?: number | null;
@ -105,6 +108,7 @@ export function formatPullRequestReviewComment(
}), }),
url: comment.html_url, url: comment.html_url,
color: GITHUB_COLORS.pull_request_review_commented, color: GITHUB_COLORS.pull_request_review_commented,
updateKey: repo && comment.id != null ? `pull_request_review_comment:${repo}:${comment.id}` : undefined,
description: `${t("events.pr_review_comment.action_inline", { emoji: em("💬"), action: al })}\n\n> ${commentBody}${truncated ? "..." : ""}`, description: `${t("events.pr_review_comment.action_inline", { emoji: em("💬"), action: al })}\n\n> ${commentBody}${truncated ? "..." : ""}`,
fields: fields.length > 0 ? fields : undefined, fields: fields.length > 0 ? fields : undefined,
}, },