Skip to content

Feature: Integrate Advanced Security page into properties window #11930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
7c6a75a
First step
0x5bfa Apr 1, 2023
1646d5c
Remove ununsed codes
0x5bfa Apr 1, 2023
5ec6f2d
Merge branch 'main' into 5bfa/integrate-securityadv
yaira2 Apr 2, 2023
150127f
Cleanup MainPropertiesPage code-behind
0x5bfa Apr 2, 2023
a6c486f
Merge branch '5bfa/integrate-securityadv' of https://github.com/onein…
0x5bfa Apr 2, 2023
fd86b36
switch case to switch expression
0x5bfa Apr 2, 2023
e78b580
Small fix
0x5bfa Apr 2, 2023
3637a50
Fix issues
0x5bfa Apr 2, 2023
ca1a239
Merge branch 'main' into 5bfa/integrate-securityadv
0x5bfa Apr 2, 2023
47d266c
Fixed build issue
0x5bfa Apr 2, 2023
10eb58c
Merge branch '5bfa/integrate-securityadv' of https://github.com/onein…
0x5bfa Apr 2, 2023
ccfa715
Fixed issue
0x5bfa Apr 2, 2023
960d9f7
Added backward navigation functionality
0x5bfa Apr 2, 2023
d02be92
Fixed button style
0x5bfa Apr 2, 2023
c9f9c00
Fix corner radius
0x5bfa Apr 3, 2023
8b94438
Merge branch 'main' into 5bfa/integrate-securityadv
0x5bfa Apr 4, 2023
4027dc8
Simplify
0x5bfa Apr 9, 2023
dab4dbb
Merge branch '5bfa/integrate-securityadv' of https://github.com/0x5bf…
0x5bfa Apr 9, 2023
9c73741
Fix unrenamed properties
0x5bfa Apr 9, 2023
9b928ab
Merge branch 'main' into 5bfa/integrate-securityadv
0x5bfa Apr 9, 2023
2190a83
Fix: Requested changes
0x5bfa Apr 9, 2023
108163e
Merge branch '5bfa/integrate-securityadv' of https://github.com/0x5bf…
0x5bfa Apr 9, 2023
76bedaf
Add alternative color
0x5bfa Apr 13, 2023
e74932f
Update resources
0x5bfa Apr 13, 2023
36beecd
Update
0x5bfa Apr 16, 2023
81efcc0
Add BaseProperties property so that main props page can access file info
0x5bfa Apr 16, 2023
6284c51
Update src/Files.App/Views/Properties/SecurityPage.xaml
0x5bfa Apr 16, 2023
bf812d0
Fix: Requested Changes
0x5bfa Apr 16, 2023
b36264e
fix: requested changes 2
0x5bfa Apr 16, 2023
ee16980
Merge branch 'main' into 5bfa/integrate-securityadv
0x5bfa Apr 16, 2023
a31c40d
Add missing security functions 1
0x5bfa Apr 16, 2023
1fcd456
Merge branch '5bfa/integrate-securityadv' of https://github.com/0x5bf…
0x5bfa Apr 16, 2023
a3ee930
Merge remote-tracking branch 'upstream/main' into 5bfa/integrate-secu…
0x5bfa Apr 17, 2023
d14f8ee
Update
0x5bfa Apr 17, 2023
fb8e87b
Merge branch 'main' into 5bfa/integrate-securityadv
yaira2 Apr 17, 2023
f644674
Fix: Requested Changes
0x5bfa Apr 18, 2023
fab9d0b
Merge branch '5bfa/integrate-securityadv' of https://github.com/0x5bf…
0x5bfa Apr 18, 2023
28c2e60
Merge branch 'main' into 5bfa/integrate-securityadv
0x5bfa Apr 18, 2023
501078a
Update src/Files.App/Views/Properties/GeneralPage.xaml
0x5bfa Apr 18, 2023
1db6c25
Update src/Files.App/Views/Properties/GeneralPage.xaml
0x5bfa Apr 18, 2023
554767b
Update src/Files.App/Views/Properties/GeneralPage.xaml
0x5bfa Apr 18, 2023
827bb78
Update src/Files.App/Views/Properties/DetailsPage.xaml
0x5bfa Apr 18, 2023
6004de5
Update src/Files.App/Views/Properties/ShortcutPage.xaml
0x5bfa Apr 18, 2023
d00db04
Update src/Files.App/Views/Properties/ShortcutPage.xaml
0x5bfa Apr 18, 2023
13d2ccc
Fix: Requested changes & backward navigation issues
0x5bfa Apr 18, 2023
f6cb440
merge
0x5bfa Apr 18, 2023
ca3519f
Fix: Requested changes
0x5bfa Apr 18, 2023
f1156db
Fix: Requested changes
0x5bfa Apr 18, 2023
5894538
Fix: Requested changes
0x5bfa Apr 18, 2023
339288b
Fix: Requested changes
0x5bfa Apr 19, 2023
a41dfd2
Merge branch 'main' into 5bfa/integrate-securityadv
0x5bfa Apr 19, 2023
82fe9c4
Fix: Revert unrelated changes
0x5bfa Apr 19, 2023
f533e8e
Merge branch '5bfa/integrate-securityadv' of https://github.com/0x5bf…
0x5bfa Apr 19, 2023
6e9626c
Fix: Fix build errors
0x5bfa Apr 19, 2023
a16d569
Update FilePropertiesHelpers.cs
0x5bfa Apr 20, 2023
266ac39
merge main into here
0x5bfa Apr 20, 2023
8df3acf
Fix
0x5bfa Apr 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/Files.App/DataModels/NavigationViewItemButtonStyleItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Files.Backend.Enums;
using Microsoft.UI.Xaml;

