---
phase: 07-user-access-audit
plan: 09
type: execute
wave: 6
depends_on: ["07-05"]
files_modified:
  - SharepointToolbox/Views/Tabs/UserAccessAuditView.xaml
autonomous: true
requirements:
  - UACC-01
  - UACC-02
gap_closure: true
source_gaps:
  - "Gap 1: Missing DataGrid visual indicators (guest badge + warning icon)"
  - "Gap 2: Missing ObjectType column in DataGrid"
must_haves:
  truths:
    - "High-privilege entries show a warning icon (⚠) in the Permission Level column cell template"
    - "External users show a guest badge (👤 Guest) in the User column cell template when IsExternalUser is true"
    - "DataGrid columns include Object Type bound to ObjectType between Object and Permission Level"
  artifacts:
    - path: "SharepointToolbox/Views/Tabs/UserAccessAuditView.xaml"
      provides: "DataGrid with visual indicators for high-privilege/external users and ObjectType column"
      contains: "IsExternalUser DataTrigger, IsHighPrivilege warning icon, ObjectType column"
  key_links:
    - from: "SharepointToolbox/Views/Tabs/UserAccessAuditView.xaml"
      to: "SharepointToolbox/Core/Models/UserAccessEntry.cs"
      via: "Bindings on IsExternalUser, IsHighPrivilege, ObjectType properties"
      pattern: "DataTrigger Binding"
---

<objective>
Add missing visual indicators and ObjectType column to the UserAccessAuditView DataGrid.

Purpose: Close verification gaps 1 and 2 — the XAML currently lacks per-row guest badges for external users, warning icons for high-privilege entries, and the ObjectType column.
Output: Updated UserAccessAuditView.xaml with all three additions.
</objective>

<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>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/phases/07-user-access-audit/07-CONTEXT.md
@.planning/phases/07-user-access-audit/07-05-SUMMARY.md
@.planning/phases/07-user-access-audit/07-VERIFICATION.md

<interfaces>
<!-- UserAccessEntry fields available for binding -->
From SharepointToolbox/Core/Models/UserAccessEntry.cs:
```csharp
public record UserAccessEntry(
    string UserDisplayName, string UserLogin,
    string SiteUrl, string SiteTitle,
    string ObjectType, string ObjectTitle, string ObjectUrl,
    string PermissionLevel, AccessType AccessType, string GrantedThrough,
    bool IsHighPrivilege, bool IsExternalUser);
```

<!-- Current DataGrid columns (lines 219-249 of UserAccessAuditView.xaml) -->
Current columns: User (UserLogin), Site (SiteTitle), Object (ObjectTitle), Permission Level (PermissionLevel), Access Type (template), Granted Through (GrantedThrough).
Missing: ObjectType column, guest badge in User column, warning icon in Permission Level column.
</interfaces>
</context>

<tasks>

<task type="auto">
  <name>Task 1: Add guest badge, warning icon, and ObjectType column to DataGrid</name>
  <files>SharepointToolbox/Views/Tabs/UserAccessAuditView.xaml</files>
  <action>
    Modify the DataGrid columns section (lines 219-249) with three changes:

    **Change 1 — Convert User column to DataGridTemplateColumn with guest badge:**
    Replace the plain `DataGridTextColumn Header="User"` with a `DataGridTemplateColumn`:
    ```xml
    <DataGridTemplateColumn Header="User" Width="180">
      <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
          <StackPanel Orientation="Horizontal">
            <TextBlock Text="{Binding UserLogin}" VerticalAlignment="Center" />
            <Border Background="#F39C12" CornerRadius="3" Padding="4,1" Margin="6,0,0,0"
                    VerticalAlignment="Center">
              <Border.Style>
                <Style TargetType="Border">
                  <Setter Property="Visibility" Value="Collapsed" />
                  <Style.Triggers>
                    <DataTrigger Binding="{Binding IsExternalUser}" Value="True">
                      <Setter Property="Visibility" Value="Visible" />
                    </DataTrigger>
                  </Style.Triggers>
                </Style>
              </Border.Style>
              <TextBlock Text="Guest" FontSize="10" Foreground="White" FontWeight="SemiBold" />
            </Border>
          </StackPanel>
        </DataTemplate>
      </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
    ```

    **Change 2 — Convert Permission Level column to DataGridTemplateColumn with warning icon:**
    Replace the plain `DataGridTextColumn Header="Permission Level"` with a `DataGridTemplateColumn`:
    ```xml
    <DataGridTemplateColumn Header="Permission Level" Width="140">
      <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
          <StackPanel Orientation="Horizontal">
            <TextBlock Text="⚠" Foreground="#E74C3C" Margin="0,0,4,0"
                       FontSize="12" VerticalAlignment="Center">
              <TextBlock.Style>
                <Style TargetType="TextBlock">
                  <Setter Property="Visibility" Value="Collapsed" />
                  <Style.Triggers>
                    <DataTrigger Binding="{Binding IsHighPrivilege}" Value="True">
                      <Setter Property="Visibility" Value="Visible" />
                    </DataTrigger>
                  </Style.Triggers>
                </Style>
              </TextBlock.Style>
            </TextBlock>
            <TextBlock Text="{Binding PermissionLevel}" VerticalAlignment="Center" />
          </StackPanel>
        </DataTemplate>
      </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
    ```

    **Change 3 — Add ObjectType column between Object and Permission Level:**
    ```xml
    <DataGridTextColumn Header="Object Type" Binding="{Binding ObjectType}" Width="90" />
    ```

    Insert this column after the "Object" column and before the "Permission Level" column.

    Final column order: User (with guest badge), Site, Object, Object Type, Permission Level (with ⚠ icon), Access Type, Granted Through.
  </action>
  <verify>
    <automated>cd "C:\Users\dev\Documents\projets\Sharepoint" && dotnet build SharepointToolbox/SharepointToolbox.csproj --no-restore 2>&1 | tail -5</automated>
  </verify>
  <done>DataGrid now shows: guest badge on external user rows (orange "Guest" pill), warning icon (⚠) on high-privilege permission levels, and ObjectType column showing Site Collection/Site/List/Folder distinction.</done>
</task>

</tasks>

<verification>
- `dotnet build SharepointToolbox/SharepointToolbox.csproj` — XAML compiles without errors
- Visual inspection: DataGrid columns order is User (with guest badge), Site, Object, Object Type, Permission Level (with ⚠), Access Type, Granted Through
- Guest badge visible only when IsExternalUser=true
- Warning icon visible only when IsHighPrivilege=true
</verification>

<success_criteria>
The DataGrid shows guest badges for external users, warning icons for high-privilege entries, and the ObjectType column — closing verification gaps 1 and 2.
</success_criteria>

<output>
After completion, create `.planning/phases/07-user-access-audit/07-09-SUMMARY.md`
</output>
