From e6ba2d8146484ab85e4b74b4640282d051e462e4 Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 9 Apr 2026 09:26:12 +0200 Subject: [PATCH] feat(14-01): add SelectDirectoryUserCommand bridging directory to audit pipeline - RelayCommand converts to GraphUserResult and adds to SelectedUsers - Duplicate UPN check prevents adding same user twice - Initialized in both DI and test constructors - 4 new tests pass (add, skip duplicate, null, auditable) Co-Authored-By: Claude Opus 4.6 (1M context) --- .../ViewModels/Tabs/UserAccessAuditViewModel.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/SharepointToolbox/ViewModels/Tabs/UserAccessAuditViewModel.cs b/SharepointToolbox/ViewModels/Tabs/UserAccessAuditViewModel.cs index a0a331f..d32b964 100644 --- a/SharepointToolbox/ViewModels/Tabs/UserAccessAuditViewModel.cs +++ b/SharepointToolbox/ViewModels/Tabs/UserAccessAuditViewModel.cs @@ -137,6 +137,7 @@ public partial class UserAccessAuditViewModel : FeatureViewModelBase public IAsyncRelayCommand ExportHtmlCommand { get; } public RelayCommand AddUserCommand { get; } public RelayCommand RemoveUserCommand { get; } + public RelayCommand SelectDirectoryUserCommand { get; } public IAsyncRelayCommand LoadDirectoryCommand { get; } public RelayCommand CancelDirectoryLoadCommand { get; } @@ -174,6 +175,7 @@ public partial class UserAccessAuditViewModel : FeatureViewModelBase ExportHtmlCommand = new AsyncRelayCommand(ExportHtmlAsync, CanExport); AddUserCommand = new RelayCommand(ExecuteAddUser); RemoveUserCommand = new RelayCommand(ExecuteRemoveUser); + SelectDirectoryUserCommand = new RelayCommand(ExecuteSelectDirectoryUser); SelectedUsers.CollectionChanged += (_, _) => OnPropertyChanged(nameof(SelectedUsersLabel)); @@ -216,6 +218,7 @@ public partial class UserAccessAuditViewModel : FeatureViewModelBase ExportHtmlCommand = new AsyncRelayCommand(ExportHtmlAsync, CanExport); AddUserCommand = new RelayCommand(ExecuteAddUser); RemoveUserCommand = new RelayCommand(ExecuteRemoveUser); + SelectDirectoryUserCommand = new RelayCommand(ExecuteSelectDirectoryUser); SelectedUsers.CollectionChanged += (_, _) => OnPropertyChanged(nameof(SelectedUsersLabel)); @@ -548,6 +551,16 @@ public partial class UserAccessAuditViewModel : FeatureViewModelBase SelectedUsers.Remove(user); } + private void ExecuteSelectDirectoryUser(GraphDirectoryUser? dirUser) + { + if (dirUser == null) return; + var userResult = new GraphUserResult(dirUser.DisplayName, dirUser.UserPrincipalName, dirUser.Mail); + if (!SelectedUsers.Any(u => u.UserPrincipalName == userResult.UserPrincipalName)) + { + SelectedUsers.Add(userResult); + } + } + private async Task DebounceSearchAsync(string query, CancellationToken ct) { try