namespace Files.App.DataModels
{
public class NavigationViewItemButtonStyleItem : ObservableObject
{
public string? Name;

public PropertiesNavigationViewItemType ItemType;

private Style _OpacityIconStyle = (Style)Application.Current.Resources["ColorIconGeneralProperties"];
public Style OpacityIconStyle
{
get => _OpacityIconStyle;
set => SetProperty(ref _OpacityIconStyle, value);
}

private bool _IsSelected;
public bool IsSelected
{
get => _IsSelected;
set => SetProperty(ref _IsSelected, value);
}

private bool _IsCompact;
public bool IsCompact
{
get => _IsCompact;
set => SetProperty(ref _IsCompact, value);
}
}
}
139 changes: 139 additions & 0 deletions src/Files.App/DataModels/PropertiesNavigationViewItemFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
using System.Collections.ObjectModel;
using Files.App.DataModels.NavigationControlItems;
using Files.App.Extensions;
using Files.App.Filesystem;
using Files.Backend.Enums;
using Files.Backend.Helpers;
using Microsoft.UI.Xaml;
using System.Collections.Generic;
using System.Linq;

namespace Files.App.DataModels
{
public static class PropertiesNavigationViewItemFactory
{
public static ObservableCollection<NavigationViewItemButtonStyleItem> Initialize(object item)
{
ObservableCollection<NavigationViewItemButtonStyleItem> PropertiesNavigationViewItems = new();

var generalItem = new NavigationViewItemButtonStyleItem()
{
Name = "General".GetLocalizedResource(),
ItemType = PropertiesNavigationViewItemType.General,
OpacityIconStyle = (Style)Application.Current.Resources["ColorIconGeneralProperties"],
};
var securityItem = new NavigationViewItemButtonStyleItem()
{
Name = "Security".GetLocalizedResource(),
ItemType = PropertiesNavigationViewItemType.Security,
OpacityIconStyle = (Style)Application.Current.Resources["ColorIconSecurityProperties"],
};
var hashesItem = new NavigationViewItemButtonStyleItem()
{
Name = "Hashes".GetLocalizedResource(),
ItemType = PropertiesNavigationViewItemType.Hashes,
OpacityIconStyle = (Style)Application.Current.Resources["ColorIconHashesProperties"],
};
var shortcutItem = new NavigationViewItemButtonStyleItem()
{
Name = "Shortcut".GetLocalizedResource(),
ItemType = PropertiesNavigationViewItemType.Shortcut,
OpacityIconStyle = (Style)Application.Current.Resources["ColorIconShortcutProperties"],
};
var libraryItem = new NavigationViewItemButtonStyleItem()
{
Name = "Library".GetLocalizedResource(),
ItemType = PropertiesNavigationViewItemType.Library,
OpacityIconStyle = (Style)Application.Current.Resources["ColorIconLibraryProperties"],
};
var detailsItem = new NavigationViewItemButtonStyleItem()
{
Name = "Details".GetLocalizedResource(),
ItemType = PropertiesNavigationViewItemType.Details,
OpacityIconStyle = (Style)Application.Current.Resources["ColorIconDetailsProperties"],
};
var customizationItem = new NavigationViewItemButtonStyleItem()
{
Name = "Customization".GetLocalizedResource(),
ItemType = PropertiesNavigationViewItemType.Customization,
OpacityIconStyle = (Style)Application.Current.Resources["ColorIconCustomizationProperties"],
};
var compatibilityItem = new NavigationViewItemButtonStyleItem()
{
Name = "Compatibility".GetLocalizedResource(),
ItemType = PropertiesNavigationViewItemType.Compatibility,
OpacityIconStyle = (Style)Application.Current.Resources["ColorIconCompatibilityProperties"],
};

PropertiesNavigationViewItems.Add(generalItem);
PropertiesNavigationViewItems.Add(securityItem);
PropertiesNavigationViewItems.Add(hashesItem);
PropertiesNavigationViewItems.Add(shortcutItem);
PropertiesNavigationViewItems.Add(libraryItem);
PropertiesNavigationViewItems.Add(detailsItem);
PropertiesNavigationViewItems.Add(customizationItem);
PropertiesNavigationViewItems.Add(compatibilityItem);

if (item is List<ListedItem> listedItems)
{
var commonFileExt = listedItems.Select(x => x.FileExtension).Distinct().Count() == 1 ? listedItems.First().FileExtension : null;
var compatibilityItemEnabled = listedItems.All(listedItem => FileExtensionHelpers.IsExecutableFile(listedItem is ShortcutItem sht ? sht.TargetPath : commonFileExt, true));

if (!compatibilityItemEnabled)
PropertiesNavigationViewItems.Remove(compatibilityItem);

PropertiesNavigationViewItems.Remove(libraryItem);
PropertiesNavigationViewItems.Remove(shortcutItem);
PropertiesNavigationViewItems.Remove(detailsItem);
PropertiesNavigationViewItems.Remove(securityItem);
PropertiesNavigationViewItems.Remove(customizationItem);
PropertiesNavigationViewItems.Remove(hashesItem);
}
else if (item is ListedItem listedItem)
{
var isShortcut = listedItem.IsShortcut;
var isLibrary = listedItem.IsLibrary;
var fileExt = listedItem.FileExtension;
var isFolder = listedItem.PrimaryItemAttribute == Windows.Storage.StorageItemTypes.Folder;

var securityItemEnabled = !isLibrary && !listedItem.IsRecycleBinItem;
var hashItemEnabled = !(isFolder && !listedItem.IsArchive) && !isLibrary && !listedItem.IsRecycleBinItem;
var detailsItemEnabled = fileExt is not null && !isShortcut && !isLibrary;
var customizationItemEnabled = !isLibrary && ((isFolder && !listedItem.IsArchive) || (isShortcut && !listedItem.IsLinkItem));
var compatibilityItemEnabled = FileExtensionHelpers.IsExecutableFile(listedItem is ShortcutItem sht ? sht.TargetPath : fileExt, true);

if (!securityItemEnabled)
PropertiesNavigationViewItems.Remove(securityItem);

if (!hashItemEnabled)
PropertiesNavigationViewItems.Remove(hashesItem);

if (!isShortcut)
PropertiesNavigationViewItems.Remove(shortcutItem);

if (!isLibrary)
PropertiesNavigationViewItems.Remove(libraryItem);

if (!detailsItemEnabled)
PropertiesNavigationViewItems.Remove(detailsItem);

if (!customizationItemEnabled)
PropertiesNavigationViewItems.Remove(customizationItem);

if (!compatibilityItemEnabled)
PropertiesNavigationViewItems.Remove(compatibilityItem);
}
else if (item is DriveItem)
{
PropertiesNavigationViewItems.Remove(hashesItem);
PropertiesNavigationViewItems.Remove(shortcutItem);
PropertiesNavigationViewItems.Remove(libraryItem);
PropertiesNavigationViewItems.Remove(detailsItem);
PropertiesNavigationViewItems.Remove(customizationItem);
PropertiesNavigationViewItems.Remove(compatibilityItem);
}

return PropertiesNavigationViewItems;
}
}
}
19 changes: 19 additions & 0 deletions src/Files.App/DataModels/PropertiesPageNavigationParameter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using System.Threading;

namespace Files.App.DataModels
{
public class PropertiesPageNavigationParameter
{
public CancellationTokenSource CancellationTokenSource;

public object Parameter;

public IShellPage AppInstance;

public Window Window;

public AppWindow AppWindow;
}
}
Loading