mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
fix(feedback): gate ErrorDetails report-bug button on bugReportEnabled
Follow-up tobde167d— 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 inbde167dwould 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:
1 parent
bde167df75
commit
c63e4ded62
1 file changed
+10
-6
@@ -5,6 +5,7 @@ import { Copy, CheckCircle2, RotateCcw, Bug } from "lucide-react";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { useTranslations } from "@/lib/i18n/context";
|
import { useTranslations } from "@/lib/i18n/context";
|
||||||
|
import { useAppSettings } from "@/components/app-settings-provider";
|
||||||
|
|
||||||
export interface ErrorDetailsProps {
|
export interface ErrorDetailsProps {
|
||||||
/** The error object, whether it's a runtime Error or a typed API error. */
|
/** The error object, whether it's a runtime Error or a typed API error. */
|
||||||
@@ -32,6 +33,7 @@ export function ErrorDetails({
|
|||||||
reportHref = "/bugreport",
|
reportHref = "/bugreport",
|
||||||
}: ErrorDetailsProps) {
|
}: ErrorDetailsProps) {
|
||||||
const { t, locale } = useTranslations();
|
const { t, locale } = useTranslations();
|
||||||
|
const { bugReportEnabled } = useAppSettings();
|
||||||
const [copied, setCopied] = useState(false);
|
const [copied, setCopied] = useState(false);
|
||||||
|
|
||||||
async function handleCopy() {
|
async function handleCopy() {
|
||||||
@@ -95,12 +97,14 @@ export function ErrorDetails({
|
|||||||
)}
|
)}
|
||||||
{copied ? t("common.copied") : t("common.copyDetails")}
|
{copied ? t("common.copied") : t("common.copyDetails")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button asChild variant="outline" size="sm">
|
{bugReportEnabled && (
|
||||||
<Link href={reportHref}>
|
<Button asChild variant="outline" size="sm">
|
||||||
<Bug className="mr-2 h-4 w-4" />
|
<Link href={reportHref}>
|
||||||
{t("common.reportIssue")}
|
<Bug className="mr-2 h-4 w-4" />
|
||||||
</Link>
|
{t("common.reportIssue")}
|
||||||
</Button>
|
</Link>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user