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
7 changes: 5 additions & 2 deletions src/components/docs/versions/builds/build-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ export default function BuildRow({ children, build }: Props) {
switch (status) {
case 'started':
return <Spinner type="slow" />;
case 'failed':
return <Tooltip content={build.failure?.reason}>{icon}</Tooltip>;
case 'failed': {
const failureCount = build.meta?.failureCount || 0;
const label = failureCount >= 15 ? `${icon} (${failureCount}/15)` : icon;
return <Tooltip content={build.failure?.reason}>{label}</Tooltip>;
}
case 'published':
return icon;
default:
Expand Down
42 changes: 35 additions & 7 deletions src/components/docs/versions/docker-image-link-or-retry-button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState } from 'react';
import { HiOutlineRefresh } from 'react-icons/hi';
import { MdRestartAlt } from 'react-icons/md';
import { SimpleAuthCheck } from '@site/src/components/auth/safe-auth-check';
import DockerImageLink from '@site/src/components/docs/versions/docker-image-link';
import { useAuthenticatedEndpoint } from '@site/src/core/hooks/use-authenticated-endpoint';
Expand All @@ -21,6 +22,9 @@ type Record = {
imageRepo: string;
imageName: string;
};
meta?: {
failureCount?: number;
};
status: string;
[key: string]: any;
};
Expand All @@ -32,21 +36,23 @@ interface Props {
export { Record };

const DockerImageLinkOrRetryButton = ({ record }: Props) => {
const { buildInfo, dockerInfo, buildId, relatedJobId, status } = record;
const { buildInfo, dockerInfo, buildId, relatedJobId, status, meta } = record;
const { baseOs, editorVersion, targetPlatform, repoVersion } = buildInfo;
const { imageRepo, imageName } = dockerInfo || {};
const imageTag = `${baseOs}-${editorVersion}-${targetPlatform}-${repoVersion}`;

const [retryRequested, setRetryRequested] = useState<boolean>(false);
const [resetRequested, setResetRequested] = useState<boolean>(false);
const notify = useNotification();
const retryBuild = useAuthenticatedEndpoint('retryBuild', { buildId, relatedJobId });
const resetBuild = useAuthenticatedEndpoint('resetFailedBuilds', { buildId });

// Also show the retry button when the build has been sent to `failed` manually.
if (dockerInfo && status !== 'failed') {
return <DockerImageLink imageRepo={imageRepo} imageName={imageName} imageTag={imageTag} />;
}

const onClick = async () => {
const onRetryClick = async () => {
try {
setRetryRequested(true);
await notify.promise(retryBuild(), {
Expand All @@ -59,17 +65,39 @@ const DockerImageLinkOrRetryButton = ({ record }: Props) => {
}
};

const onResetClick = async () => {
try {
setResetRequested(true);
await notify.promise(resetBuild(), {
loading: <Spinner type="spin" />,
success: (response) => response.message,
error: (error) => error.message,
});
} catch {
setResetRequested(false);
}
};

const failureCount = meta?.failureCount || 0;
const isMaxedOut = failureCount >= 15;
const buttonStyle = { padding: 0, border: 0, outline: 0, cursor: 'pointer' };

return (
<SimpleAuthCheck fallback={<span />} requiredClaims={{ admin: true }}>
<Tooltip content={`Delete tag "${imageTag}" then click this retry button.`}>
<button
type="button"
onClick={onClick}
style={{ padding: 0, border: 0, outline: 0, cursor: 'pointer' }}
>
<button type="button" onClick={onRetryClick} style={buttonStyle}>
<HiOutlineRefresh color={retryRequested ? 'orange' : 'red'} />
</button>
</Tooltip>
{isMaxedOut && (
<Tooltip
content={`Reset failure count (${failureCount}) so Ingeminator retries this build.`}
>
<button type="button" onClick={onResetClick} style={buttonStyle}>
<MdRestartAlt color={resetRequested ? 'orange' : '#b45309'} />
</button>
Comment on lines +88 to +98
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add accessible names to icon-only action buttons.

Both action buttons are icon-only, so screen readers get unnamed controls. Add explicit aria-labels.

Suggested fix
-        <button type="button" onClick={onRetryClick} style={buttonStyle}>
+        <button
+          type="button"
+          onClick={onRetryClick}
+          style={buttonStyle}
+          aria-label={`Retry build ${buildId}`}
+        >
           <HiOutlineRefresh color={retryRequested ? 'orange' : 'red'} />
         </button>
@@
-          <button type="button" onClick={onResetClick} style={buttonStyle}>
+          <button
+            type="button"
+            onClick={onResetClick}
+            style={buttonStyle}
+            aria-label={`Reset failure count for build ${buildId}`}
+          >
             <MdRestartAlt color={resetRequested ? 'orange' : '#b45309'} />
           </button>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<button type="button" onClick={onRetryClick} style={buttonStyle}>
<HiOutlineRefresh color={retryRequested ? 'orange' : 'red'} />
</button>
</Tooltip>
{isMaxedOut && (
<Tooltip
content={`Reset failure count (${failureCount}) so Ingeminator retries this build.`}
>
<button type="button" onClick={onResetClick} style={buttonStyle}>
<MdRestartAlt color={resetRequested ? 'orange' : '#b45309'} />
</button>
<button
type="button"
onClick={onRetryClick}
style={buttonStyle}
aria-label={`Retry build ${buildId}`}
>
<HiOutlineRefresh color={retryRequested ? 'orange' : 'red'} />
</button>
</Tooltip>
{isMaxedOut && (
<Tooltip
content={`Reset failure count (${failureCount}) so Ingeminator retries this build.`}
>
<button
type="button"
onClick={onResetClick}
style={buttonStyle}
aria-label={`Reset failure count for build ${buildId}`}
>
<MdRestartAlt color={resetRequested ? 'orange' : '#b45309'} />
</button>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/docs/versions/docker-image-link-or-retry-button.tsx` around
lines 88 - 98, The icon-only action buttons rendered with onRetryClick and
onResetClick lack accessible names; add explicit aria-label attributes to the
retry and reset buttons (the elements using HiOutlineRefresh and MdRestartAlt)
so screen readers announce them (e.g., aria-label={`Retry build${retryRequested
? ' requested' : ''}`} and aria-label={`Reset failures
(${failureCount})${resetRequested ? ' requested' : ''}`}), keeping the existing
onClick handlers and visual styling intact.

</Tooltip>
)}
</SimpleAuthCheck>
);
};
Expand Down
Loading