Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Languages/lang_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"Do you really want to uninstall the following {0} packages?": "Do you really want to uninstall the following {0} packages?",
"No": "No",
"Yes": "Yes",
"Partial": "Partial",
"View on UniGetUI": "View on UniGetUI",
"Update": "Update",
Comment thread
GabrielDuf marked this conversation as resolved.
"Open UniGetUI": "Open UniGetUI",
Expand Down Expand Up @@ -524,6 +525,7 @@
"e.g. 10": "e.g. 10",
"Custom minimum age (days)": "Custom minimum age (days)",
"{pm} does not provide release dates for its packages, so this setting will have no effect": "{pm} does not provide release dates for its packages, so this setting will have no effect",
"{pm} only provides release dates for some of its packages, so this setting will only apply to those packages": "{pm} only provides release dates for some of its packages, so this setting will only apply to those packages",
"Override the global minimum update age for this package manager": "Override the global minimum update age for this package manager",
Comment thread
GabrielDuf marked this conversation as resolved.
"View {0} logs": "View {0} logs",
"If Python cannot be found or is not listing packages but is installed on the system, ": "If Python cannot be found or is not listing packages but is installed on the system, ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using UniGetUI.Avalonia.Views.Pages.SettingsPages;
using UniGetUI.Core.Tools;
using UniGetUI.PackageEngine;
using UniGetUI.PackageEngine.ManagerClasses.Manager;
using CoreSettings = UniGetUI.Core.SettingsEngine.Settings;
using CornerRadius = Avalonia.CornerRadius;
using Thickness = Avalonia.Thickness;
Expand All @@ -20,10 +21,6 @@ public partial class UpdatesViewModel : ViewModelBase
[ObservableProperty] private bool _isAutoCheckEnabled;
[ObservableProperty] private bool _isCustomAgeSelected;

private static readonly HashSet<string> _managersWithoutUpdateDate =
new(StringComparer.OrdinalIgnoreCase)
{ "Homebrew", "Scoop", "vcpkg" };

/// <summary>Items for the minimum update age ComboboxCard, in display/value pairs.</summary>
public IReadOnlyList<(string Name, string Value)> MinimumAgeItems { get; } =
[
Expand Down Expand Up @@ -60,9 +57,6 @@ public UpdatesViewModel()

public Control BuildReleaseDateCompatTable()
{
string yesStr = CoreTools.Translate("Yes");
string noStr = CoreTools.Translate("No");

var managers = PEInterface.Managers.ToList();

var table = new Grid
Expand All @@ -89,8 +83,13 @@ public Control BuildReleaseDateCompatTable()
var name = new TextBlock { Text = manager.DisplayName, VerticalAlignment = VerticalAlignment.Center };
Grid.SetRow(name, row); Grid.SetColumn(name, 0);

bool supported = !_managersWithoutUpdateDate.Contains(manager.Name);
var badge = _statusBadge(supported ? yesStr : noStr, supported ? Colors.Green : Colors.Red);
(string label, Color color) = manager.Capabilities.KnowsPackageReleaseDate switch
{
PackageReleaseDateSupport.Yes => (CoreTools.Translate("Yes"), Colors.Green),
PackageReleaseDateSupport.Partial => (CoreTools.Translate("Partial"), Color.FromRgb(224, 168, 0)),
_ => (CoreTools.Translate("No"), Colors.Red),
};
var badge = _statusBadge(label, color);
Grid.SetRow(badge, row); Grid.SetColumn(badge, 1);

table.Children.Add(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using UniGetUI.Core.Tools;
using UniGetUI.Interface.Enums;
using UniGetUI.PackageEngine.Interfaces;
using UniGetUI.PackageEngine.ManagerClasses.Manager;
using UniGetUI.PackageEngine.Managers.VcpkgManager;
using CoreSettings = UniGetUI.Core.SettingsEngine.Settings;
using CornerRadius = global::Avalonia.CornerRadius;
Expand All @@ -21,9 +22,6 @@ namespace UniGetUI.Avalonia.Views.Pages.SettingsPages;

public sealed partial class PackageManagerPage : UserControl, ISettingsPage
{
private static readonly HashSet<string> _managersWithoutUpdateDate =
new(StringComparer.OrdinalIgnoreCase)
{ "Homebrew", "Scoop", "vcpkg" };
private PackageManagerViewModel ViewModel => (PackageManagerViewModel)DataContext!;

public bool CanGoBack => true;
Expand Down Expand Up @@ -260,17 +258,28 @@ private void BuildPage()
};

bool initiallyCustom = savedAge == "custom";
bool ageSupported = !_managersWithoutUpdateDate.Contains(manager.Name);
object ageDescription = !ageSupported
? new TextBlock
var releaseDateSupport = manager.Capabilities.KnowsPackageReleaseDate;
bool ageSupported = releaseDateSupport != PackageReleaseDateSupport.No;
object ageDescription = releaseDateSupport switch
{
PackageReleaseDateSupport.No => new TextBlock
{
Text = CoreTools.Translate("{pm} does not provide release dates for its packages, so this setting will have no effect")
.Replace("{pm}", manager.DisplayName),
Foreground = new SolidColorBrush(Color.Parse("#e05252")),
TextWrapping = TextWrapping.Wrap,
FontSize = 12,
}
: CoreTools.Translate("Override the global minimum update age for this package manager");
},
PackageReleaseDateSupport.Partial => new TextBlock
{
Text = CoreTools.Translate("{pm} only provides release dates for some of its packages, so this setting will only apply to those packages")
.Replace("{pm}", manager.DisplayName),
Foreground = new SolidColorBrush(Color.FromRgb(224, 168, 0)),
TextWrapping = TextWrapping.Wrap,
FontSize = 12,
},
_ => CoreTools.Translate("Override the global minimum update age for this package manager"),
};

ageCombo.IsEnabled = ageSupported;
customAgeInput.IsEnabled = ageSupported;
Expand Down
8 changes: 8 additions & 0 deletions src/UniGetUI.PackageEngine.Enums/ManagerCapabilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ public enum ProxySupport
Yes,
}

public enum PackageReleaseDateSupport
{
No,
Partial,
Yes,
}

public struct SourceCapabilities
{
public bool KnowsUpdateDate { get; set; } = false;
Expand Down Expand Up @@ -37,6 +44,7 @@ public struct ManagerCapabilities
public bool SupportsCustomPackageScreenshots = false;
public ProxySupport SupportsProxy = ProxySupport.No;
public bool SupportsProxyAuth = false;
public PackageReleaseDateSupport KnowsPackageReleaseDate = PackageReleaseDateSupport.No;
public SourceCapabilities Sources { get; set; }

public ManagerCapabilities()
Expand Down
1 change: 1 addition & 0 deletions src/UniGetUI.PackageEngine.Managers.Apt/Apt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public Apt()
SupportsCustomSources = false,
SupportsProxy = ProxySupport.No,
SupportsProxyAuth = false,
KnowsPackageReleaseDate = PackageReleaseDateSupport.Yes,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are apt, snap, flatpak, dnf, and pacman setting UpdateDate?

};

Properties = new ManagerProperties
Expand Down
3 changes: 2 additions & 1 deletion src/UniGetUI.PackageEngine.Managers.Bun/Bun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public Bun()
CanListDependencies = true,
SupportsPreRelease = true,
SupportsProxy = ProxySupport.No,
SupportsProxyAuth = false
SupportsProxyAuth = false,
KnowsPackageReleaseDate = PackageReleaseDateSupport.Yes,
};

Properties = new ManagerProperties
Expand Down
1 change: 1 addition & 0 deletions src/UniGetUI.PackageEngine.Managers.Cargo/Cargo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public Cargo()
CanDownloadInstaller = true,
SupportsProxy = ProxySupport.Partially,
SupportsProxyAuth = true,
KnowsPackageReleaseDate = PackageReleaseDateSupport.Yes,
};

var cratesIo = new ManagerSource(this, "crates.io", new Uri("https://index.crates.io/"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public Chocolatey()
},
SupportsProxy = ProxySupport.Yes,
SupportsProxyAuth = true,
KnowsPackageReleaseDate = PackageReleaseDateSupport.Yes,
};

Properties = new ManagerProperties
Expand Down
1 change: 1 addition & 0 deletions src/UniGetUI.PackageEngine.Managers.Dnf/Dnf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public Dnf()
SupportsCustomSources = false,
SupportsProxy = ProxySupport.No,
SupportsProxyAuth = false,
KnowsPackageReleaseDate = PackageReleaseDateSupport.Yes,
};

Properties = new ManagerProperties
Expand Down
1 change: 1 addition & 0 deletions src/UniGetUI.PackageEngine.Managers.Dotnet/DotNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public DotNet()
SupportsCustomVersions = true,
SupportsProxy = ProxySupport.Partially,
SupportsProxyAuth = true,
KnowsPackageReleaseDate = PackageReleaseDateSupport.Yes,
};

Properties = new ManagerProperties
Expand Down
1 change: 1 addition & 0 deletions src/UniGetUI.PackageEngine.Managers.Flatpak/Flatpak.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public Flatpak()
},
SupportsProxy = ProxySupport.No,
SupportsProxyAuth = false,
KnowsPackageReleaseDate = PackageReleaseDateSupport.Yes,
};

Properties = new ManagerProperties
Expand Down
1 change: 1 addition & 0 deletions src/UniGetUI.PackageEngine.Managers.Homebrew/Homebrew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public Homebrew()
},
SupportsProxy = ProxySupport.No,
SupportsProxyAuth = false,
KnowsPackageReleaseDate = PackageReleaseDateSupport.No,
};

Properties = new ManagerProperties
Expand Down
1 change: 1 addition & 0 deletions src/UniGetUI.PackageEngine.Managers.Npm/Npm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public Npm()
SupportsPreRelease = true,
SupportsProxy = ProxySupport.No,
SupportsProxyAuth = false,
KnowsPackageReleaseDate = PackageReleaseDateSupport.Yes,
};

Properties = new ManagerProperties
Expand Down
1 change: 1 addition & 0 deletions src/UniGetUI.PackageEngine.Managers.Pacman/Pacman.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public Pacman()
SupportsCustomSources = false,
SupportsProxy = ProxySupport.No,
SupportsProxyAuth = false,
KnowsPackageReleaseDate = PackageReleaseDateSupport.Yes,
};

Properties = new ManagerProperties
Expand Down
1 change: 1 addition & 0 deletions src/UniGetUI.PackageEngine.Managers.Pip/Pip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public Pip()
CanListDependencies = true,
SupportsProxy = ProxySupport.Yes,
SupportsProxyAuth = true,
KnowsPackageReleaseDate = PackageReleaseDateSupport.Yes,
};

Properties = new ManagerProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public PowerShell()
},
SupportsProxy = ProxySupport.Partially,
SupportsProxyAuth = true,
KnowsPackageReleaseDate = PackageReleaseDateSupport.Yes,
};

Properties = new ManagerProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public PowerShell7()
},
SupportsProxy = ProxySupport.Partially,
SupportsProxyAuth = true,
KnowsPackageReleaseDate = PackageReleaseDateSupport.Yes,
};

Properties = new ManagerProperties
Expand Down
1 change: 1 addition & 0 deletions src/UniGetUI.PackageEngine.Managers.Scoop/Scoop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public Scoop()
},
SupportsProxy = ProxySupport.No,
SupportsProxyAuth = false,
KnowsPackageReleaseDate = PackageReleaseDateSupport.No,
};

Properties = new ManagerProperties
Expand Down
1 change: 1 addition & 0 deletions src/UniGetUI.PackageEngine.Managers.Snap/Snap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public Snap()
SupportsCustomSources = false,
SupportsProxy = ProxySupport.No,
SupportsProxyAuth = false,
KnowsPackageReleaseDate = PackageReleaseDateSupport.Yes,
};

var snapcraftSource = new ManagerSource(this, "snapcraft", new Uri("https://snapcraft.io"));
Expand Down
1 change: 1 addition & 0 deletions src/UniGetUI.PackageEngine.Managers.Vcpkg/Vcpkg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public Vcpkg()
CanListDependencies = true,
SupportsProxy = ProxySupport.No,
SupportsProxyAuth = false,
KnowsPackageReleaseDate = PackageReleaseDateSupport.No,
};

string DefaultTriplet = GetDefaultTriplet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,14 @@ private static void ApplyManifestJson(IPackageDetails details, string output)
.ToArray()!;
}

// ReleaseDate is set at the manifest root by default, with an optional per-installer override
SetIfPresent(value => details.UpdateDate = value,
(hasInstaller ? GetString(installer, "ReleaseDate") : null) ?? GetString(manifest, "ReleaseDate"));

if (hasInstaller)
{
SetIfPresent(value => details.InstallerHash = value, GetString(installer, "InstallerSha256"));
SetIfPresent(value => details.InstallerType = value, GetString(installer, "InstallerType"));
SetIfPresent(value => details.UpdateDate = value, GetString(installer, "ReleaseDate"));

if (TryCreateUri(GetString(installer, "InstallerUrl"), out Uri? installerUri))
{
Expand Down
1 change: 1 addition & 0 deletions src/UniGetUI.PackageEngine.Managers.WinGet/WinGet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public WinGet()
},
SupportsProxy = ProxySupport.Partially,
SupportsProxyAuth = false,
KnowsPackageReleaseDate = PackageReleaseDateSupport.Partial,
};

Properties = new ManagerProperties
Expand Down
28 changes: 11 additions & 17 deletions src/UniGetUI/Pages/SettingsPages/GeneralPages/Updates.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using UniGetUI.Core.SettingsEngine;
using UniGetUI.Core.Tools;
using UniGetUI.PackageEngine;
using UniGetUI.PackageEngine.ManagerClasses.Manager;
using Windows.UI;
using Windows.UI.Text;

Expand All @@ -18,9 +19,6 @@ namespace UniGetUI.Pages.SettingsPages.GeneralPages
/// </summary>
public sealed partial class Updates : Page, ISettingsPage
{
private static readonly HashSet<string> _managersWithoutUpdateDate =
new(StringComparer.OrdinalIgnoreCase) { "Homebrew", "Scoop", "vcpkg", "WinGet" };

public Updates()
{
this.InitializeComponent();
Expand Down Expand Up @@ -97,9 +95,6 @@ private void RefreshMinimumAgeLayout()

private static UIElement BuildReleaseDateCompatTable()
{
string yesStr = CoreTools.Translate("Yes");
string noStr = CoreTools.Translate("No");

var managers = PEInterface.Managers.ToList();

var table = new Grid { ColumnSpacing = 24, RowSpacing = 8 };
Expand Down Expand Up @@ -130,8 +125,7 @@ private static UIElement BuildReleaseDateCompatTable()
int row = i + 1;
var name = new TextBlock { Text = manager.DisplayName, VerticalAlignment = VerticalAlignment.Center };
Grid.SetRow(name, row); Grid.SetColumn(name, 0);
bool supported = !_managersWithoutUpdateDate.Contains(manager.Name);
var badge = MakeStatusBadge(supported ? yesStr : noStr, supported);
var badge = MakeStatusBadge(manager.Capabilities.KnowsPackageReleaseDate);
Grid.SetRow(badge, row); Grid.SetColumn(badge, 1);
table.Children.Add(name);
table.Children.Add(badge);
Expand All @@ -156,23 +150,23 @@ private static UIElement BuildReleaseDateCompatTable()
return card;
}

private static Border MakeStatusBadge(string text, bool isSupported)
private static Border MakeStatusBadge(PackageReleaseDateSupport support)
{
var bgColor = isSupported
? Color.FromArgb(60, 0, 180, 0)
: Color.FromArgb(60, 224, 82, 82);
var borderColor = isSupported
? Color.FromArgb(120, 0, 180, 0)
: Color.FromArgb(120, 224, 82, 82);
(string text, Color baseColor) = support switch
{
PackageReleaseDateSupport.Yes => (CoreTools.Translate("Yes"), Color.FromArgb(255, 0, 180, 0)),
PackageReleaseDateSupport.Partial => (CoreTools.Translate("Partial"), Color.FromArgb(255, 224, 168, 0)),
_ => (CoreTools.Translate("No"), Color.FromArgb(255, 224, 82, 82)),
};

return new Border
{
CornerRadius = new CornerRadius(4),
Padding = new Thickness(4, 2, 4, 2),
BorderThickness = new Thickness(1),
HorizontalAlignment = HorizontalAlignment.Stretch,
Background = new SolidColorBrush(bgColor),
BorderBrush = new SolidColorBrush(borderColor),
Background = new SolidColorBrush(Color.FromArgb(60, baseColor.R, baseColor.G, baseColor.B)),
BorderBrush = new SolidColorBrush(Color.FromArgb(120, baseColor.R, baseColor.G, baseColor.B)),
Child = new TextBlock { Text = text, TextAlignment = TextAlignment.Center },
};
}
Expand Down
Loading
Loading