fix #5894 - allow user to select upgrade version

This commit is contained in:
sbwalker
2026-01-19 08:24:56 -05:00
parent 780e2a8484
commit 7d7ecf4757
2 changed files with 31 additions and 13 deletions

View File

@@ -11,11 +11,22 @@
{
<TabStrip>
<TabPanel Name="Download" ResourceKey="Download">
@if (_package != null && _upgradeavailable)
@if (_versions.Count > 0 && _upgradeable)
{
<div class="container">
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" HelpText="Specify if you want to backup files during the upgrade process. Disabling this option will reduce the time required for the upgrade." ResourceKey="Backup">Backup Files? </Label>
<Label Class="col-sm-3" For="version" HelpText="Select the framework upgrade version" ResourceKey="Version">Version: </Label>
<div class="col-sm-9">
<select id="backup" class="form-select" @bind="@_version">
@foreach (var version in _versions)
{
<option value="@version">@version</option>
}
</select>
</div>
</div>
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" For="backup" HelpText="Specify if you want to backup files during the upgrade process. Disabling this option will reduce the time required for the upgrade." ResourceKey="Backup">Backup Files? </Label>
<div class="col-sm-9">
<select id="backup" class="form-select" @bind="@_backup">
<option value="True">@SharedLocalizer["Yes"]</option>
@@ -27,7 +38,7 @@
<br />
@if (!_downloaded)
{
<button type="button" class="btn btn-primary" @onclick=@(async () => await Download(Constants.PackageId, @_package.Version))>@SharedLocalizer["Download"] @_package.Version</button>
<button type="button" class="btn btn-primary" @onclick=@(async () => await Download(Constants.PackageId, _version))>@SharedLocalizer["Download"] @_version</button>
}
else
{
@@ -66,8 +77,9 @@
@code {
private bool _initialized = false;
private bool _downloaded = false;
private Package _package;
private bool _upgradeavailable = false;
private List<string> _versions = new List<string>();
private string _version;
private bool _upgradeable = false;
private string _backup = "True";
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host;
@@ -84,18 +96,18 @@
{
AddModuleMessage(Localizer["Disclaimer.Text"], MessageType.Warning);
List<Package> packages = await PackageService.GetPackagesAsync("framework", "", "", "");
var packages = await PackageService.GetPackagesAsync("framework", "", "", "");
if (packages != null)
{
_package = packages.Where(item => item.PackageId.StartsWith(Constants.PackageId)).FirstOrDefault();
if (_package != null)
_version = packages.First(item => item.PackageId.StartsWith(Constants.PackageId)).Version;
foreach (var version in Constants.ReleaseVersions.Split(','))
{
_upgradeavailable = (Version.Parse(_package.Version).CompareTo(Version.Parse(Constants.Version)) > 0);
}
else
{
_package = new Package { Name = Constants.PackageId, Version = Constants.Version };
if (Version.Parse(version).CompareTo(Version.Parse(Constants.Version)) > 0)
{
_versions.Add(version);
}
}
_upgradeable = (Version.Parse(_version).CompareTo(Version.Parse(Constants.Version)) > 0);
}
_initialized = true;
}

View File

@@ -156,4 +156,10 @@
<data name="Backup.HelpText" xml:space="preserve">
<value>Specify if you want to backup files during the upgrade process. Disabling this option will reduce the time required for the upgrade.</value>
</data>
<data name="Version.Text" xml:space="preserve">
<value>Version:</value>
</data>
<data name="Version.HelpText" xml:space="preserve">
<value>Select the framework upgrade version</value>
</data>
</root>