mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-09-26 19:22:09 +02:00
fix: don't let the user create profile or change version if latest version not downloaded
This commit is contained in:
@@ -164,13 +164,60 @@ export function ChangeVersionDialog({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!releaseTypes.stable || !releaseTypes.nightly ? (
|
{!releaseTypes.stable && !releaseTypes.nightly ? (
|
||||||
<Alert>
|
<Alert>
|
||||||
<AlertDescription>
|
<AlertDescription>
|
||||||
Only {profile.release_type} releases are available for{" "}
|
No releases are available for{" "}
|
||||||
{getBrowserDisplayName(profile.browser)}.
|
{getBrowserDisplayName(profile.browser)}.
|
||||||
</AlertDescription>
|
</AlertDescription>
|
||||||
</Alert>
|
</Alert>
|
||||||
|
) : !releaseTypes.stable || !releaseTypes.nightly ? (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<Alert>
|
||||||
|
<AlertDescription>
|
||||||
|
Only {profile.release_type} releases are available for{" "}
|
||||||
|
{getBrowserDisplayName(profile.browser)}.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
<div className="grid gap-2">
|
||||||
|
<Label>New Release Type</Label>
|
||||||
|
{isLoadingReleaseTypes ? (
|
||||||
|
<div className="text-sm text-muted-foreground">
|
||||||
|
Loading release types...
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="space-y-4">
|
||||||
|
{selectedReleaseType &&
|
||||||
|
selectedReleaseType !== profile.release_type &&
|
||||||
|
selectedVersion &&
|
||||||
|
!isVersionDownloaded(selectedVersion) && (
|
||||||
|
<Alert>
|
||||||
|
<AlertDescription>
|
||||||
|
You must download{" "}
|
||||||
|
{getBrowserDisplayName(profile.browser)}{" "}
|
||||||
|
{selectedVersion} before switching to this release
|
||||||
|
type. Use the download button above to get the
|
||||||
|
latest version.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<ReleaseTypeSelector
|
||||||
|
selectedReleaseType={selectedReleaseType}
|
||||||
|
onReleaseTypeSelect={setSelectedReleaseType}
|
||||||
|
availableReleaseTypes={releaseTypes}
|
||||||
|
browser={profile.browser}
|
||||||
|
isDownloading={isDownloading}
|
||||||
|
onDownload={() => {
|
||||||
|
void handleDownload();
|
||||||
|
}}
|
||||||
|
placeholder="Select release type..."
|
||||||
|
downloadedVersions={downloadedVersions}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="grid gap-2">
|
<div className="grid gap-2">
|
||||||
<Label>New Release Type</Label>
|
<Label>New Release Type</Label>
|
||||||
@@ -179,18 +226,35 @@ export function ChangeVersionDialog({
|
|||||||
Loading release types...
|
Loading release types...
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<ReleaseTypeSelector
|
<div className="space-y-4">
|
||||||
selectedReleaseType={selectedReleaseType}
|
{selectedReleaseType &&
|
||||||
onReleaseTypeSelect={setSelectedReleaseType}
|
selectedReleaseType !== profile.release_type &&
|
||||||
availableReleaseTypes={releaseTypes}
|
selectedVersion &&
|
||||||
browser={profile.browser}
|
!isVersionDownloaded(selectedVersion) && (
|
||||||
isDownloading={isDownloading}
|
<Alert>
|
||||||
onDownload={() => {
|
<AlertDescription>
|
||||||
void handleDownload();
|
You must download{" "}
|
||||||
}}
|
{getBrowserDisplayName(profile.browser)}{" "}
|
||||||
placeholder="Select release type..."
|
{selectedVersion} before switching to this release
|
||||||
downloadedVersions={downloadedVersions}
|
type. Use the download button above to get the latest
|
||||||
/>
|
version.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<ReleaseTypeSelector
|
||||||
|
selectedReleaseType={selectedReleaseType}
|
||||||
|
onReleaseTypeSelect={setSelectedReleaseType}
|
||||||
|
availableReleaseTypes={releaseTypes}
|
||||||
|
browser={profile.browser}
|
||||||
|
isDownloading={isDownloading}
|
||||||
|
onDownload={() => {
|
||||||
|
void handleDownload();
|
||||||
|
}}
|
||||||
|
placeholder="Select release type..."
|
||||||
|
downloadedVersions={downloadedVersions}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ export function CreateProfileDialog({
|
|||||||
isDownloading,
|
isDownloading,
|
||||||
downloadedVersions,
|
downloadedVersions,
|
||||||
loadDownloadedVersions,
|
loadDownloadedVersions,
|
||||||
|
isVersionDownloaded,
|
||||||
} = useBrowserDownload();
|
} = useBrowserDownload();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -280,6 +281,7 @@ export function CreateProfileDialog({
|
|||||||
selectedBrowser &&
|
selectedBrowser &&
|
||||||
selectedReleaseType &&
|
selectedReleaseType &&
|
||||||
selectedVersion &&
|
selectedVersion &&
|
||||||
|
isVersionDownloaded(selectedVersion) &&
|
||||||
(!proxyEnabled || isProxyDisabled || (proxyHost && proxyPort)) &&
|
(!proxyEnabled || isProxyDisabled || (proxyHost && proxyPort)) &&
|
||||||
!nameError;
|
!nameError;
|
||||||
|
|
||||||
@@ -370,37 +372,48 @@ export function CreateProfileDialog({
|
|||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{selectedBrowser &&
|
{selectedBrowser ? (
|
||||||
(!releaseTypes.stable || !releaseTypes.nightly) ? (
|
|
||||||
<Alert>
|
|
||||||
<AlertDescription>
|
|
||||||
Only {(releaseTypes.stable && "Stable") ?? "Nightly"} releases
|
|
||||||
are available for {getBrowserDisplayName(selectedBrowser)}.
|
|
||||||
</AlertDescription>
|
|
||||||
</Alert>
|
|
||||||
) : (
|
|
||||||
<div className="grid gap-2">
|
<div className="grid gap-2">
|
||||||
<Label>Release Type</Label>
|
<Label>Release Type</Label>
|
||||||
{isLoadingReleaseTypes ? (
|
{isLoadingReleaseTypes ? (
|
||||||
<div className="text-sm text-muted-foreground">
|
<div className="text-sm text-muted-foreground">
|
||||||
Loading release types...
|
Loading release types...
|
||||||
</div>
|
</div>
|
||||||
|
) : Object.keys(releaseTypes).length === 0 ? (
|
||||||
|
<Alert>
|
||||||
|
<AlertDescription>
|
||||||
|
No releases are available for{" "}
|
||||||
|
{getBrowserDisplayName(selectedBrowser)}.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
) : (
|
) : (
|
||||||
<ReleaseTypeSelector
|
<div className="space-y-4">
|
||||||
selectedReleaseType={selectedReleaseType}
|
{(!releaseTypes.stable || !releaseTypes.nightly) && (
|
||||||
onReleaseTypeSelect={setSelectedReleaseType}
|
<Alert>
|
||||||
availableReleaseTypes={releaseTypes}
|
<AlertDescription>
|
||||||
browser={selectedBrowser ?? ""}
|
Only {(releaseTypes.stable && "Stable") ?? "Nightly"}{" "}
|
||||||
isDownloading={isDownloading}
|
releases are available for{" "}
|
||||||
onDownload={() => {
|
{getBrowserDisplayName(selectedBrowser)}.
|
||||||
void handleDownload();
|
</AlertDescription>
|
||||||
}}
|
</Alert>
|
||||||
placeholder="Select release type..."
|
)}
|
||||||
downloadedVersions={downloadedVersions}
|
|
||||||
/>
|
<ReleaseTypeSelector
|
||||||
|
selectedReleaseType={selectedReleaseType}
|
||||||
|
onReleaseTypeSelect={setSelectedReleaseType}
|
||||||
|
availableReleaseTypes={releaseTypes}
|
||||||
|
browser={selectedBrowser}
|
||||||
|
isDownloading={isDownloading}
|
||||||
|
onDownload={() => {
|
||||||
|
void handleDownload();
|
||||||
|
}}
|
||||||
|
placeholder="Select release type..."
|
||||||
|
downloadedVersions={downloadedVersions}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
) : null}
|
||||||
|
|
||||||
{/* Proxy Settings */}
|
{/* Proxy Settings */}
|
||||||
<div className="grid gap-4 pt-4 border-t">
|
<div className="grid gap-4 pt-4 border-t">
|
||||||
|
|||||||
Reference in New Issue
Block a user