Skip to content
Open
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
36 changes: 22 additions & 14 deletions services/hackbot-ui/components/RunDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ import { parseTestPlan, TestPlanView } from "./TestPlanView";
// approves the actual text and not just an action type. A comment carries its
// body in params.text; a Phabricator submission carries the title and summary of
// the revision it would open for the patch (previewed by PatchView).
function actionPreview(a: RunAction): { label: string; text: string } | null {
function actionPreview(
action: RunAction
): { label: string; text: string } | null {
const text = (v: unknown): string =>
typeof v === "string" && v.trim() ? v : "";
if (a.type === "bugzilla.add_comment") {
const body = text(a.params?.text);
if (action.type === "bugzilla.add_comment") {
const body = text(action.params?.text);
return body ? { label: "Comment preview", text: body } : null;
}
if (a.type === "phabricator.submit_patch") {
const body = [text(a.params?.title), text(a.params?.summary)]
if (action.type === "phabricator.submit_patch") {
const body = [text(action.params?.title), text(action.params?.summary)]
.filter(Boolean)
.join("\n\n");
return body ? { label: "Revision preview", text: body } : null;
Expand Down Expand Up @@ -192,9 +194,9 @@ export function RunDetail({
// Both pending and failed actions are (re)applied by the apply endpoint — it
// skips only already-applied ones — so one button covers applying and retry.
const pendingActions =
actions?.filter((a) => a.status === "pending").length ?? 0;
actions?.filter((action) => action.status === "pending").length ?? 0;
const failedActions =
actions?.filter((a) => a.status === "failed").length ?? 0;
actions?.filter((action) => action.status === "failed").length ?? 0;
const applyLabel =
pendingActions && failedActions
? "Apply pending & retry failed actions"
Expand Down Expand Up @@ -296,21 +298,27 @@ export function RunDetail({
<h2>Actions ({actions.length})</h2>
{applyError && <div className="error-banner">{applyError}</div>}
<ul className="action-list">
{actions.map((a) => {
const preview = actionPreview(a);
{actions.map((action) => {
const preview = actionPreview(action);
const url =
typeof a.result?.url === "string" ? a.result.url : null;
typeof action.result?.url === "string"
? action.result.url
: null;
return (
<li key={a.idx}>
<li key={action.idx}>
<div className="action-row">
<span className={`badge ${a.status}`}>{a.status}</span>
<code>{a.type}</code>
<span className={`badge ${action.status}`}>
{action.status}
</span>
<code>{action.type}</code>
{url && (
<a href={url} target="_blank" rel="noreferrer">
Open
</a>
)}
{a.error && <span className="muted">{a.error}</span>}
{action.error && (
<span className="muted">{action.error}</span>
)}
</div>
{preview && (
<div className="action-preview">
Expand Down