fix(feedback): gate ErrorDetails report-bug button on bugReportEnabled

Follow-up to bde167d — the test landed but the implementation file
was unstaged at commit time (the prior `git add` only picked up the
new test file). This commit applies the actual gating: import
`useAppSettings()` and wrap the `<Button asChild>` in
`{bugReportEnabled && (...)}` so the button disappears when the
admin disables the feature.

Without this, the test in bde167d would have failed for the disabled
branch (the button would still render). Verified locally with `pnpm
test --run src/components/__tests__/error-details.test.tsx` — both
branches green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marc-André BombeckandClaude Opus 4.7 committed 2026-05-09 20:19:47 +02:00
1 parent bde167df75
commit c63e4ded62
1 file changed
+10 -6
+10 -6
View File
@@ -5,6 +5,7 @@ import { Copy, CheckCircle2, RotateCcw, Bug } from "lucide-react";
import Link from "next/link";
import { Button } from "@/components/ui/button";
import { useTranslations } from "@/lib/i18n/context";
import { useAppSettings } from "@/components/app-settings-provider";
export interface ErrorDetailsProps {
/** The error object, whether it's a runtime Error or a typed API error. */
@@ -32,6 +33,7 @@ export function ErrorDetails({
reportHref = "/bugreport",
}: ErrorDetailsProps) {
const { t, locale } = useTranslations();
const { bugReportEnabled } = useAppSettings();
const [copied, setCopied] = useState(false);
async function handleCopy() {
@@ -95,12 +97,14 @@ export function ErrorDetails({
)}
{copied ? t("common.copied") : t("common.copyDetails")}
</Button>
<Button asChild variant="outline" size="sm">
<Link href={reportHref}>
<Bug className="mr-2 h-4 w-4" />
{t("common.reportIssue")}
</Link>
</Button>
{bugReportEnabled && (
<Button asChild variant="outline" size="sm">
<Link href={reportHref}>
<Bug className="mr-2 h-4 w-4" />
{t("common.reportIssue")}
</Link>
</Button>
)}
</div>
</div>
);