Skip to content

Commit

Permalink
Add remove all feature (#1626)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamnarauf authored Jan 12, 2024
1 parent 1bc8749 commit cb99883
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,10 @@
<value>Check the spelling or try new keywords.</value>
<comment>Text displayed when no search results were found</comment>
</data>
<data name="RemoveAll.Text" xml:space="preserve">
<value>Remove all</value>
<comment>Label for removing all items from selection</comment>
</data>
<data name="RemoveApplication" xml:space="preserve">
<value>Remove</value>
<comment>Text announced when screen readers focus on the 'Remove' button. The 'Remove' button allows users to remove an application from their cart</comment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
Expand Down Expand Up @@ -41,6 +42,8 @@ public partial class AppManagementViewModel : SetupPageViewModelBase
StringResource.GetLocalized(StringResourceKey.ApplicationsAddedSingular) :
StringResource.GetLocalized(StringResourceKey.ApplicationsAddedPlural, SelectedPackages.Count);

public bool EnableRemoveAll => SelectedPackages.Count > 0;

public AppManagementViewModel(
ISetupFlowStringResource stringResource,
SetupFlowOrchestrator orchestrator,
Expand All @@ -57,6 +60,7 @@ public AppManagementViewModel(
_screenReaderService = host.GetService<IScreenReaderService>();

_packageProvider.PackageSelectionChanged += (_, _) => OnPropertyChanged(nameof(ApplicationsAddedText));
_packageProvider.PackageSelectionChanged += (_, _) => OnPropertyChanged(nameof(EnableRemoveAll));

PageTitle = StringResource.GetLocalized(StringResourceKey.ApplicationsPageTitle);

Expand Down Expand Up @@ -128,4 +132,14 @@ private async Task SearchTextChangedAsync(string text, CancellationToken cancell
break;
}
}

[RelayCommand]
private void RemoveAllPackages()
{
Log.Logger?.ReportInfo(Log.Component.AppManagement, $"Removing all packages from selected applications for installation");
foreach (var package in SelectedPackages.ToList())
{
package.IsSelected = false;
}
}
}
21 changes: 16 additions & 5 deletions tools/SetupFlow/DevHome.SetupFlow/Views/AppManagementView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,22 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<!-- Header text -->
<StackPanel Grid.Row="0" Padding="5 0" Orientation="Vertical" Spacing="4">
<TextBlock x:Name="SidePanelTitle" Style="{ThemeResource BaseTextBlockStyle}" x:Uid="ms-resource:///DevHome.SetupFlow/Resources/SelectedPackages" />
<TextBlock Style="{ThemeResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorSecondary}" Text="{x:Bind ViewModel.ApplicationsAddedText,Mode=OneWay}"/>
</StackPanel>
<Grid Grid.Row="0">
<!-- Header text -->
<StackPanel Grid.Row="0" Padding="5 0" Orientation="Vertical" Spacing="4">
<TextBlock x:Name="SidePanelTitle" Style="{ThemeResource BaseTextBlockStyle}" x:Uid="ms-resource:///DevHome.SetupFlow/Resources/SelectedPackages" />
<TextBlock Style="{ThemeResource CaptionTextBlockStyle}" Foreground="{ThemeResource TextFillColorSecondary}" Text="{x:Bind ViewModel.ApplicationsAddedText,Mode=OneWay}"/>
</StackPanel>
<!-- Remove all -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<HyperlinkButton
AutomationProperties.AutomationControlType="Button"
Command="{x:Bind ViewModel.RemoveAllPackagesCommand}"
IsEnabled="{x:Bind ViewModel.EnableRemoveAll, Mode=OneWay}">
<TextBlock x:Uid="ms-resource:///DevHome.SetupFlow/Resources/RemoveAll" />
</HyperlinkButton>
</StackPanel>
</Grid>

<!-- No package selected -->
<TextBlock
Expand Down

0 comments on commit cb99883

Please sign in to comment.