feat(07-05): create UserAccessAuditView XAML layout
- Two-panel layout (290px left + * right) following PermissionsView pattern - Left panel: people picker with autocomplete list + removable user pills, site picker button, scan option checkboxes, run/cancel/export buttons - Right panel: 3-card summary banner (TotalAccessCount, SitesCount, HighPrivilegeCount), filter TextBox, group-by ToggleButton, color-coded DataGrid - DataGrid: color-coded rows by AccessType (Direct=blue, Group=green, Inherited=gray), warning icon for high privilege, Guest badge for external users, access type icons - GroupStyle with Expander headers showing group name + item count - Status bar with ProgressBar + StatusMessage
This commit is contained in:
411
SharepointToolbox/Views/Tabs/UserAccessAuditView.xaml
Normal file
411
SharepointToolbox/Views/Tabs/UserAccessAuditView.xaml
Normal file
@@ -0,0 +1,411 @@
|
||||
<UserControl x:Class="SharepointToolbox.Views.Tabs.UserAccessAuditView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:loc="clr-namespace:SharepointToolbox.Localization"
|
||||
xmlns:models="clr-namespace:SharepointToolbox.Core.Models">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="290" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Left panel: Audit configuration -->
|
||||
<DockPanel Grid.Column="0" Grid.Row="0" Margin="8">
|
||||
|
||||
<!-- People Picker GroupBox -->
|
||||
<GroupBox Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[audit.grp.users]}"
|
||||
DockPanel.Dock="Top" Margin="0,0,0,8" Padding="8">
|
||||
<StackPanel>
|
||||
|
||||
<!-- Search box -->
|
||||
<TextBox Text="{Binding SearchQuery, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,0,0,2" />
|
||||
|
||||
<!-- Search spinner -->
|
||||
<TextBlock Text="Searching..."
|
||||
Foreground="Gray" FontStyle="Italic" FontSize="11"
|
||||
Margin="0,0,0,2">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsSearching}" Value="True">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
|
||||
<!-- Autocomplete results list: shown when SearchResults is not empty -->
|
||||
<ListBox x:Name="SearchResultsList"
|
||||
ItemsSource="{Binding SearchResults}"
|
||||
MaxHeight="160"
|
||||
BorderThickness="1"
|
||||
BorderBrush="#CCCCCC"
|
||||
Margin="0,0,0,4"
|
||||
Visibility="Collapsed">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Vertical" Margin="2">
|
||||
<TextBlock Text="{Binding DisplayName}" FontWeight="SemiBold" FontSize="12" />
|
||||
<TextBlock Text="{Binding Mail}" Foreground="Gray" FontSize="11" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<EventSetter Event="MouseLeftButtonUp" Handler="OnSearchResultClicked" />
|
||||
<Setter Property="Padding" Value="4,2" />
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
</ListBox>
|
||||
|
||||
<!-- Selected users pills (removable) -->
|
||||
<ItemsControl ItemsSource="{Binding SelectedUsers}" Margin="0,0,0,4">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Background="#D6EAF8"
|
||||
BorderBrush="#2980B9"
|
||||
BorderThickness="1"
|
||||
CornerRadius="10"
|
||||
Padding="6,2"
|
||||
Margin="0,0,4,4">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding DisplayName}" FontSize="11" VerticalAlignment="Center" />
|
||||
<Button Content="✕"
|
||||
Command="{Binding DataContext.RemoveUserCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
CommandParameter="{Binding}"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
FontSize="10"
|
||||
Padding="3,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Cursor="Hand" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<!-- Selected users label -->
|
||||
<TextBlock Text="{Binding SelectedUsersLabel}"
|
||||
FontStyle="Italic" Foreground="Gray" FontSize="11" />
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
|
||||
<!-- Site Selection GroupBox -->
|
||||
<GroupBox Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[audit.grp.sites]}"
|
||||
DockPanel.Dock="Top" Margin="0,0,0,8" Padding="8">
|
||||
<StackPanel>
|
||||
<Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[btn.view.sites]}"
|
||||
Command="{Binding OpenSitePickerCommand}"
|
||||
HorizontalAlignment="Left" Padding="8,2" Margin="0,0,0,4" />
|
||||
<TextBlock Text="{Binding SitesSelectedLabel}"
|
||||
FontStyle="Italic" Foreground="Gray" FontSize="11" />
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
|
||||
<!-- Scan Options GroupBox -->
|
||||
<GroupBox Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[audit.grp.options]}"
|
||||
DockPanel.Dock="Top" Margin="0,0,0,8" Padding="8">
|
||||
<StackPanel>
|
||||
<CheckBox Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[chk.inherited.perms]}"
|
||||
IsChecked="{Binding IncludeInherited}" Margin="0,0,0,4" />
|
||||
<CheckBox Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[chk.scan.folders]}"
|
||||
IsChecked="{Binding ScanFolders}" Margin="0,0,0,4" />
|
||||
<CheckBox Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[chk.recursive]}"
|
||||
IsChecked="{Binding IncludeSubsites}" Margin="0,0,0,4" />
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
|
||||
<!-- Action buttons -->
|
||||
<StackPanel DockPanel.Dock="Top" Margin="0,0,0,4">
|
||||
<Grid Margin="0,0,0,4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Column="0"
|
||||
Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[audit.btn.run]}"
|
||||
Command="{Binding RunCommand}"
|
||||
Margin="0,0,4,0" Padding="6,3" />
|
||||
<Button Grid.Column="1"
|
||||
Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[btn.cancel]}"
|
||||
Command="{Binding CancelCommand}"
|
||||
Margin="0,0,0,0" Padding="6,3" />
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Column="0"
|
||||
Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[audit.btn.exportCsv]}"
|
||||
Command="{Binding ExportCsvCommand}"
|
||||
Margin="0,0,4,0" Padding="6,3" />
|
||||
<Button Grid.Column="1"
|
||||
Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[audit.btn.exportHtml]}"
|
||||
Command="{Binding ExportHtmlCommand}"
|
||||
Margin="0,0,0,0" Padding="6,3" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
</DockPanel>
|
||||
|
||||
<!-- Right panel: Summary banner + Results DataGrid -->
|
||||
<Grid Grid.Column="1" Grid.Row="0" Margin="0,8,8,8">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Summary banner: 3 stat cards -->
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,8">
|
||||
<!-- Total Accesses -->
|
||||
<Border Background="#EBF5FB" BorderBrush="#2980B9" BorderThickness="1"
|
||||
CornerRadius="4" Padding="12,6" Margin="0,0,8,0" MinWidth="90">
|
||||
<StackPanel HorizontalAlignment="Center">
|
||||
<TextBlock Text="{Binding TotalAccessCount}" FontSize="20" FontWeight="Bold"
|
||||
Foreground="#1A5276" HorizontalAlignment="Center" />
|
||||
<TextBlock Text="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[audit.summary.total]}"
|
||||
FontSize="11" Foreground="#2980B9" HorizontalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<!-- Sites -->
|
||||
<Border Background="#F0F3F4" BorderBrush="#717D7E" BorderThickness="1"
|
||||
CornerRadius="4" Padding="12,6" Margin="0,0,8,0" MinWidth="90">
|
||||
<StackPanel HorizontalAlignment="Center">
|
||||
<TextBlock Text="{Binding SitesCount}" FontSize="20" FontWeight="Bold"
|
||||
Foreground="#2C3E50" HorizontalAlignment="Center" />
|
||||
<TextBlock Text="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[audit.summary.sites]}"
|
||||
FontSize="11" Foreground="#717D7E" HorizontalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<!-- High Privilege -->
|
||||
<Border Background="#FDEDEC" BorderBrush="#E74C3C" BorderThickness="1"
|
||||
CornerRadius="4" Padding="12,6" Margin="0,0,0,0" MinWidth="90">
|
||||
<StackPanel HorizontalAlignment="Center">
|
||||
<TextBlock Text="{Binding HighPrivilegeCount}" FontSize="20" FontWeight="Bold"
|
||||
Foreground="#922B21" HorizontalAlignment="Center" />
|
||||
<TextBlock Text="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[audit.summary.highPriv]}"
|
||||
FontSize="11" Foreground="#E74C3C" HorizontalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Toolbar: Filter + Group-by toggle -->
|
||||
<Grid Grid.Row="1" Margin="0,0,0,6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Column="0"
|
||||
Text="{Binding FilterText, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,0,8,0" />
|
||||
<ToggleButton Grid.Column="1"
|
||||
IsChecked="{Binding IsGroupByUser}">
|
||||
<ToggleButton.Style>
|
||||
<Style TargetType="ToggleButton">
|
||||
<Setter Property="Content" Value="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[audit.toggle.bySite]}" />
|
||||
<Setter Property="Padding" Value="8,3" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="Content" Value="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[audit.toggle.byUser]}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ToggleButton.Style>
|
||||
</ToggleButton>
|
||||
</Grid>
|
||||
|
||||
<!-- Results DataGrid -->
|
||||
<DataGrid Grid.Row="2"
|
||||
ItemsSource="{Binding ResultsView}"
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="True"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
EnableRowVirtualization="True"
|
||||
CanUserResizeRows="False">
|
||||
|
||||
<!-- Row color-coding by AccessType -->
|
||||
<DataGrid.RowStyle>
|
||||
<Style TargetType="DataGridRow">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding AccessType}" Value="{x:Static models:AccessType.Direct}">
|
||||
<Setter Property="Background" Value="#EBF5FB" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding AccessType}" Value="{x:Static models:AccessType.Group}">
|
||||
<Setter Property="Background" Value="#EAFAF1" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding AccessType}" Value="{x:Static models:AccessType.Inherited}">
|
||||
<Setter Property="Background" Value="#F4F6F6" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsHighPrivilege}" Value="True">
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
|
||||
<!-- Group headers with expander -->
|
||||
<DataGrid.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.ContainerStyle>
|
||||
<Style TargetType="GroupItem">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="GroupItem">
|
||||
<Expander IsExpanded="True">
|
||||
<Expander.Header>
|
||||
<StackPanel Orientation="Horizontal" Margin="2,2">
|
||||
<TextBlock Text="{Binding Name}" FontWeight="SemiBold" Foreground="#2C3E50" />
|
||||
<TextBlock Text=" (" Foreground="Gray" />
|
||||
<TextBlock Text="{Binding ItemCount}" Foreground="Gray" />
|
||||
<TextBlock Text=")" Foreground="Gray" />
|
||||
</StackPanel>
|
||||
</Expander.Header>
|
||||
<ItemsPresenter />
|
||||
</Expander>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</GroupStyle.ContainerStyle>
|
||||
</GroupStyle>
|
||||
</DataGrid.GroupStyle>
|
||||
|
||||
<DataGrid.Columns>
|
||||
|
||||
<!-- User column with external user badge -->
|
||||
<DataGridTemplateColumn Header="User" Width="160" SortMemberPath="UserDisplayName">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding UserDisplayName}" VerticalAlignment="Center" />
|
||||
<Border Background="#F0B27A" BorderBrush="#E59866" BorderThickness="1"
|
||||
CornerRadius="8" Padding="4,0" Margin="4,0,0,0">
|
||||
<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="9" Foreground="#784212" />
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<!-- Site -->
|
||||
<DataGridTextColumn Header="Site" Binding="{Binding SiteTitle}" Width="120" />
|
||||
|
||||
<!-- Object -->
|
||||
<DataGridTextColumn Header="Object" Binding="{Binding ObjectTitle}" Width="140" />
|
||||
|
||||
<!-- Permission Level with high-privilege warning icon -->
|
||||
<DataGridTemplateColumn Header="Permission Level" Width="130" SortMemberPath="PermissionLevel">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="⚠ " Foreground="#E74C3C" 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>
|
||||
|
||||
<!-- Access Type with icon and color -->
|
||||
<DataGridTemplateColumn Header="Access Type" Width="110" SortMemberPath="AccessType">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<!-- Icon based on AccessType -->
|
||||
<TextBlock VerticalAlignment="Center" FontFamily="Segoe UI Symbol" FontSize="13" Margin="0,0,4,0">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Text" Value="→" />
|
||||
<Setter Property="Foreground" Value="#717D7E" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding AccessType}" Value="{x:Static models:AccessType.Direct}">
|
||||
<Setter Property="Text" Value="" />
|
||||
<Setter Property="Foreground" Value="#2980B9" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding AccessType}" Value="{x:Static models:AccessType.Group}">
|
||||
<Setter Property="Text" Value="" />
|
||||
<Setter Property="Foreground" Value="#27AE60" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding AccessType}" Value="{x:Static models:AccessType.Inherited}">
|
||||
<Setter Property="Text" Value="" />
|
||||
<Setter Property="Foreground" Value="#717D7E" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
<!-- Label with color -->
|
||||
<TextBlock Text="{Binding AccessType}" VerticalAlignment="Center">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="#717D7E" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding AccessType}" Value="{x:Static models:AccessType.Direct}">
|
||||
<Setter Property="Foreground" Value="#2980B9" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding AccessType}" Value="{x:Static models:AccessType.Group}">
|
||||
<Setter Property="Foreground" Value="#27AE60" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<!-- Granted Through -->
|
||||
<DataGridTextColumn Header="Granted Through" Binding="{Binding GrantedThrough}" Width="160" />
|
||||
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
|
||||
<!-- Bottom: status bar spanning both columns -->
|
||||
<StatusBar Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1">
|
||||
<StatusBarItem>
|
||||
<ProgressBar Width="150" Height="14"
|
||||
Value="{Binding ProgressValue}"
|
||||
Minimum="0" Maximum="100" />
|
||||
</StatusBarItem>
|
||||
<StatusBarItem Content="{Binding StatusMessage}" />
|
||||
</StatusBar>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
Reference in New Issue
Block a user