-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added file size and download confirmation for kernel files
- Loading branch information
Showing
6 changed files
with
111 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
frontend/src/components/modals/DownloadConfirmationModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import Modal from "@/components/ui/Modal"; | ||
import { Button } from "@/components/ui/button"; | ||
|
||
interface DownloadConfirmationModalProps { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
onDownload: () => void; | ||
fileName: string; | ||
fileSize: string; | ||
} | ||
|
||
const DownloadConfirmationModal = ({ | ||
isOpen, | ||
onClose, | ||
onDownload, | ||
fileName, | ||
fileSize, | ||
}: DownloadConfirmationModalProps) => { | ||
return ( | ||
<Modal isOpen={isOpen} onClose={onClose}> | ||
<div className="p-8 bg-gray-12 rounded-lg shadow-lg"> | ||
<h2 className="text-2xl font-bold mb-4 text-gray-2"> | ||
Download Kernel Image | ||
</h2> | ||
<div className="mb-6 space-y-2 text-gray-7"> | ||
<p>Are you sure you want to download this kernel image?</p> | ||
<p> | ||
<span className="text-gray-2 font-bold mb-4">File: </span> | ||
{fileName} | ||
</p> | ||
<p> | ||
<span className="text-gray-2 front-bold mb-4">Size: </span> | ||
{fileSize} | ||
</p> | ||
</div> | ||
<div className="flex justify-end space-x-4"> | ||
<Button onClick={onClose} variant="outline"> | ||
Cancel | ||
</Button> | ||
<Button | ||
onClick={() => { | ||
onDownload(); | ||
onClose(); | ||
}} | ||
variant="default" | ||
> | ||
Download | ||
</Button> | ||
</div> | ||
</div> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default DownloadConfirmationModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const formatFileSize = (bytes: number): string => { | ||
if (!bytes) return "0 B"; | ||
const k = 1024; | ||
const sizes = ["B", "KB", "MB", "GB"]; | ||
const i = Math.floor(Math.log(bytes) / Math.log(k)); | ||
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters