|
2 | 2 | import { Microchip, TriangleAlert } from '@lucide/svelte'; |
3 | 3 | import { DownloadAndVerifyBoardBinary } from '$lib/api/firmwareCDN'; |
4 | 4 | import { Button } from '$lib/components/ui/button'; |
| 5 | + import * as Dialog from '$lib/components/ui/dialog'; |
5 | 6 | import { Progress } from '$lib/components/ui/progress'; |
6 | 7 | import FlashManager from './FlashManager'; |
7 | 8 |
|
|
10 | 11 | board: string; |
11 | 12 | manager: FlashManager; |
12 | 13 | eraseBeforeFlash: boolean; |
| 14 | + showNonStableWarning: boolean; |
13 | 15 | isFlashing?: boolean; |
14 | 16 | } |
15 | 17 |
|
|
18 | 20 | board, |
19 | 21 | manager, |
20 | 22 | eraseBeforeFlash, |
| 23 | + showNonStableWarning, |
21 | 24 | isFlashing = $bindable(false), |
22 | 25 | }: Props = $props(); |
23 | 26 |
|
| 27 | + let riskAcknowledgeStatus = $state<'none' | 'shown' | 'accepted'>('none'); |
24 | 28 | let progressName = $state<string | null>(null); |
25 | 29 | let progressPercent = $state<number | null>(null); |
26 | 30 | let error = $state<string | null>(null); |
|
65 | 69 | } |
66 | 70 | async function FlashDevice() { |
67 | 71 | if (isFlashing) return; |
| 72 | + if (showNonStableWarning && riskAcknowledgeStatus !== 'accepted') { |
| 73 | + riskAcknowledgeStatus = 'shown'; |
| 74 | + return; |
| 75 | + } |
68 | 76 | try { |
69 | 77 | isFlashing = true; |
70 | 78 | await FlashDeviceImpl(); |
|
76 | 84 | } |
77 | 85 | </script> |
78 | 86 |
|
| 87 | +<!-- Risk acknowledgement modal --> |
| 88 | +<Dialog.Root open={riskAcknowledgeStatus === 'shown'}> |
| 89 | + <Dialog.Content> |
| 90 | + <Dialog.Header> |
| 91 | + <Dialog.Title>⚠️ Unstable Firmware Warning</Dialog.Title> |
| 92 | + <Dialog.Description> |
| 93 | + You are about to install <strong class="text-red-500">experimental, non-stable firmware</strong>. |
| 94 | + <br /><br /> |
| 95 | + This firmware is <strong class="text-red-500">not intended for general use</strong> and may contain |
| 96 | + serious bugs, regressions, or incomplete features. |
| 97 | + <br /><br /> |
| 98 | + <strong class="text-red-500">No support is provided for issues caused by non-stable firmware.</strong> |
| 99 | + </Dialog.Description> |
| 100 | + </Dialog.Header> |
| 101 | + |
| 102 | + <div class="flex justify-end gap-2"> |
| 103 | + <Button |
| 104 | + variant="secondary" |
| 105 | + onclick={() => (riskAcknowledgeStatus = 'none')} |
| 106 | + > |
| 107 | + Cancel |
| 108 | + </Button> |
| 109 | + |
| 110 | + <Button |
| 111 | + variant="destructive" |
| 112 | + onclick={() => (riskAcknowledgeStatus = 'accepted')} |
| 113 | + > |
| 114 | + I UNDERSTAND AND ACCEPT ALL RISKS |
| 115 | + </Button> |
| 116 | + </div> |
| 117 | + </Dialog.Content> |
| 118 | +</Dialog.Root> |
| 119 | + |
79 | 120 | <div class="flex flex-col items-stretch justify-start gap-4"> |
80 | 121 | <!-- Flash button --> |
81 | 122 | <Button onclick={FlashDevice} disabled={!manager || isFlashing}> |
|
0 commit comments