Files
kandev/apps/web/lib/executor-icons.ts
T
José Almeida 3790fc148f fix(docker): use container icon for local docker executor too
Local docker tasks were rendering the Docker brand "chip" mark while
remote docker uses the container glyph. Map both variants to
IconContainer so the executor surfaces look consistent.
2026-05-05 21:19:23 +01:00

63 lines
1.7 KiB
TypeScript

import {
IconFolder,
IconFolders,
IconCloud,
IconCloudOff,
IconContainer,
IconContainerOff,
IconServer,
IconServerOff,
} from "@tabler/icons-react";
export const EXECUTOR_ICON_MAP: Record<string, typeof IconFolder> = {
local: IconFolder,
worktree: IconFolders,
local_docker: IconContainer,
remote_docker: IconContainer,
sprites: IconCloud,
};
export function getExecutorIcon(type: string): typeof IconFolder {
return EXECUTOR_ICON_MAP[type] ?? IconFolder;
}
const EXECUTOR_LABEL_MAP: Record<string, string> = {
local: "Local",
worktree: "Worktree",
local_docker: "Local Docker",
remote_docker: "Remote Docker",
sprites: "Sprites.dev",
};
export function getExecutorLabel(type: string): string {
return EXECUTOR_LABEL_MAP[type] ?? type;
}
/**
* Picks the status icon for the right-side executor popover button and the
* left-side cloud tooltip on cards/lists. The "Off" variants signal an error
* state (e.g. missing sandbox upstream) so the surface can swap glyph + color
* without each caller inventing its own mapping.
*/
export function getExecutorStatusIcon(
executorType: string | null | undefined,
hasError: boolean,
): { Icon: typeof IconFolder; testId: string } {
if (executorType === "local_docker" || executorType === "remote_docker") {
return {
Icon: hasError ? IconContainerOff : IconContainer,
testId: "executor-status-container-icon",
};
}
if (executorType === "sprites") {
return {
Icon: hasError ? IconCloudOff : IconCloud,
testId: "executor-status-cloud-icon",
};
}
return {
Icon: hasError ? IconServerOff : IconServer,
testId: "executor-status-server-icon",
};
}