Skip to content

Code Qaulity: Rename storage UI items #15588

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task ExecuteAsync(object? parameter = null)
if (context.ShellPage is null)
return;

string path = context.SelectedItem is ListedItem selectedItem
string path = context.SelectedItem is StandardStorageItem selectedItem
? selectedItem.ItemPath
: context.ShellPage.FilesystemViewModel.WorkingDirectory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public BaseOpenInNewTabAction()

public virtual async Task ExecuteAsync(object? parameter = null)
{
foreach (ListedItem listedItem in ContentPageContext.SelectedItems)
foreach (StandardStorageItem listedItem in ContentPageContext.SelectedItems)
{
await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public virtual async Task ExecuteAsync(object? parameter = null)
if (ContentPageContext.ShellPage?.SlimContentPage?.SelectedItems is null)
return;

List<ListedItem> items = ContentPageContext.ShellPage.SlimContentPage.SelectedItems;
List<StandardStorageItem> items = ContentPageContext.ShellPage.SlimContentPage.SelectedItems;

foreach (ListedItem listedItem in items)
foreach (StandardStorageItem listedItem in items)
{
var selectedItemPath = (listedItem as ShortcutItem)?.TargetPath ?? listedItem.ItemPath;
var folderUri = new Uri($"files-uwp:?folder={@selectedItemPath}");
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/Sidebar/PinFolderToSidebarAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private bool GetIsExecutable()
? context.SelectedItems.All(IsPinnable)
: context.Folder is not null && IsPinnable(context.Folder);

bool IsPinnable(ListedItem item)
bool IsPinnable(StandardStorageItem item)
{
return
item.PrimaryItemAttribute is StorageItemTypes.Folder &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private bool GetIsExecutable()
? context.SelectedItems.All(IsPinned)
: context.Folder is not null && IsPinned(context.Folder);

bool IsPinned(ListedItem item)
bool IsPinned(StandardStorageItem item)
{
return pinnedFolders.Contains(item.ItemPath);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/Start/PinToStartAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task ExecuteAsync(object? parameter = null)
{
if (context.SelectedItems.Count > 0 && context.ShellPage?.SlimContentPage?.SelectedItems is not null)
{
foreach (ListedItem listedItem in context.ShellPage.SlimContentPage.SelectedItems)
foreach (StandardStorageItem listedItem in context.ShellPage.SlimContentPage.SelectedItems)
{
IStorable storable = listedItem.IsFolder switch
{
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Actions/Start/UnpinFromStartAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task ExecuteAsync(object? parameter = null)
{
if (context.SelectedItems.Count > 0)
{
foreach (ListedItem listedItem in context.ShellPage?.SlimContentPage.SelectedItems)
foreach (StandardStorageItem listedItem in context.ShellPage?.SlimContentPage.SelectedItems)
{
IStorable storable = listedItem.IsFolder switch
{
Expand Down
14 changes: 7 additions & 7 deletions src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Files.App.Data.Contexts
{
internal sealed class ContentPageContext : ObservableObject, IContentPageContext
{
private static readonly IReadOnlyList<ListedItem> emptyItems = Enumerable.Empty<ListedItem>().ToImmutableList();
private static readonly IReadOnlyList<StandardStorageItem> emptyItems = Enumerable.Empty<StandardStorageItem>().ToImmutableList();

private readonly IMultiPanesContext context = Ioc.Default.GetRequiredService<IMultiPanesContext>();

Expand All @@ -21,15 +21,15 @@ internal sealed class ContentPageContext : ObservableObject, IContentPageContext
private ContentPageTypes pageType = ContentPageTypes.None;
public ContentPageTypes PageType => pageType;

public ListedItem? Folder => ShellPage?.FilesystemViewModel?.CurrentFolder;
public StandardStorageItem? Folder => ShellPage?.FilesystemViewModel?.CurrentFolder;

public bool HasItem => ShellPage?.ToolbarViewModel?.HasItem ?? false;

public bool HasSelection => SelectedItems.Count is not 0;
public ListedItem? SelectedItem => SelectedItems.Count is 1 ? SelectedItems[0] : null;
public StandardStorageItem? SelectedItem => SelectedItems.Count is 1 ? SelectedItems[0] : null;

private IReadOnlyList<ListedItem> selectedItems = emptyItems;
public IReadOnlyList<ListedItem> SelectedItems => selectedItems;
private IReadOnlyList<StandardStorageItem> selectedItems = emptyItems;
public IReadOnlyList<StandardStorageItem> SelectedItems => selectedItems;

public bool CanRefresh => ShellPage is not null && ShellPage.ToolbarViewModel.CanRefresh;

Expand Down Expand Up @@ -226,9 +226,9 @@ private void UpdatePageType()
private void UpdateSelectedItems()
{
bool oldHasSelection = HasSelection;
ListedItem? oldSelectedItem = SelectedItem;
StandardStorageItem? oldSelectedItem = SelectedItem;

IReadOnlyList<ListedItem> items = ShellPage?.ToolbarViewModel?.SelectedItems?.AsReadOnly() ?? emptyItems;
IReadOnlyList<StandardStorageItem> items = ShellPage?.ToolbarViewModel?.SelectedItems?.AsReadOnly() ?? emptyItems;
if (SetProperty(ref selectedItems, items, nameof(SelectedItems)))
{
if (HasSelection != oldHasSelection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ public interface IContentPageContext : INotifyPropertyChanged

Type PageLayoutType { get; }

ListedItem? Folder { get; }
StandardStorageItem? Folder { get; }

bool HasItem { get; }
bool HasSelection { get; }
bool CanRefresh { get; }
ListedItem? SelectedItem { get; }
IReadOnlyList<ListedItem> SelectedItems { get; }
StandardStorageItem? SelectedItem { get; }
IReadOnlyList<StandardStorageItem> SelectedItems { get; }

bool CanGoBack { get; }
bool CanGoForward { get; }
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Data/Contexts/SideBar/ISideBarContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface ISidebarContext
/// <summary>
/// Gets the last sidebar right clicked item
/// </summary>
INavigationControlItem? RightClickedItem { get; }
ISidebarItem? RightClickedItem { get; }

/// <summary>
/// Gets the value that indicates whether any item has been right clicked
Expand Down
8 changes: 4 additions & 4 deletions src/Files.App/Data/Contexts/SideBar/SideBarContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ internal sealed class SidebarContext : ObservableObject, ISidebarContext
? favoriteModel.IndexOfItem(_RightClickedItem!)
: -1;

private INavigationControlItem? _RightClickedItem = null;
public INavigationControlItem? RightClickedItem => _RightClickedItem;
private ISidebarItem? _RightClickedItem = null;
public ISidebarItem? RightClickedItem => _RightClickedItem;

public bool IsItemRightClicked =>
_RightClickedItem is not null;

public bool IsPinnedFolderItem =>
IsItemRightClicked &&
_RightClickedItem!.Section is SectionType.Pinned &&
_RightClickedItem!.Section is SidebarSectionKind.Pinned &&
PinnedFolderItemIndex is not -1;

public DriveItem? OpenDriveItem
Expand All @@ -32,7 +32,7 @@ public SidebarContext()
SidebarViewModel.RightClickedItemChanged += SidebarControl_RightClickedItemChanged;
}

public void SidebarControl_RightClickedItemChanged(object? sender, INavigationControlItem? e)
public void SidebarControl_RightClickedItemChanged(object? sender, ISidebarItem? e)
{
if (SetProperty(ref _RightClickedItem, e, nameof(RightClickedItem)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@

namespace Files.App.Data.Contracts
{
public interface INavigationControlItem : IComparable<INavigationControlItem>, INotifyPropertyChanged, ISidebarItemModel
public interface ISidebarItem : IComparable<ISidebarItem>, INotifyPropertyChanged, ISidebarItemModel
{
public new string Text { get; }

public string Path { get; }

public SectionType Section { get; }
public SidebarSectionKind Section { get; }

public NavigationControlItemType ItemType { get; }
public SidebarItemKind ItemType { get; }

public ContextMenuOptions MenuOptions { get; }
}

public enum NavigationControlItemType
public enum SidebarItemKind
{
Drive,
LinuxDistro,
Location,
FileTag
}

public enum SectionType
public enum SidebarSectionKind
{
Home,
Pinned,
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Data/Contracts/IStorageArchiveService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public interface IStorageArchiveService
/// </summary>
/// <param name="items">Items to check if they can be compressed.</param>
/// <returns>True if can be compressed; otherwise, false.</returns>
bool CanCompress(IReadOnlyList<ListedItem> items);
bool CanCompress(IReadOnlyList<StandardStorageItem> items);

/// <summary>
/// Gets the value that indicates whether specified items can be decompressed.
/// </summary>
/// <param name="items">Items to check if they can be decompressed.</param>
/// <returns>True if can be decompressed; otherwise, false.</returns>
bool CanDecompress(IReadOnlyList<ListedItem> items);
bool CanDecompress(IReadOnlyList<StandardStorageItem> items);

/// <summary>
/// Compresses the specified items.
Expand All @@ -45,7 +45,7 @@ public interface IStorageArchiveService
/// </summary>
/// <param name="items">Item names to generate archive file name.</param>
/// <returns></returns>
string GenerateArchiveNameFromItems(IReadOnlyList<ListedItem> items);
string GenerateArchiveNameFromItems(IReadOnlyList<StandardStorageItem> items);

/// <summary>
/// Gets the value that indicates whether the archive file is encrypted.
Expand Down
10 changes: 5 additions & 5 deletions src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ public static class ContentPageContextFlyoutFactory
private static readonly ICommandManager Commands = Ioc.Default.GetRequiredService<ICommandManager>();
private static IStorageArchiveService StorageArchiveService { get; } = Ioc.Default.GetRequiredService<IStorageArchiveService>();

public static List<ContextMenuFlyoutItemViewModel> GetItemContextCommandsWithoutShellItems(CurrentInstanceViewModel currentInstanceViewModel, List<ListedItem> selectedItems, BaseLayoutViewModel commandsViewModel, bool shiftPressed, SelectedItemsPropertiesViewModel? selectedItemsPropertiesViewModel, ItemViewModel? itemViewModel = null)
public static List<ContextMenuFlyoutItemViewModel> GetItemContextCommandsWithoutShellItems(CurrentInstanceViewModel currentInstanceViewModel, List<StandardStorageItem> selectedItems, BaseLayoutViewModel commandsViewModel, bool shiftPressed, SelectedItemsPropertiesViewModel? selectedItemsPropertiesViewModel, ItemViewModel? itemViewModel = null)
{
var menuItemsList = GetBaseItemMenuItems(commandsViewModel: commandsViewModel, selectedItems: selectedItems, selectedItemsPropertiesViewModel: selectedItemsPropertiesViewModel, currentInstanceViewModel: currentInstanceViewModel, itemViewModel: itemViewModel);
menuItemsList = Filter(items: menuItemsList, shiftPressed: shiftPressed, currentInstanceViewModel: currentInstanceViewModel, selectedItems: selectedItems, removeOverflowMenu: false);
return menuItemsList;
}

public static Task<List<ContextMenuFlyoutItemViewModel>> GetItemContextShellCommandsAsync(string workingDir, List<ListedItem> selectedItems, bool shiftPressed, bool showOpenMenu, CancellationToken cancellationToken)
public static Task<List<ContextMenuFlyoutItemViewModel>> GetItemContextShellCommandsAsync(string workingDir, List<StandardStorageItem> selectedItems, bool shiftPressed, bool showOpenMenu, CancellationToken cancellationToken)
{
return ShellContextFlyoutFactory.GetShellContextmenuAsync(shiftPressed: shiftPressed, showOpenMenu: showOpenMenu, workingDirectory: workingDir, selectedItems: selectedItems, cancellationToken: cancellationToken);
}

public static List<ContextMenuFlyoutItemViewModel> Filter(List<ContextMenuFlyoutItemViewModel> items, List<ListedItem> selectedItems, bool shiftPressed, CurrentInstanceViewModel currentInstanceViewModel, bool removeOverflowMenu = true)
public static List<ContextMenuFlyoutItemViewModel> Filter(List<ContextMenuFlyoutItemViewModel> items, List<StandardStorageItem> selectedItems, bool shiftPressed, CurrentInstanceViewModel currentInstanceViewModel, bool removeOverflowMenu = true)
{
items = items.Where(x => Check(item: x, currentInstanceViewModel: currentInstanceViewModel, selectedItems: selectedItems)).ToList();
items.ForEach(x => x.Items = x.Items?.Where(y => Check(item: y, currentInstanceViewModel: currentInstanceViewModel, selectedItems: selectedItems)).ToList());
Expand Down Expand Up @@ -64,7 +64,7 @@ public static List<ContextMenuFlyoutItemViewModel> Filter(List<ContextMenuFlyout
return items;
}

private static bool Check(ContextMenuFlyoutItemViewModel item, CurrentInstanceViewModel currentInstanceViewModel, List<ListedItem> selectedItems)
private static bool Check(ContextMenuFlyoutItemViewModel item, CurrentInstanceViewModel currentInstanceViewModel, List<StandardStorageItem> selectedItems)
{
return
(item.ShowInRecycleBin || !currentInstanceViewModel.IsPageTypeRecycleBin) &&
Expand All @@ -78,7 +78,7 @@ private static bool Check(ContextMenuFlyoutItemViewModel item, CurrentInstanceVi
public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
BaseLayoutViewModel commandsViewModel,
SelectedItemsPropertiesViewModel? selectedItemsPropertiesViewModel,
List<ListedItem> selectedItems,
List<StandardStorageItem> selectedItems,
CurrentInstanceViewModel currentInstanceViewModel,
ItemViewModel? itemViewModel = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static ObservableCollection<NavigationViewItemButtonStyleItem> Initialize
PropertiesNavigationViewItems.Add(customizationItem);
PropertiesNavigationViewItems.Add(compatibilityItem);

if (item is List<ListedItem> listedItems)
if (item is List<StandardStorageItem> listedItems)
{
var firstFileExtension = listedItems.FirstOrDefault()?.FileExtension;
var commonFileExt = listedItems.All(x => x.FileExtension == firstFileExtension) ? firstFileExtension : null;
Expand All @@ -91,7 +91,7 @@ public static ObservableCollection<NavigationViewItemButtonStyleItem> Initialize
PropertiesNavigationViewItems.Remove(customizationItem);
PropertiesNavigationViewItems.Remove(hashesItem);
}
else if (item is ListedItem listedItem)
else if (item is StandardStorageItem listedItem)
{
var isShortcut = listedItem.IsShortcut;
var isLibrary = listedItem.IsLibrary;
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class ShellContextFlyoutFactory
{
public static IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();

public static async Task<List<ContextMenuFlyoutItemViewModel>> GetShellContextmenuAsync(bool showOpenMenu, bool shiftPressed, string workingDirectory, List<ListedItem>? selectedItems, CancellationToken cancellationToken)
public static async Task<List<ContextMenuFlyoutItemViewModel>> GetShellContextmenuAsync(bool showOpenMenu, bool shiftPressed, string workingDirectory, List<StandardStorageItem>? selectedItems, CancellationToken cancellationToken)
{
bool IsItemSelected = selectedItems?.Count > 0;

Expand Down Expand Up @@ -240,7 +240,7 @@ public static async Task LoadShellMenuItemsAsync(
var shiftPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down);
var shellMenuItems = await ContentPageContextFlyoutFactory.GetItemContextShellCommandsAsync(
workingDir: null,
[new ListedItem(null) { ItemPath = path }],
[new StandardStorageItem() { ItemPath = path }],
shiftPressed: shiftPressed,
showOpenMenu: false,
default);
Expand Down
10 changes: 5 additions & 5 deletions src/Files.App/Data/Items/FileTagItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Files.App.Data.Items
{
public sealed class FileTagItem : ObservableObject, INavigationControlItem
public sealed class FileTagItem : ObservableObject, ISidebarItem
{
public string Text { get; set; }

Expand All @@ -27,14 +27,14 @@ public string Path

public string ToolTipText { get; private set; }

public SectionType Section { get; set; }
public SidebarSectionKind Section { get; set; }

public ContextMenuOptions MenuOptions { get; set; }

public NavigationControlItemType ItemType
=> NavigationControlItemType.FileTag;
public SidebarItemKind ItemType
=> SidebarItemKind.FileTag;

public int CompareTo(INavigationControlItem other)
public int CompareTo(ISidebarItem other)
=> Text.CompareTo(other.Text);

public TagViewModel FileTag { get; set; }
Expand Down
16 changes: 8 additions & 8 deletions src/Files.App/Data/Items/LocationItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Files.App.Data.Items
{
public class LocationItem : ObservableObject, INavigationControlItem
public class LocationItem : ObservableObject, ISidebarItem
{
public BitmapImage icon;
public BitmapImage Icon
Expand Down Expand Up @@ -53,13 +53,13 @@ public string Path
}
}

public NavigationControlItemType ItemType
=> NavigationControlItemType.Location;
public SidebarItemKind ItemType
=> SidebarItemKind.Location;

public bool IsDefaultLocation { get; set; }

public object? Children => Section == SectionType.Home ? null : ChildItems;
public BulkConcurrentObservableCollection<INavigationControlItem>? ChildItems { get; set; }
public object? Children => Section == SidebarSectionKind.Home ? null : ChildItems;
public BulkConcurrentObservableCollection<ISidebarItem>? ChildItems { get; set; }
public IconSource? IconSource
{
get => new ImageIconSource()
Expand All @@ -81,7 +81,7 @@ public bool IsExpanded

public bool IsPinned => App.QuickAccessManager.Model.PinnedFolders.Contains(path);

public SectionType Section { get; set; }
public SidebarSectionKind Section { get; set; }

public ContextMenuOptions MenuOptions { get; set; }

Expand All @@ -101,7 +101,7 @@ public FrameworkElement? ItemDecorator
{
get
{
if (Section == SectionType.Pinned)
if (Section == SidebarSectionKind.Pinned)
{
return new OpacityIcon()
{
Expand All @@ -112,7 +112,7 @@ public FrameworkElement? ItemDecorator
}
}

public int CompareTo(INavigationControlItem other)
public int CompareTo(ISidebarItem other)
=> Text.CompareTo(other.Text);

public static T Create<T>() where T : LocationItem, new()
Expand Down
Loading
Loading