mirror of https://github.com/jetkvm/kvm.git
fix: add ConfirmDialog for renewing DHCP lease and improve network settings layout
- Integrated ConfirmDialog component to confirm DHCP lease renewal. - Enhanced the layout of network settings, including better organization of IPv4 and IPv6 information. - Updated state management for displaying network settings and lease information. - Improved user experience with clearer descriptions and structured UI elements.
This commit is contained in:
parent
fcf2dbab60
commit
df74cb111d
|
@ -1,6 +1,7 @@
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import relativeTime from "dayjs/plugin/relativeTime";
|
import relativeTime from "dayjs/plugin/relativeTime";
|
||||||
|
import { ArrowPathIcon } from "@heroicons/react/24/outline";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IPv4Mode,
|
IPv4Mode,
|
||||||
|
@ -23,6 +24,7 @@ import { SelectMenuBasic } from "../components/SelectMenuBasic";
|
||||||
|
|
||||||
import { SettingsItem } from "./devices.$id.settings";
|
import { SettingsItem } from "./devices.$id.settings";
|
||||||
import Fieldset from "../components/Fieldset";
|
import Fieldset from "../components/Fieldset";
|
||||||
|
import { ConfirmDialog } from "../components/ConfirmDialog";
|
||||||
|
|
||||||
dayjs.extend(relativeTime);
|
dayjs.extend(relativeTime);
|
||||||
|
|
||||||
|
@ -206,12 +208,15 @@ export default function SettingsNetworkRoute() {
|
||||||
[networkSettingsLoaded],
|
[networkSettingsLoaded],
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("firstNetworkSettings", firstNetworkSettings.current);
|
const [showRenewLeaseConfirm, setShowRenewLeaseConfirm] = useState(false);
|
||||||
console.log("networkSettings", networkSettings);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<Fieldset disabled={!networkSettingsLoaded} className="space-y-4">
|
<Fieldset disabled={!networkSettingsLoaded} className="space-y-4">
|
||||||
<SettingsPageHeader title="Network" description="Configure your network settings" />
|
<SettingsPageHeader
|
||||||
|
title="Network"
|
||||||
|
description="Configure your network settings"
|
||||||
|
/>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<SettingsItem
|
<SettingsItem
|
||||||
title="MAC Address"
|
title="MAC Address"
|
||||||
|
@ -251,7 +256,10 @@ export default function SettingsNetworkRoute() {
|
||||||
|
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<SettingsItem title="Domain" description="Network domain suffix for the device">
|
<SettingsItem
|
||||||
|
title="Domain"
|
||||||
|
description="Network domain suffix for the device"
|
||||||
|
>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<SelectMenuBasic
|
<SelectMenuBasic
|
||||||
size="SM"
|
size="SM"
|
||||||
|
@ -353,7 +361,7 @@ export default function SettingsNetworkRoute() {
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<h3 className="text-base font-bold text-slate-900 dark:text-white">
|
<h3 className="text-base font-bold text-slate-900 dark:text-white">
|
||||||
Current DHCP Lease
|
DHCP Lease
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div className="flex gap-x-6 gap-y-2">
|
<div className="flex gap-x-6 gap-y-2">
|
||||||
|
@ -540,9 +548,11 @@ export default function SettingsNetworkRoute() {
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
size="SM"
|
size="SM"
|
||||||
theme="primary"
|
theme="light"
|
||||||
text="Renew lease"
|
className="text-red-500"
|
||||||
onClick={handleRenewLease}
|
text="Renew DHCP Lease"
|
||||||
|
LeadingIcon={ArrowPathIcon}
|
||||||
|
onClick={() => setShowRenewLeaseConfirm(true)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -672,5 +682,18 @@ export default function SettingsNetworkRoute() {
|
||||||
</SettingsItem>
|
</SettingsItem>
|
||||||
</div>
|
</div>
|
||||||
</Fieldset>
|
</Fieldset>
|
||||||
|
<ConfirmDialog
|
||||||
|
open={showRenewLeaseConfirm}
|
||||||
|
onClose={() => setShowRenewLeaseConfirm(false)}
|
||||||
|
title="Renew DHCP Lease"
|
||||||
|
description="This will request a new IP address from your DHCP server. Your device may temporarily lose network connectivity during this process."
|
||||||
|
variant="danger"
|
||||||
|
confirmText="Renew Lease"
|
||||||
|
onConfirm={() => {
|
||||||
|
handleRenewLease();
|
||||||
|
setShowRenewLeaseConfirm(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue