9.0 KiB
9.0 KiB
phase, plan, type, wave, depends_on, files_modified, autonomous, requirements, must_haves
| phase | plan | type | wave | depends_on | files_modified | autonomous | requirements | must_haves | |||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 13-user-directory-viewmodel | 01 | execute | 1 |
|
true |
|
|
Purpose: SC3 requires "Members only / Include guests" toggle that filters in-memory without a new Graph request. The service must fetch all users (members + guests) when requested, and the model must carry UserType for client-side filtering.
Output: Updated model, interface, implementation, and tests.
<execution_context> @C:/Users/dev/.claude/get-shit-done/workflows/execute-plan.md @C:/Users/dev/.claude/get-shit-done/templates/summary.md </execution_context>
@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/phases/13-user-directory-viewmodel/13-RESEARCH.md From SharepointToolbox/Core/Models/GraphDirectoryUser.cs: ```csharp public record GraphDirectoryUser( string DisplayName, string UserPrincipalName, string? Mail, string? Department, string? JobTitle); ```From SharepointToolbox/Services/IGraphUserDirectoryService.cs:
public interface IGraphUserDirectoryService
{
Task<IReadOnlyList<GraphDirectoryUser>> GetUsersAsync(
string clientId,
IProgress<int>? progress = null,
CancellationToken ct = default);
}
From SharepointToolbox/Services/GraphUserDirectoryService.cs:
config.QueryParameters.Filter = "accountEnabled eq true and userType eq 'Member'";
config.QueryParameters.Select = new[]
{
"displayName", "userPrincipalName", "mail", "department", "jobTitle"
};
internal static GraphDirectoryUser MapUser(User user) =>
new(
DisplayName: user.DisplayName ?? user.UserPrincipalName ?? string.Empty,
UserPrincipalName: user.UserPrincipalName ?? string.Empty,
Mail: user.Mail,
Department: user.Department,
JobTitle: user.JobTitle);
2. Check for any existing code that constructs GraphDirectoryUser (MapUser, tests) and add the UserType parameter.
Search for `new GraphDirectoryUser(` and `new(` in test files to find all construction sites.
dotnet build --no-restore -warnaserror
GraphDirectoryUser has UserType property. All construction sites updated. Build passes.
Task 2: Add includeGuests parameter to interface and implementation
SharepointToolbox/Services/IGraphUserDirectoryService.cs,
SharepointToolbox/Services/GraphUserDirectoryService.cs
- IGraphUserDirectoryService.GetUsersAsync has a new `bool includeGuests = false` parameter
- When includeGuests=false: filter is "accountEnabled eq true and userType eq 'Member'" (unchanged)
- When includeGuests=true: filter is "accountEnabled eq true" (fetches members + guests)
- "userType" is always in the select set (needed for MapUser)
- MapUser includes user.UserType in the mapping
1. Update `IGraphUserDirectoryService.cs`:
```csharp
Task> GetUsersAsync(
string clientId,
bool includeGuests = false,
IProgress? progress = null,
CancellationToken ct = default);
```
2. Update `GraphUserDirectoryService.cs`:
- Update method signature to match interface
- Add `userType` to Select array
- Branch filter based on includeGuests:
```csharp
config.QueryParameters.Filter = includeGuests
? "accountEnabled eq true"
: "accountEnabled eq true and userType eq 'Member'";
config.QueryParameters.Select = new[]
{
"displayName", "userPrincipalName", "mail", "department", "jobTitle", "userType"
};
```
- Update MapUser:
```csharp
internal static GraphDirectoryUser MapUser(User user) =>
new(
DisplayName: user.DisplayName ?? user.UserPrincipalName ?? string.Empty,
UserPrincipalName: user.UserPrincipalName ?? string.Empty,
Mail: user.Mail,
Department: user.Department,
JobTitle: user.JobTitle,
UserType: user.UserType);
```
dotnet build --no-restore -warnaserror
Interface and implementation updated. Default parameter preserves backward compat. Build passes.
Task 3: Update tests
SharepointToolbox.Tests/Services/GraphUserDirectoryServiceTests.cs
- Existing MapUser tests pass with UserType parameter added
- New test: MapUser populates UserType from User.UserType
- New test: MapUser returns null UserType when User.UserType is null
1. Read `SharepointToolbox.Tests/Services/GraphUserDirectoryServiceTests.cs`
2. Update any existing `MapUser` test assertions to include the UserType field
3. Add test: MapUser_PopulatesUserType — set User.UserType = "Member", verify GraphDirectoryUser.UserType == "Member"
4. Add test: MapUser_NullUserType — set User.UserType = null, verify GraphDirectoryUser.UserType is null
5. Run tests
dotnet test SharepointToolbox.Tests --filter "FullyQualifiedName~GraphUserDirectoryService" --no-build -q
All MapUser tests pass including UserType coverage.
```bash
dotnet build --no-restore -warnaserror
dotnet test SharepointToolbox.Tests --filter "FullyQualifiedName~GraphUserDirectoryService" --no-build -q
```
Both must pass with zero failures.
<success_criteria>
- GraphDirectoryUser has UserType (string?) as last positional parameter
- IGraphUserDirectoryService.GetUsersAsync has bool includeGuests = false parameter
- When includeGuests=false, filter unchanged (backward compatible)
- When includeGuests=true, filter omits userType restriction
- MapUser populates UserType from Graph User object
- userType always in select set
- All tests pass </success_criteria>