Skip to content

Commit

Permalink
Ignored updates dialog will ask for confirmation before resetting the…
Browse files Browse the repository at this point in the history
… list (fix #1913)
  • Loading branch information
marticliment committed Sep 22, 2024
1 parent 7172441 commit b8f01ed
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/UniGetUI/Pages/DialogPages/DialogHelper_Generic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,14 @@ public static async Task ManageIgnoredUpdates()
};
UpdatesDialog.Resources["ContentDialogMaxWidth"] = 1400;
UpdatesDialog.Resources["ContentDialogMaxHeight"] = 1000;

UpdatesDialog.SecondaryButtonText = CoreTools.Translate("Close");
UpdatesDialog.PrimaryButtonText = CoreTools.Translate("Reset");

//UpdatesDialog.PrimaryButtonText = CoreTools.Translate("Reset");

UpdatesDialog.DefaultButton = ContentDialogButton.Secondary;
UpdatesDialog.Title = CoreTools.Translate("Manage ignored updates");
IgnoredUpdatesManager IgnoredUpdatesPage = new();
UpdatesDialog.PrimaryButtonClick += IgnoredUpdatesPage.ManageIgnoredUpdates_SecondaryButtonClick;
UpdatesDialog.Content = IgnoredUpdatesPage;
IgnoredUpdatesPage.Close += (_, _) => UpdatesDialog.Hide();

Expand Down
54 changes: 52 additions & 2 deletions src/UniGetUI/Pages/DialogPages/IgnoredUpdates.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,59 @@

<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<StackPanel Spacing="8" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<widgets:TranslatedTextBlock Text="The packages listed here won't be taken in account when checking for updates. Double-click them or click the button on their right to stop ignoring their updates."/>
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<widgets:TranslatedTextBlock
Text="The packages listed here won't be taken in account when checking for updates. Double-click them or click the button on their right to stop ignoring their updates."/>
<Button
Grid.Column="2"
HorizontalAlignment="Stretch">
<widgets:TranslatedTextBlock Text="Reset list"/>
<Button.Flyout>
<Flyout
x:Name="ConfirmResetFlyout"
LightDismissOverlayMode="Off"
Placement="Bottom">
<Grid Width="300" ColumnSpacing="8" RowSpacing="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock
Grid.ColumnSpan="2"
Text="Do you really want to reset the ignored updates list? This action cannot be reverted"
Margin="0,0,0,0"
TextWrapping="WrapWholeWords"
/>
<Button
Name="NoResetButton"
Click="NoResetButton_Click"
Grid.Row="1" Grid.Column="1"
HorizontalAlignment="Stretch"
Style="{ThemeResource AccentButtonStyle}">
<widgets:TranslatedTextBlock Text="No"/>
</Button>
<Button
Name="YesResetButton"
Click="YesResetButton_Click"
Grid.Row="1" Grid.Column="0"
HorizontalAlignment="Stretch">
<widgets:TranslatedTextBlock Text="Yes"/>
</Button>
</Grid>
</Flyout>
</Button.Flyout>
</Button>
</Grid>
<ScrollViewer>
<ListView Name="IgnoredUpdatesList" Height="300" HorizontalAlignment="Stretch" Padding="2,4,2,4" CornerRadius="6" DoubleTapped="IgnoredUpdatesList_DoubleTapped" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ListView Name="IgnoredUpdatesList" Height="350" HorizontalAlignment="Stretch" Padding="2,4,2,4" CornerRadius="6" DoubleTapped="IgnoredUpdatesList_DoubleTapped" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:IgnoredPackageEntry">
<Grid ColumnSpacing="4">
Expand Down
15 changes: 11 additions & 4 deletions src/UniGetUI/Pages/DialogPages/IgnoredUpdates.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.ObjectModel;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using UniGetUI.Core.Logging;
using UniGetUI.Core.Tools;
using UniGetUI.Interface.Enums;
using UniGetUI.PackageEngine;
Expand Down Expand Up @@ -63,18 +64,24 @@ private async void IgnoredUpdatesList_DoubleTapped(object sender, DoubleTappedRo
}
}

public async void ManageIgnoredUpdates_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
private void CloseButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
Close?.Invoke(this, EventArgs.Empty);
}


private async void YesResetButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
args.Cancel = true;
foreach (IgnoredPackageEntry package in ignoredPackages.ToArray())
{
await package.RemoveFromIgnoredUpdates();
}
ConfirmResetFlyout.Hide();
}

private void CloseButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
private void NoResetButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
Close?.Invoke(this, EventArgs.Empty);
ConfirmResetFlyout.Hide();
}
}

Expand Down

0 comments on commit b8f01ed

Please sign in to comment.