refactor: remove unused state for log download in FailSafeModeOverlay (#993)

This commit is contained in:
Adam Shiervani 2025-11-20 17:48:56 +01:00 committed by GitHub
parent 661110cdb5
commit ba8a169ef2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 49 deletions

View File

@ -1,10 +1,9 @@
import { useState } from "react"; import { useState } from "react";
import { ExclamationTriangleIcon } from "@heroicons/react/24/solid"; import { ExclamationTriangleIcon } from "@heroicons/react/24/solid";
import { motion, AnimatePresence } from "framer-motion"; import { motion, AnimatePresence } from "framer-motion";
import { LuInfo } from "react-icons/lu";
import { Button } from "@/components/Button"; import { Button } from "@/components/Button";
import Card, { GridCard } from "@components/Card"; import { GridCard } from "@components/Card";
import { JsonRpcResponse, useJsonRpc } from "@/hooks/useJsonRpc"; import { JsonRpcResponse, useJsonRpc } from "@/hooks/useJsonRpc";
import { useDeviceUiNavigation } from "@/hooks/useAppNavigation"; import { useDeviceUiNavigation } from "@/hooks/useAppNavigation";
import { useVersion } from "@/hooks/useVersion"; import { useVersion } from "@/hooks/useVersion";
@ -34,40 +33,12 @@ function OverlayContent({ children }: OverlayContentProps) {
); );
} }
interface TooltipProps {
readonly children: React.ReactNode;
readonly text: string;
readonly show: boolean;
}
function Tooltip({ children, text, show }: TooltipProps) {
if (!show) {
return <>{children}</>;
}
return (
<div className="group/tooltip relative">
{children}
<div className="pointer-events-none absolute bottom-full left-1/2 mb-2 hidden -translate-x-1/2 opacity-0 transition-opacity group-hover/tooltip:block group-hover/tooltip:opacity-100">
<Card>
<div className="whitespace-nowrap px-2 py-1 text-xs flex items-center gap-1 justify-center">
<LuInfo className="h-3 w-3 text-slate-700 dark:text-slate-300" />
{text}
</div>
</Card>
</div>
</div>
);
}
export function FailSafeModeOverlay({ reason }: FailSafeModeOverlayProps) { export function FailSafeModeOverlay({ reason }: FailSafeModeOverlayProps) {
const { send } = useJsonRpc(); const { send } = useJsonRpc();
const { navigateTo } = useDeviceUiNavigation(); const { navigateTo } = useDeviceUiNavigation();
const { appVersion } = useVersion(); const { appVersion } = useVersion();
const { systemVersion } = useDeviceStore(); const { systemVersion } = useDeviceStore();
const [isDownloadingLogs, setIsDownloadingLogs] = useState(false); const [isDownloadingLogs, setIsDownloadingLogs] = useState(false);
const [hasDownloadedLogs, setHasDownloadedLogs] = useState(false);
const getReasonCopy = () => { const getReasonCopy = () => {
switch (reason) { switch (reason) {
@ -115,7 +86,6 @@ export function FailSafeModeOverlay({ reason }: FailSafeModeOverlayProps) {
URL.revokeObjectURL(url); URL.revokeObjectURL(url);
notifications.success("Crash logs downloaded successfully"); notifications.success("Crash logs downloaded successfully");
setHasDownloadedLogs(true);
// Open GitHub issue // Open GitHub issue
const issueBody = `## Issue Description const issueBody = `## Issue Description
@ -182,25 +152,19 @@ Please attach the recovery logs file that was downloaded to your computer:
/> />
<div className="h-8 w-px bg-slate-200 dark:bg-slate-700 block" /> <div className="h-8 w-px bg-slate-200 dark:bg-slate-700 block" />
<Tooltip text="Download logs first" show={!hasDownloadedLogs}>
<Button <Button
onClick={() => navigateTo("/settings/general/reboot")} onClick={() => navigateTo("/settings/general/reboot")}
theme="light" theme="light"
size="SM" size="SM"
text="Reboot Device" text="Reboot Device"
disabled={!hasDownloadedLogs}
/> />
</Tooltip>
<Tooltip text="Download logs first" show={!hasDownloadedLogs}>
<Button <Button
size="SM" size="SM"
onClick={handleDowngrade} onClick={handleDowngrade}
theme="light" theme="light"
text={`Downgrade to v${DOWNGRADE_VERSION}`} text={`Downgrade to v${DOWNGRADE_VERSION}`}
disabled={!hasDownloadedLogs}
/> />
</Tooltip>
</div> </div>