From e1d2a57a44387b231cc89d686b480baa1dbe2b7a Mon Sep 17 00:00:00 2001 From: U+5BFA Date: Mon, 27 Mar 2023 13:21:01 +0900 Subject: [PATCH 1/4] Fix: Fix UI in Security pages --- .../Filesystem/Security/AccessControlEntry.cs | 2 +- .../Filesystem/Security/Principal.cs | 12 +- src/Files.App/Strings/en-US/Resources.resw | 6 +- .../Properties/SecurityViewModel.cs | 15 +- .../Properties/SecurityAdvancedPage.xaml | 383 ++++++++++++------ .../Properties/SecurityAdvancedPage.xaml.cs | 2 +- .../Views/Properties/SecurityPage.xaml | 256 ++++++------ 7 files changed, 415 insertions(+), 261 deletions(-) diff --git a/src/Files.App/Filesystem/Security/AccessControlEntry.cs b/src/Files.App/Filesystem/Security/AccessControlEntry.cs index 79464f0a01e4..dba43114febc 100644 --- a/src/Files.App/Filesystem/Security/AccessControlEntry.cs +++ b/src/Files.App/Filesystem/Security/AccessControlEntry.cs @@ -33,7 +33,7 @@ public AccessControlType AccessControlType public string AccessControlTypeGlyph => AccessControlType switch { - AccessControlType.Allow => "\xF13E", + AccessControlType.Allow => "\xE73E", _ => "\xF140" // AccessControlType.Deny }; diff --git a/src/Files.App/Filesystem/Security/Principal.cs b/src/Files.App/Filesystem/Security/Principal.cs index ac7493b1d63d..5d82a5a429bd 100644 --- a/src/Files.App/Filesystem/Security/Principal.cs +++ b/src/Files.App/Filesystem/Security/Principal.cs @@ -1,5 +1,4 @@ using CommunityToolkit.Mvvm.ComponentModel; -using Files.App.Extensions; using System.Collections.Generic; using System.Text; using static Vanara.PInvoke.AdvApi32; @@ -25,11 +24,14 @@ public string Glyph public string? Name { get; set; } - public string DisplayName - => string.IsNullOrEmpty(Name) ? "SecurityUnknownAccount".GetLocalizedResource() : Name; + public string? DisplayName + => string.IsNullOrEmpty(Name) ? Sid : Name; - public string FullNameOrSid - => string.IsNullOrEmpty(Name) ? Sid : string.IsNullOrEmpty(Domain) ? Name : $"{Domain}\\{Name}"; + public string? FullNameOrSid + => string.IsNullOrEmpty(Domain) ? Sid : $"{Domain}\\{Name}"; + + public string? FullNameHumanized + => string.IsNullOrEmpty(Domain) ? string.Empty : $"({Domain}\\{Name})"; public List Groups { get; set; } diff --git a/src/Files.App/Strings/en-US/Resources.resw b/src/Files.App/Strings/en-US/Resources.resw index a118e435915f..d7b83d352efc 100644 --- a/src/Files.App/Strings/en-US/Resources.resw +++ b/src/Files.App/Strings/en-US/Resources.resw @@ -1642,7 +1642,7 @@ You do not have permissions to view the security properties of this object. Click "Advanced permissions" to proceed. - Owner + Owner: Unknown owner @@ -1683,8 +1683,8 @@ Applies to - - Entity + + Principal files diff --git a/src/Files.App/ViewModels/Properties/SecurityViewModel.cs b/src/Files.App/ViewModels/Properties/SecurityViewModel.cs index 5e63c402cbbb..73ff18e77008 100644 --- a/src/Files.App/ViewModels/Properties/SecurityViewModel.cs +++ b/src/Files.App/ViewModels/Properties/SecurityViewModel.cs @@ -5,8 +5,7 @@ using Files.App.Filesystem; using Files.App.Filesystem.Security; using Files.App.Helpers; -using System.Collections.Generic; -using System.Linq; +using Microsoft.UI.Xaml; using System.Threading.Tasks; using Windows.Storage; @@ -91,6 +90,18 @@ public string DisableInheritanceOption private bool _preserveInheritance; + private GridLength _columnType = new(64d); + public GridLength ColumnType { get => _columnType; set => SetProperty(ref _columnType, value); } + + private GridLength _columnPrincipal = new(200d); + public GridLength ColumnPrincipal { get => _columnPrincipal; set => SetProperty(ref _columnPrincipal, value); } + + private GridLength _columnAccess = new(160d); + public GridLength ColumnAccess { get => _columnAccess; set => SetProperty(ref _columnAccess, value); } + + private GridLength _columnInherited = new(70d); + public GridLength ColumnInherited { get => _columnInherited; set => SetProperty(ref _columnInherited, value); } + public RelayCommand ChangeOwnerCommand { get; set; } public RelayCommand AddAccessControlEntryCommand { get; set; } public RelayCommand RemoveAccessControlEntryCommand { get; set; } diff --git a/src/Files.App/Views/Properties/SecurityAdvancedPage.xaml b/src/Files.App/Views/Properties/SecurityAdvancedPage.xaml index ce75e58400cd..2e95f8413bb4 100644 --- a/src/Files.App/Views/Properties/SecurityAdvancedPage.xaml +++ b/src/Files.App/Views/Properties/SecurityAdvancedPage.xaml @@ -8,26 +8,51 @@ xmlns:i="using:Microsoft.Xaml.Interactivity" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:security="using:Files.App.Filesystem.Security" + xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls" xmlns:toolkitconverters="using:CommunityToolkit.WinUI.UI.Converters" Background="{ThemeResource App.Theme.BackgroundBrush}" + DataContext="{x:Bind ViewModel, Mode=OneWay}" KeyDown="SecurityAdvancedPage_KeyDown" Loaded="SecurityAdvancedPage_Loaded" mc:Ignorable="d"> - + + + + + + + + + + - - - + - + + + + + + + + + Spacing="8"> + + x:Load="{x:Bind ViewModel.AccessControlList.CanReadAccessControl, Mode=OneWay}" + IsTextSelectionEnabled="True" + Style="{StaticResource BodyTextBlockStyle}" + ToolTipService.ToolTip="{x:Bind ViewModel.AccessControlList.Owner.FullNameOrSid, Mode=OneWay}"> -  ( - - ) + + + - - - - @@ -129,45 +169,52 @@ - + + + + + - - - - + + + + + + + + - + + + Background="{ThemeResource DividerStrokeColorDefaultBrush}" /> + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - + + + + + @@ -261,22 +364,27 @@ + x:Load="{x:Bind IsEditEnabled, Mode=OneWay}" + Style="{StaticResource TransparentDropDownButtonStyle}"> + + + - + + + + - -  ( - - ) + + + + @@ -324,20 +433,24 @@ + + + + @@ -348,6 +461,7 @@ + + + + + + + + + + + BorderThickness="0,1,0,0" + ColumnSpacing="12"> - + + - - - + + + + + + + + + + + + + + + + + + + Height="1" + Background="{ThemeResource DividerStrokeColorDefault}" /> + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + Grid.Column="1" + Style="{StaticResource BodyTextBlockStyle}" + ToolTipService.ToolTip="{x:Bind Principal.FullNameOrSid}"> + + + + + + + + + + + - + + RowSpacing="8"> - - - - - - - - + + + + + + + + + + + + + + + + Background="{ThemeResource DividerStrokeColorDefault}" /> + From a0eefbc129f6b0ff8807cc100a84aa4ed764be49 Mon Sep 17 00:00:00 2001 From: U+5BFA Date: Tue, 28 Mar 2023 03:46:44 +0900 Subject: [PATCH 2/4] Final brushing --- .../Filesystem/Security/AccessControlEntry.cs | 7 + src/Files.App/Strings/en-US/Resources.resw | 13 +- .../Properties/SecurityViewModel.cs | 30 +- .../Properties/SecurityAdvancedPage.xaml | 1034 +++++++++-------- .../Views/Properties/SecurityPage.xaml | 2 +- 5 files changed, 594 insertions(+), 492 deletions(-) diff --git a/src/Files.App/Filesystem/Security/AccessControlEntry.cs b/src/Files.App/Filesystem/Security/AccessControlEntry.cs index dba43114febc..a7de86ffc988 100644 --- a/src/Files.App/Filesystem/Security/AccessControlEntry.cs +++ b/src/Files.App/Filesystem/Security/AccessControlEntry.cs @@ -30,6 +30,13 @@ public AccessControlType AccessControlType } } + public string AccessControlTypeHumanized + => AccessControlType switch + { + AccessControlType.Allow => "Allow", + _ => "Deny" // AccessControlType.Deny + }; + public string AccessControlTypeGlyph => AccessControlType switch { diff --git a/src/Files.App/Strings/en-US/Resources.resw b/src/Files.App/Strings/en-US/Resources.resw index d7b83d352efc..e17bc6e86db0 100644 --- a/src/Files.App/Strings/en-US/Resources.resw +++ b/src/Files.App/Strings/en-US/Resources.resw @@ -1608,7 +1608,7 @@ Allow - + Deny @@ -1680,10 +1680,10 @@ Access - + Applies to - + Principal @@ -1695,10 +1695,10 @@ subfolders - + Inherited - + Permissions @@ -2670,4 +2670,7 @@ Exit compact overlay + + Change + \ No newline at end of file diff --git a/src/Files.App/ViewModels/Properties/SecurityViewModel.cs b/src/Files.App/ViewModels/Properties/SecurityViewModel.cs index 73ff18e77008..ec3a5946e640 100644 --- a/src/Files.App/ViewModels/Properties/SecurityViewModel.cs +++ b/src/Files.App/ViewModels/Properties/SecurityViewModel.cs @@ -61,8 +61,14 @@ public AccessControlEntry SelectedAccessControlEntry get => _selectedAccessControlEntry; set { + if (_selectedAccessControlEntry is not null) + _selectedAccessControlEntry.IsSelected = false; + if (SetProperty(ref _selectedAccessControlEntry, value)) + { + value.IsSelected = true; RemoveAccessControlEntryCommand.NotifyCanExecuteChanged(); + } } } @@ -91,16 +97,32 @@ public string DisableInheritanceOption private bool _preserveInheritance; private GridLength _columnType = new(64d); - public GridLength ColumnType { get => _columnType; set => SetProperty(ref _columnType, value); } + public GridLength ColumnType + { + get => _columnType; + set => SetProperty(ref _columnType, value); + } private GridLength _columnPrincipal = new(200d); - public GridLength ColumnPrincipal { get => _columnPrincipal; set => SetProperty(ref _columnPrincipal, value); } + public GridLength ColumnPrincipal + { + get => _columnPrincipal; + set => SetProperty(ref _columnPrincipal, value); + } private GridLength _columnAccess = new(160d); - public GridLength ColumnAccess { get => _columnAccess; set => SetProperty(ref _columnAccess, value); } + public GridLength ColumnAccess + { + get => _columnAccess; + set => SetProperty(ref _columnAccess, value); + } private GridLength _columnInherited = new(70d); - public GridLength ColumnInherited { get => _columnInherited; set => SetProperty(ref _columnInherited, value); } + public GridLength ColumnInherited + { + get => _columnInherited; + set => SetProperty(ref _columnInherited, value); + } public RelayCommand ChangeOwnerCommand { get; set; } public RelayCommand AddAccessControlEntryCommand { get; set; } diff --git a/src/Files.App/Views/Properties/SecurityAdvancedPage.xaml b/src/Files.App/Views/Properties/SecurityAdvancedPage.xaml index 2e95f8413bb4..3cb164e29655 100644 --- a/src/Files.App/Views/Properties/SecurityAdvancedPage.xaml +++ b/src/Files.App/Views/Properties/SecurityAdvancedPage.xaml @@ -24,26 +24,18 @@ + - - @@ -61,7 +53,7 @@ - + @@ -73,33 +65,102 @@ x:Name="TitlebarArea" Height="36" Background="Transparent"> - - + - - - + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -108,501 +169,510 @@ Grid.Column="0" Margin="4" VerticalAlignment="Center" - Text="{helpers:ResourceString Name=SecurityOwnerLabel/Text}" /> + Text="{helpers:ResourceString Name=Permissions}" /> - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + TextWrapping="NoWrap"> + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + TextWrapping="NoWrap" + Visibility="{x:Bind IsFolder, Mode=OneWay}" /> - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - + + + + Text="{helpers:ResourceString Name=Deny}" /> Date: Tue, 28 Mar 2023 12:08:33 +0900 Subject: [PATCH 3/4] Update SecurityViewModel.cs --- src/Files.App/ViewModels/Properties/SecurityViewModel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Files.App/ViewModels/Properties/SecurityViewModel.cs b/src/Files.App/ViewModels/Properties/SecurityViewModel.cs index 3dfffe31526a..ec3a5946e640 100644 --- a/src/Files.App/ViewModels/Properties/SecurityViewModel.cs +++ b/src/Files.App/ViewModels/Properties/SecurityViewModel.cs @@ -5,6 +5,7 @@ using Files.App.Filesystem; using Files.App.Filesystem.Security; using Files.App.Helpers; +using Microsoft.UI.Xaml; using System.Threading.Tasks; using Windows.Storage; From 7fbf66dd6f8be820cbc7d632145540b23499697b Mon Sep 17 00:00:00 2001 From: U+5BFA <62196528+onein528@users.noreply.github.com> Date: Tue, 28 Mar 2023 12:51:55 +0900 Subject: [PATCH 4/4] Update Resources.resw --- src/Files.App/Strings/en-US/Resources.resw | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Files.App/Strings/en-US/Resources.resw b/src/Files.App/Strings/en-US/Resources.resw index 2f5a2939e5cb..72381812d665 100644 --- a/src/Files.App/Strings/en-US/Resources.resw +++ b/src/Files.App/Strings/en-US/Resources.resw @@ -2666,7 +2666,8 @@ Change + Toggle Selection - \ No newline at end of file +