mirror of https://github.com/jetkvm/kvm.git
feat(ui): Add dev channel toggle to advanced settings
Move dev channel update option from general settings to advanced settings - Introduced new state and handler for dev channel toggle - Removed dev channel option from general settings route - Added dev channel toggle in advanced settings with error handling
This commit is contained in:
parent
7d0919ff32
commit
cb8f373044
|
@ -17,10 +17,12 @@ export default function SettingsAdvancedRoute() {
|
||||||
|
|
||||||
const [sshKey, setSSHKey] = useState<string>("");
|
const [sshKey, setSSHKey] = useState<string>("");
|
||||||
const setDeveloperMode = useSettingsStore(state => state.setDeveloperMode);
|
const setDeveloperMode = useSettingsStore(state => state.setDeveloperMode);
|
||||||
|
const [devChannel, setDevChannel] = useState(false);
|
||||||
|
const [usbEmulationEnabled, setUsbEmulationEnabled] = useState(false);
|
||||||
|
|
||||||
const settings = useSettingsStore();
|
const settings = useSettingsStore();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
send("getDevModeState", {}, resp => {
|
send("getDevModeState", {}, resp => {
|
||||||
if ("error" in resp) return;
|
if ("error" in resp) return;
|
||||||
const result = resp.result as { enabled: boolean };
|
const result = resp.result as { enabled: boolean };
|
||||||
|
@ -36,6 +38,11 @@ export default function SettingsAdvancedRoute() {
|
||||||
if ("error" in resp) return;
|
if ("error" in resp) return;
|
||||||
setUsbEmulationEnabled(resp.result as boolean);
|
setUsbEmulationEnabled(resp.result as boolean);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
send("getDevChannelState", {}, resp => {
|
||||||
|
if ("error" in resp) return;
|
||||||
|
setDevChannel(resp.result as boolean);
|
||||||
|
});
|
||||||
}, [send, setDeveloperMode]);
|
}, [send, setDeveloperMode]);
|
||||||
|
|
||||||
const getUsbEmulationState = useCallback(() => {
|
const getUsbEmulationState = useCallback(() => {
|
||||||
|
@ -45,7 +52,6 @@ export default function SettingsAdvancedRoute() {
|
||||||
});
|
});
|
||||||
}, [send]);
|
}, [send]);
|
||||||
|
|
||||||
|
|
||||||
const handleUsbEmulationToggle = useCallback(
|
const handleUsbEmulationToggle = useCallback(
|
||||||
(enabled: boolean) => {
|
(enabled: boolean) => {
|
||||||
send("setUsbEmulationState", { enabled: enabled }, resp => {
|
send("setUsbEmulationState", { enabled: enabled }, resp => {
|
||||||
|
@ -101,7 +107,17 @@ export default function SettingsAdvancedRoute() {
|
||||||
[send, setDeveloperMode],
|
[send, setDeveloperMode],
|
||||||
);
|
);
|
||||||
|
|
||||||
const [usbEmulationEnabled, setUsbEmulationEnabled] = useState(false);
|
const handleDevChannelChange = (enabled: boolean) => {
|
||||||
|
send("setDevChannelState", { enabled }, resp => {
|
||||||
|
if ("error" in resp) {
|
||||||
|
notifications.error(
|
||||||
|
`Failed to set dev channel state: ${resp.error.data || "Unknown error"}`,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setDevChannel(enabled);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
|
@ -112,51 +128,16 @@ export default function SettingsAdvancedRoute() {
|
||||||
|
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<SettingsItem
|
<SettingsItem
|
||||||
title="Troubleshooting Mode"
|
title="Dev Channel Updates"
|
||||||
description="Diagnostic tools and additional controls for troubleshooting and development purposes"
|
description="Receive early updates from the development channel"
|
||||||
>
|
>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
defaultChecked={settings.debugMode}
|
checked={devChannel}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
settings.setDebugMode(e.target.checked);
|
handleDevChannelChange(e.target.checked);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</SettingsItem>
|
</SettingsItem>
|
||||||
|
|
||||||
{settings.debugMode && (
|
|
||||||
<>
|
|
||||||
<SettingsItem
|
|
||||||
title="USB Emulation"
|
|
||||||
description="Control the USB emulation state"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
size="SM"
|
|
||||||
theme="light"
|
|
||||||
text={
|
|
||||||
usbEmulationEnabled ? "Disable USB Emulation" : "Enable USB Emulation"
|
|
||||||
}
|
|
||||||
onClick={() => handleUsbEmulationToggle(!usbEmulationEnabled)}
|
|
||||||
/>
|
|
||||||
</SettingsItem>
|
|
||||||
|
|
||||||
<SettingsItem
|
|
||||||
title="Reset Configuration"
|
|
||||||
description="Reset configuration to default. This will log you out."
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
size="SM"
|
|
||||||
theme="light"
|
|
||||||
text="Reset Config"
|
|
||||||
onClick={() => {
|
|
||||||
handleResetConfig();
|
|
||||||
window.location.reload();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</SettingsItem>
|
|
||||||
<div className="h-[1px] w-full bg-slate-800/10 dark:bg-slate-300/20" />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<SettingsItem
|
<SettingsItem
|
||||||
title="Developer Mode"
|
title="Developer Mode"
|
||||||
description="Enable advanced features for developers"
|
description="Enable advanced features for developers"
|
||||||
|
@ -231,6 +212,51 @@ export default function SettingsAdvancedRoute() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<SettingsItem
|
||||||
|
title="Troubleshooting Mode"
|
||||||
|
description="Diagnostic tools and additional controls for troubleshooting and development purposes"
|
||||||
|
>
|
||||||
|
<Checkbox
|
||||||
|
defaultChecked={settings.debugMode}
|
||||||
|
onChange={e => {
|
||||||
|
settings.setDebugMode(e.target.checked);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</SettingsItem>
|
||||||
|
|
||||||
|
{settings.debugMode && (
|
||||||
|
<>
|
||||||
|
<SettingsItem
|
||||||
|
title="USB Emulation"
|
||||||
|
description="Control the USB emulation state"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
size="SM"
|
||||||
|
theme="light"
|
||||||
|
text={
|
||||||
|
usbEmulationEnabled ? "Disable USB Emulation" : "Enable USB Emulation"
|
||||||
|
}
|
||||||
|
onClick={() => handleUsbEmulationToggle(!usbEmulationEnabled)}
|
||||||
|
/>
|
||||||
|
</SettingsItem>
|
||||||
|
|
||||||
|
<SettingsItem
|
||||||
|
title="Reset Configuration"
|
||||||
|
description="Reset configuration to default. This will log you out."
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
size="SM"
|
||||||
|
theme="light"
|
||||||
|
text="Reset Config"
|
||||||
|
onClick={() => {
|
||||||
|
handleResetConfig();
|
||||||
|
window.location.reload();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</SettingsItem>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,7 +14,6 @@ export default function SettingsGeneralRoute() {
|
||||||
const [send] = useJsonRpc();
|
const [send] = useJsonRpc();
|
||||||
const { navigateTo } = useDeviceUiNavigation();
|
const { navigateTo } = useDeviceUiNavigation();
|
||||||
|
|
||||||
const [devChannel, setDevChannel] = useState(false);
|
|
||||||
const [autoUpdate, setAutoUpdate] = useState(true);
|
const [autoUpdate, setAutoUpdate] = useState(true);
|
||||||
const [currentVersions, setCurrentVersions] = useState<{
|
const [currentVersions, setCurrentVersions] = useState<{
|
||||||
appVersion: string;
|
appVersion: string;
|
||||||
|
@ -38,11 +37,6 @@ export default function SettingsGeneralRoute() {
|
||||||
if ("error" in resp) return;
|
if ("error" in resp) return;
|
||||||
setAutoUpdate(resp.result as boolean);
|
setAutoUpdate(resp.result as boolean);
|
||||||
});
|
});
|
||||||
|
|
||||||
send("getDevChannelState", {}, resp => {
|
|
||||||
if ("error" in resp) return;
|
|
||||||
setDevChannel(resp.result as boolean);
|
|
||||||
});
|
|
||||||
}, [getCurrentVersions, send]);
|
}, [getCurrentVersions, send]);
|
||||||
|
|
||||||
const handleAutoUpdateChange = (enabled: boolean) => {
|
const handleAutoUpdateChange = (enabled: boolean) => {
|
||||||
|
@ -57,18 +51,6 @@ export default function SettingsGeneralRoute() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDevChannelChange = (enabled: boolean) => {
|
|
||||||
send("setDevChannelState", { enabled }, resp => {
|
|
||||||
if ("error" in resp) {
|
|
||||||
notifications.error(
|
|
||||||
`Failed to set dev channel state: ${resp.error.data || "Unknown error"}`,
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setDevChannel(enabled);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<SettingsPageHeader
|
<SettingsPageHeader
|
||||||
|
@ -118,17 +100,6 @@ export default function SettingsGeneralRoute() {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</SettingsItem>
|
</SettingsItem>
|
||||||
<SettingsItem
|
|
||||||
title="Dev Channel Updates"
|
|
||||||
description="Receive early updates from the development channel"
|
|
||||||
>
|
|
||||||
<Checkbox
|
|
||||||
checked={devChannel}
|
|
||||||
onChange={e => {
|
|
||||||
handleDevChannelChange(e.target.checked);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</SettingsItem>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue