Skip to content

Commit 4b9a609

Browse files
committed
Add a popup to warn the user when the package doesn't have available details
1 parent 8d59b58 commit 4b9a609

File tree

7 files changed

+67
-22
lines changed

7 files changed

+67
-22
lines changed

src/Directory.Build.props

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
<ImplicitUsings>enable</ImplicitUsings>
44
<TargetFramework>net8.0-windows10.0.26100.0</TargetFramework>
55
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
6-
<WindowsSdkPackageVersion>10.0.26100.56</WindowsSdkPackageVersion>
6+
<!-- IF BUILD FAILS DUE TO MISSING Microsoft.Management.Deployment NAMESPACE,
7+
TOGGLE THE LAST NUMBER OF THE LINE BELOW 1 UNIT UP OR DOWN, AND REBUILD-->
8+
<WindowsSdkPackageVersion>10.0.26100.57</WindowsSdkPackageVersion>
9+
710
<SdkVersion>8.0.407</SdkVersion>
811
<Authors>Martí Climent and the contributors</Authors>
912
<PublisherName>Martí Climent</PublisherName>

src/UniGetUI/Controls/OperationWidgets/OperationControl.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -573,16 +573,20 @@ public List<MenuFlyoutItemBase> GetOperationOptions()
573573
var details = new BetterMenuItem {
574574
Text = CoreTools.Translate("Package details"),
575575
IconName = IconType.Info_Round,
576+
IsEnabled = !packageOp.Package.Source.IsVirtualManager
576577
};
577578
details.Click += (_, _) =>
578579
{
579580
DialogHelper.ShowPackageDetails(packageOp.Package, OperationType.None, TEL_InstallReferral.DIRECT_SEARCH);
580581
};
581582
optionsMenu.Add(details);
582583

583-
var installationSettings = new BetterMenuItem {
584+
585+
var installationSettings = new BetterMenuItem
586+
{
584587
Text = CoreTools.Translate("Installation options"),
585588
IconName = IconType.Options,
589+
IsEnabled = !packageOp.Package.Source.IsVirtualManager
586590
};
587591
installationSettings.Click += (_, _) =>
588592
{

src/UniGetUI/MainWindow.xaml

+7
Original file line numberDiff line numberDiff line change
@@ -177,5 +177,12 @@
177177
Visibility="Visible" />
178178
</Grid>
179179
</Frame>
180+
181+
<TeachingTip
182+
x:Name="DismissableNotification"
183+
x:FieldModifier="public"
184+
PlacementMargin="20"
185+
PreferredPlacement="Auto" />
186+
180187
</Grid>
181188
</Window>

src/UniGetUI/MainWindow.xaml.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public MainWindow()
5353
DialogHelper.Window = this;
5454

5555
InitializeComponent();
56+
DismissableNotification.CloseButtonContent = CoreTools.Translate("Close");
5657

5758
ExtendsContentIntoTitleBar = true;
5859
try
@@ -750,8 +751,15 @@ public void ApplyTheme()
750751

751752
public void SharePackage(IPackage? package)
752753
{
753-
if (package is null || package.Source.IsVirtualManager || package is InvalidImportedPackage)
754+
if (package is null)
755+
return;
756+
757+
if (package.Source.IsVirtualManager || package is InvalidImportedPackage)
754758
{
759+
DialogHelper.ShowDismissableBalloon(
760+
CoreTools.Translate("Something went wrong"),
761+
CoreTools.Translate("\"{0}\" is a local package and can't be shared", package.Name)
762+
);
755763
return;
756764
}
757765

src/UniGetUI/Pages/DialogPages/DialogHelper_Generic.cs

+7
Original file line numberDiff line numberDiff line change
@@ -618,4 +618,11 @@ public static async Task HowToAddPackagesToBundle()
618618
if(result is ContentDialogResult.Primary) Window.NavigationPage.NavigateTo(PageType.Discover);
619619
else if(result is ContentDialogResult.Secondary) Window.NavigationPage.NavigateTo(PageType.Installed);
620620
}
621+
622+
public static void ShowDismissableBalloon(string title, string message)
623+
{
624+
Window.DismissableNotification.Title = title;
625+
Window.DismissableNotification.Content = new TextBlock() { Text = message, TextWrapping = TextWrapping.Wrap };
626+
Window.DismissableNotification.IsOpen = true;
627+
}
621628
}

src/UniGetUI/Pages/SoftwarePages/AbstractPackagesPage.xaml.cs

+23-18
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,15 @@ protected void ClearSourceSelectionButton_Click(object sender, RoutedEventArgs e
882882

883883
protected void ShowDetailsForPackage(IPackage? package, TEL_InstallReferral referral)
884884
{
885-
if (package is null || package.Source.IsVirtualManager || package is InvalidImportedPackage)
885+
if (package is null)
886+
return;
887+
888+
if(package.Source.IsVirtualManager || package is InvalidImportedPackage)
886889
{
890+
DialogHelper.ShowDismissableBalloon(
891+
CoreTools.Translate("Something went wrong"),
892+
CoreTools.Translate("{0} is a local package and does not have available details", package.Name)
893+
);
887894
return;
888895
}
889896

@@ -903,21 +910,25 @@ protected void OpenPackageInstallLocation(IPackage? package)
903910
});
904911
}
905912

