From fc5cb6cde23814cbd04e9bb97538d2f4a5f8dcc9 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Sat, 28 Dec 2024 16:17:41 +0100 Subject: [PATCH] UI/flash: use modal for confirmation --- pkgs/webview-ui/app/src/routes/flash/view.tsx | 108 +++++++++++------- 1 file changed, 68 insertions(+), 40 deletions(-) diff --git a/pkgs/webview-ui/app/src/routes/flash/view.tsx b/pkgs/webview-ui/app/src/routes/flash/view.tsx index dcdff3d97..6033b0153 100644 --- a/pkgs/webview-ui/app/src/routes/flash/view.tsx +++ b/pkgs/webview-ui/app/src/routes/flash/view.tsx @@ -20,6 +20,7 @@ import { createEffect, createSignal, For, Show } from "solid-js"; import toast from "solid-toast"; import { FieldLayout } from "@/src/Form/fields/layout"; import { InputLabel } from "@/src/components/inputBase"; +import { Modal } from "@/src/components/modal"; interface Wifi extends FieldValues { ssid: string; @@ -53,7 +54,7 @@ export const Flash = () => { /* ==== WIFI NETWORK ==== */ const [wifiNetworks, setWifiNetworks] = createSignal([]); const [passwordVisibility, setPasswordVisibility] = createSignal( - [], + [] ); createEffect(() => { @@ -77,7 +78,7 @@ export const Flash = () => { const updatedNetworks = wifiNetworks().filter((_, i) => i !== index); setWifiNetworks(updatedNetworks); const updatedVisibility = passwordVisibility().filter( - (_, i) => i !== index, + (_, i) => i !== index ); setPasswordVisibility(updatedVisibility); setValue(formStore, "wifi", updatedNetworks); @@ -144,11 +145,15 @@ export const Flash = () => { } return dataTransfer.files; }; + const [confirmOpen, setConfirmOpen] = createSignal(false); - const handleSubmit = async (values: FlashFormValues) => { + const handleConfirm = async (values: FlashFormValues) => { + setConfirmOpen(true); console.log("Submit:", values); toast.error("Not fully implemented yet"); // Disabled for now. To prevent accidental flashing of local disks + // User should confirm the disk to flash to + // try { // await callApi("flash_machine", { // machine: { @@ -177,6 +182,30 @@ export const Flash = () => { return ( <>
+ setConfirmOpen(false)} + title="Confirm" + > +
+
+ + Warning: All data on will be lost. +
+ Selected disk: '{getValue(formStore, "disk")}' +
+
+
+ + +
+
+
USB Utility image. @@ -185,7 +214,7 @@ export const Flash = () => { Will make bootstrapping new machines easier by providing secure remote connection to any machine when plugged in. -
+
{(field, props) => ( @@ -242,7 +271,7 @@ export const Flash = () => { value={field.value || ""} error={field.error} required - placeholder="Select a thing where the installer will be flashed to" + placeholder="Select a drive where the clan-installer will be flashed to" options={ deviceQuery.data?.blockdevices.map((d) => ({ value: d.path, @@ -285,7 +314,7 @@ export const Flash = () => { label="SSID" value={field.value ?? ""} error={field.error} - class="col-span-3" + class="col-span-full " required /> )} @@ -295,40 +324,39 @@ export const Flash = () => { validate={[required("Password is required")]} > {(field, props) => ( -
- - // togglePasswordVisibility(index()) - // } - // startIcon={ - // passwordVisibility()[index()] ? ( - // - // ) : ( - // - // ) - // } - // > - // ), - // }} - required - /> -
+ + // togglePasswordVisibility(index()) + // } + // startIcon={ + // passwordVisibility()[index()] ? ( + // + // ) : ( + // + // ) + // } + // > + // ), + // }} + required + /> )}