"use client"; import { RadioGroup, RadioGroupItem } from "@kandev/ui/radio-group"; import type { TaskGitCredentialsState } from "@/hooks/domains/github/use-task-git-credentials"; import type { TaskGitCredentialsMode } from "@/lib/types/github"; import { GitHubAccessHelp } from "./github-access-help"; import { useTranslation } from "react-i18next"; // Keyed by the wire mode, which is never translated. Catalog keys rather than // `t()` calls, because this is module scope (see docs/i18n.md). const taskAccessLabelKeys: Record = { managed: "github:managedWorkspaceCredentials", executor: "github:inheritExecutorGitCredentials", }; export function GitHubTaskAccessSummary({ mode, loading, error, }: Omit) { const { t } = useTranslation(); let value = t(taskAccessLabelKeys[mode]); if (loading) value = t("github:loadingTaskAccess"); if (error) value = t("github:taskAccessUnavailable"); return (
{t("github:taskAccess")} {value}
); } export function GitHubTaskAccessForm({ taskAccess, value, onChange, disabled, }: { taskAccess: TaskGitCredentialsState; value: TaskGitCredentialsMode; onChange: (value: TaskGitCredentialsMode) => void; disabled?: boolean; }) { const { t } = useTranslation(); return (

{t("github:taskGitAccess")}

{t("github:chooseHowNewlyLaunchedTasksAuthenticate")}

onChange(nextValue as TaskGitCredentialsMode)} disabled={taskAccess.loading || taskAccess.error || disabled} className="gap-2" >

{/* Env var names are identifiers the user must type exactly, so they are interpolated rather than left for the pseudo-locale to mangle. */} {t("github:anExecutorProfileGhTokenOr", { ghToken: "GH_TOKEN", githubToken: "GITHUB_TOKEN", })}

{taskAccess.error && (

{t("github:unableToLoadTheCurrentTask")}

)}
); }