UI/details: return early in error case
This commit is contained in:
committed by
Jörg Thalheim
parent
414c908717
commit
2bf0753722
@@ -1,10 +1,4 @@
|
|||||||
import {
|
import { callApi, ClanService, SuccessData, SuccessQuery } from "@/src/api";
|
||||||
callApi,
|
|
||||||
ClanService,
|
|
||||||
Services,
|
|
||||||
SuccessData,
|
|
||||||
SuccessQuery,
|
|
||||||
} from "@/src/api";
|
|
||||||
import { set_single_disk_id } from "@/src/api/disk";
|
import { set_single_disk_id } from "@/src/api/disk";
|
||||||
import { get_iwd_service } from "@/src/api/wifi";
|
import { get_iwd_service } from "@/src/api/wifi";
|
||||||
import { activeURI } from "@/src/App";
|
import { activeURI } from "@/src/App";
|
||||||
@@ -17,25 +11,11 @@ import {
|
|||||||
createForm,
|
createForm,
|
||||||
FieldValues,
|
FieldValues,
|
||||||
getValue,
|
getValue,
|
||||||
reset,
|
|
||||||
setValue,
|
setValue,
|
||||||
} from "@modular-forms/solid";
|
} from "@modular-forms/solid";
|
||||||
import { useParams } from "@solidjs/router";
|
import { useParams } from "@solidjs/router";
|
||||||
import {
|
import { createQuery, useQueryClient } from "@tanstack/solid-query";
|
||||||
createQuery,
|
import { createSignal, For, Show, Switch, Match, JSXElement } from "solid-js";
|
||||||
QueryObserver,
|
|
||||||
useQueryClient,
|
|
||||||
} from "@tanstack/solid-query";
|
|
||||||
import {
|
|
||||||
createSignal,
|
|
||||||
For,
|
|
||||||
Show,
|
|
||||||
Switch,
|
|
||||||
Match,
|
|
||||||
JSXElement,
|
|
||||||
createEffect,
|
|
||||||
createMemo,
|
|
||||||
} from "solid-js";
|
|
||||||
import toast from "solid-toast";
|
import toast from "solid-toast";
|
||||||
|
|
||||||
type MachineFormInterface = MachineData & {
|
type MachineFormInterface = MachineData & {
|
||||||
@@ -58,6 +38,12 @@ interface InstallMachineProps {
|
|||||||
disks: Disks;
|
disks: Disks;
|
||||||
}
|
}
|
||||||
const InstallMachine = (props: InstallMachineProps) => {
|
const InstallMachine = (props: InstallMachineProps) => {
|
||||||
|
const curr = activeURI();
|
||||||
|
const { name } = props;
|
||||||
|
if (!curr || !name) {
|
||||||
|
return <span>No Clan selected</span>;
|
||||||
|
}
|
||||||
|
|
||||||
const diskPlaceholder = "Select the boot disk of the remote machine";
|
const diskPlaceholder = "Select the boot disk of the remote machine";
|
||||||
|
|
||||||
const [formStore, { Form, Field }] = createForm<InstallForm>();
|
const [formStore, { Form, Field }] = createForm<InstallForm>();
|
||||||
@@ -67,23 +53,14 @@ const InstallMachine = (props: InstallMachineProps) => {
|
|||||||
const [confirmDisk, setConfirmDisk] = createSignal(!hasDisk());
|
const [confirmDisk, setConfirmDisk] = createSignal(!hasDisk());
|
||||||
|
|
||||||
const hwInfoQuery = createQuery(() => ({
|
const hwInfoQuery = createQuery(() => ({
|
||||||
queryKey: [
|
queryKey: [curr, "machine", name, "show_machine_hardware_config"],
|
||||||
activeURI(),
|
|
||||||
"machine",
|
|
||||||
props.name,
|
|
||||||
"show_machine_hardware_info",
|
|
||||||
],
|
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const curr = activeURI();
|
const result = await callApi("show_machine_hardware_config", {
|
||||||
if (curr && props.name) {
|
clan_dir: curr,
|
||||||
const result = await callApi("show_machine_hardware_config", {
|
machine_name: name,
|
||||||
clan_dir: curr,
|
});
|
||||||
machine_name: props.name,
|
if (result.status === "error") throw new Error("Failed to fetch data");
|
||||||
});
|
return result.data === "NIXOS_FACTER";
|
||||||
if (result.status === "error") throw new Error("Failed to fetch data");
|
|
||||||
return result.data === "NIXOS_FACTER" || null;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user