906-
907913
protected void SharePackage(IPackage? package)
908914
{
909915
if (package is null)
910-
{
911916
return;
912-
}
913917

914918
MainApp.Instance.MainWindow.SharePackage(package);
915919
}
916920

917921
protected async void ShowInstallationOptionsForPackage(IPackage? package)
918922
{
919-
if (package is null || package.Source.IsVirtualManager || package is InvalidImportedPackage)
923+
if (package is null)
924+
return;
925+
926+
if (package.Source.IsVirtualManager || package is InvalidImportedPackage)
920927
{
928+
DialogHelper.ShowDismissableBalloon(
929+
CoreTools.Translate("Something went wrong"),
930+
CoreTools.Translate("{0} a local package and is not compatible with this feature", package.Name)
931+
);
921932
return;
922933
}
923934

@@ -1165,11 +1176,8 @@ private void PackageItemContainer_PreviewKeyDown(object sender, KeyRoutedEventAr
11651176
{
11661177
if (IS_ALT_PRESSED)
11671178
{
1168-
if (!package.Source.IsVirtualManager && package is not InvalidImportedPackage)
1169-
{
1170-
ShowInstallationOptionsForPackage(package);
1171-
e.Handled = true;
1172-
}
1179+
ShowInstallationOptionsForPackage(package);
1180+
e.Handled = true;
11731181
}
11741182
else if (IS_CONTROL_PRESSED)
11751183
{
@@ -1181,14 +1189,11 @@ private void PackageItemContainer_PreviewKeyDown(object sender, KeyRoutedEventAr
11811189
}
11821190
else
11831191
{
1184-
if (!package.Source.IsVirtualManager && package is not InvalidImportedPackage)
1185-
{
1186-
TEL_InstallReferral referral = TEL_InstallReferral.ALREADY_INSTALLED;
1187-
if (PAGE_NAME == "Bundles") referral = TEL_InstallReferral.FROM_BUNDLE;
1188-
if (PAGE_NAME == "Discover") referral = TEL_InstallReferral.DIRECT_SEARCH;
1189-
ShowDetailsForPackage(package, referral);
1190-
e.Handled = true;
1191-
}
1192+
TEL_InstallReferral referral = TEL_InstallReferral.ALREADY_INSTALLED;
1193+
if (PAGE_NAME == "Bundles") referral = TEL_InstallReferral.FROM_BUNDLE;
1194+
if (PAGE_NAME == "Discover") referral = TEL_InstallReferral.DIRECT_SEARCH;
1195+
ShowDetailsForPackage(package, referral);
1196+
e.Handled = true;
11921197
}
11931198
}
11941199
else if (e.Key == VirtualKey.Space && package is not null)

src/UniGetUI/Pages/SoftwarePages/PackageBundlesPage.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,18 @@ public override void GenerateToolBar()
249249

250250
PackageDetails.Click += (_, _) =>
251251
{
252-
if (SelectedItem is null) return;
252+
if (SelectedItem is null)
253+
return;
254+
255+
if (SelectedItem.Source.IsVirtualManager || SelectedItem is InvalidImportedPackage)
256+
{
257+
DialogHelper.ShowDismissableBalloon(
258+
CoreTools.Translate("Something went wrong"),
259+
CoreTools.Translate("\"{0}\" is a local package and can't be shared", SelectedItem.Name)
260+
);
261+
return;
262+
}
263+
253264
DialogHelper.ShowPackageDetails(SelectedItem, OperationType.None, TEL_InstallReferral.FROM_BUNDLE);
254265
};
255266

0 commit comments

Comments
 (0)