Файли
openidea/src/features/vcs/CommitCheckSummary.tsx
T
Akbar Husain aa1b6c1ce0 perf(lint): fix React performance lint violations (#5503)
Clears the React-specific violations reported by oxlint's `perf` category: 123 array-index keys, 28 constructed context values and 6 object/array default props. Keys now use a stable data id where one exists, and the index with a short documented suppression where position is the real identity (editable rows, streams, repeated data). Context values are memoized or hoisted, and default literals are module-level constants. Enabling the `perf` category itself is handled separately; this PR only fixes the violations.

Co-authored-by: akbar1214 <[email protected]>
2026-11-24 08:06:54 +08:00

61 рядки
1.8 KiB
TypeScript

import { tx } from "@/platform/i18n";
import { Icon, T } from "@/ui";
import type { CommitCheckRun } from "./commitChecks";
import styles from "./CommitView.module.css";
export function CommitCheckSummary({
result,
onInspect,
onOpenToolWindow,
}: {
result: CommitCheckRun & { stale?: boolean };
onInspect?: () => void;
onOpenToolWindow?: () => void;
}) {
const passed = !result.problems.length;
return (
<div
className={styles.checkProblems}
role={result.blocked && !result.stale ? "alert" : "status"}
onClick={(event) => {
if (event.target instanceof Element && event.target.closest("button")) onInspect?.();
}}
>
<Icon
name={passed ? "check" : "warning"}
size={14}
className={passed ? styles.checkPassedIcon : styles.checkProblemsIcon}
/>
<div className={styles.checkProblemsList}>
{passed ? (
<T>Commit checks passed</T>
) : (
result.problems.map((p, i) => (
// oxlint-disable-next-line react/no-array-index-key -- problem titles can repeat; position is the identity
<div key={i}>
<span className={styles.checkProblemTitle}>{tx(p.title)}</span>
{" · "}
{typeof p.text === "string" ? tx(p.text) : p.text}
{p.details && (
<>
{" "}
<button
type="button"
className={styles.checkProblemLink}
onClick={() => {
if (p.details?.opensToolWindow) onOpenToolWindow?.();
void p.details?.run();
}}
>
{tx(p.details.label)}
</button>
</>
)}
</div>
))
)}
</div>
</div>
);
}