style: only show the select menu if both stable and nightly releases are available

This commit is contained in:
zhom
2025-06-17 02:42:03 +04:00
parent 575d7f80b1
commit cb6f744d6b
+36 -26
View File
@@ -14,6 +14,7 @@ import {
} from "@/components/ui/dialog"; } from "@/components/ui/dialog";
import { Label } from "@/components/ui/label"; import { Label } from "@/components/ui/label";
import { useBrowserDownload } from "@/hooks/use-browser-download"; import { useBrowserDownload } from "@/hooks/use-browser-download";
import { getBrowserDisplayName } from "@/lib/browser-utils";
import type { BrowserProfile, BrowserReleaseTypes } from "@/types"; import type { BrowserProfile, BrowserReleaseTypes } from "@/types";
import { invoke } from "@tauri-apps/api/core"; import { invoke } from "@tauri-apps/api/core";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
@@ -153,43 +154,52 @@ export function ChangeVersionDialog({
<div className="grid gap-4 py-4"> <div className="grid gap-4 py-4">
<div className="space-y-2"> <div className="space-y-2">
<Label className="text-sm font-medium">Profile:</Label> <Label className="text-sm font-medium">Profile:</Label>
<div className="p-2 bg-muted rounded text-sm">{profile.name}</div> <div className="p-2 text-sm rounded bg-muted">{profile.name}</div>
</div> </div>
<div className="space-y-2"> <div className="space-y-2">
<Label className="text-sm font-medium">Current Release:</Label> <Label className="text-sm font-medium">Current Release:</Label>
<div className="p-2 bg-muted rounded text-sm capitalize"> <div className="p-2 text-sm capitalize rounded bg-muted">
{profile.release_type} ({profile.version}) {profile.release_type} ({profile.version})
</div> </div>
</div> </div>
{/* Release Type Selection */} {/* Release Type Selection - only show if multiple release types are available */}
<div className="grid gap-2"> {!releaseTypes.stable || !releaseTypes.nightly ? (
<Label>New Release Type</Label> <Alert>
{isLoadingReleaseTypes ? ( <AlertDescription>
<div className="text-sm text-muted-foreground"> Only {profile.release_type} releases are available for{" "}
Loading release types... {getBrowserDisplayName(profile.browser)}.
</div> </AlertDescription>
) : ( </Alert>
<ReleaseTypeSelector ) : (
selectedReleaseType={selectedReleaseType} <div className="grid gap-2">
onReleaseTypeSelect={setSelectedReleaseType} <Label>New Release Type</Label>
availableReleaseTypes={releaseTypes} {isLoadingReleaseTypes ? (
browser={profile.browser} <div className="text-sm text-muted-foreground">
isDownloading={isDownloading} Loading release types...
onDownload={() => { </div>
void handleDownload(); ) : (
}} <ReleaseTypeSelector
placeholder="Select release type..." selectedReleaseType={selectedReleaseType}
downloadedVersions={downloadedVersions} onReleaseTypeSelect={setSelectedReleaseType}
/> availableReleaseTypes={releaseTypes}
)} browser={profile.browser}
</div> isDownloading={isDownloading}
onDownload={() => {
void handleDownload();
}}
placeholder="Select release type..."
downloadedVersions={downloadedVersions}
/>
)}
</div>
)}
{/* Downgrade Warning */} {/* Downgrade Warning */}
{showDowngradeWarning && ( {showDowngradeWarning && (
<Alert className="border-orange-700"> <Alert className="border-orange-700">
<LuTriangleAlert className="h-4 w-4 text-orange-700" /> <LuTriangleAlert className="w-4 h-4 text-orange-700" />
<AlertTitle className="text-orange-700"> <AlertTitle className="text-orange-700">
Stability Warning Stability Warning
</AlertTitle> </AlertTitle>
@@ -197,7 +207,7 @@ export function ChangeVersionDialog({
You are about to switch from stable to nightly releases. Nightly You are about to switch from stable to nightly releases. Nightly
versions may be less stable and could contain bugs or incomplete versions may be less stable and could contain bugs or incomplete
features. features.
<div className="flex items-center space-x-2 mt-3"> <div className="flex items-center mt-3 space-x-2">
<Checkbox <Checkbox
id="acknowledge-downgrade" id="acknowledge-downgrade"
checked={acknowledgeDowngrade} checked={acknowledgeDowngrade}