mirror of https://github.com/jetkvm/kvm.git
fix(cloud): Improve cloud URL configuration and adoption flow
- Update error handling in cloud URL configuration RPC method - Modify cloud adoption route to support dynamic cloud URLs - Remove hardcoded default cloud URLs in device access settings - Refactor cloud adoption click handler to be more flexible
This commit is contained in:
parent
69a25ce1e9
commit
ba3834b95f
|
@ -758,7 +758,7 @@ func rpcSetCloudUrl(apiUrl string, appUrl string) (bool, error) {
|
||||||
config.CloudAppURL = appUrl
|
config.CloudAppURL = appUrl
|
||||||
|
|
||||||
if err := SaveConfig(); err != nil {
|
if err := SaveConfig(); err != nil {
|
||||||
return false, err
|
return false, fmt.Errorf("failed to save config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
|
|
|
@ -180,8 +180,8 @@ if (isOnDevice) {
|
||||||
{
|
{
|
||||||
path: "/adopt",
|
path: "/adopt",
|
||||||
element: <AdoptRoute />,
|
element: <AdoptRoute />,
|
||||||
errorElement: <ErrorBoundary />,
|
|
||||||
loader: AdoptRoute.loader,
|
loader: AdoptRoute.loader,
|
||||||
|
errorElement: <ErrorBoundary />,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -53,8 +53,8 @@ export default function SettingsAccessIndexRoute() {
|
||||||
|
|
||||||
const [isAdopted, setAdopted] = useState(false);
|
const [isAdopted, setAdopted] = useState(false);
|
||||||
const [deviceId, setDeviceId] = useState<string | null>(null);
|
const [deviceId, setDeviceId] = useState<string | null>(null);
|
||||||
const [cloudApiUrl, setCloudApiUrl] = useState("https://api.jetkvm.com");
|
const [cloudApiUrl, setCloudApiUrl] = useState("");
|
||||||
const [cloudAppUrl, setCloudAppUrl] = useState("https://app.jetkvm.com");
|
const [cloudAppUrl, setCloudAppUrl] = useState("");
|
||||||
|
|
||||||
// Use a simple string identifier for the selected provider
|
// Use a simple string identifier for the selected provider
|
||||||
const [selectedProvider, setSelectedProvider] = useState<string>("jetkvm");
|
const [selectedProvider, setSelectedProvider] = useState<string>("jetkvm");
|
||||||
|
@ -95,7 +95,8 @@ export default function SettingsAccessIndexRoute() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onCloudAdoptClick = useCallback(() => {
|
const onCloudAdoptClick = useCallback(
|
||||||
|
(cloudApiUrl: string, cloudAppUrl: string) => {
|
||||||
if (!deviceId) {
|
if (!deviceId) {
|
||||||
notifications.error("No device ID available");
|
notifications.error("No device ID available");
|
||||||
return;
|
return;
|
||||||
|
@ -109,16 +110,19 @@ export default function SettingsAccessIndexRoute() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
getCloudState();
|
|
||||||
|
|
||||||
const returnTo = new URL(window.location.href);
|
const returnTo = new URL(window.location.href);
|
||||||
returnTo.pathname = "/adopt";
|
returnTo.pathname = "/adopt";
|
||||||
returnTo.search = "";
|
returnTo.search = "";
|
||||||
returnTo.hash = "";
|
returnTo.hash = "";
|
||||||
window.location.href =
|
window.location.href =
|
||||||
cloudAppUrl + "/signup?deviceId=" + deviceId + `&returnTo=${returnTo.toString()}`;
|
cloudAppUrl +
|
||||||
|
"/signup?deviceId=" +
|
||||||
|
deviceId +
|
||||||
|
`&returnTo=${returnTo.toString()}`;
|
||||||
});
|
});
|
||||||
}, [deviceId, getCloudState, send, cloudApiUrl, cloudAppUrl]);
|
},
|
||||||
|
[deviceId, send],
|
||||||
|
);
|
||||||
|
|
||||||
// Handle provider selection change
|
// Handle provider selection change
|
||||||
const handleProviderChange = (value: string) => {
|
const handleProviderChange = (value: string) => {
|
||||||
|
@ -297,7 +301,7 @@ export default function SettingsAccessIndexRoute() {
|
||||||
{!isAdopted ? (
|
{!isAdopted ? (
|
||||||
<div className="flex items-end gap-x-2">
|
<div className="flex items-end gap-x-2">
|
||||||
<Button
|
<Button
|
||||||
onClick={onCloudAdoptClick}
|
onClick={() => onCloudAdoptClick(cloudApiUrl, cloudAppUrl)}
|
||||||
size="SM"
|
size="SM"
|
||||||
theme="primary"
|
theme="primary"
|
||||||
text="Adopt KVM to Cloud"
|
text="Adopt KVM to Cloud"
|
||||||
|
|
Loading…
Reference in New Issue