Skip to content

Commit 2c57b15

Browse files
committed
Sidebar
1 parent a761b2a commit 2c57b15

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) 2024 Files Community
2+
// Licensed under the MIT License. See the LICENSE.
3+
4+
namespace Files.App.Actions
5+
{
6+
internal sealed class OpenStorageSenseFromSidebarAction : OpenStorageSenseAction
7+
{
8+
private ISidebarContext SidebarContext { get; } = Ioc.Default.GetRequiredService<ISidebarContext>();
9+
private readonly DrivesViewModel drivesViewModel = Ioc.Default.GetRequiredService<DrivesViewModel>();
10+
11+
public override bool IsExecutable =>
12+
SidebarContext.IsItemRightClicked &&
13+
SidebarContext.RightClickedItem is not null &&
14+
SidebarContext.RightClickedItem.Path is not null &&
15+
drivesViewModel.Drives
16+
.Cast<DriveItem>()
17+
.FirstOrDefault(x => string.Equals(x.Path, SidebarContext.RightClickedItem.Path)) is DriveItem driveItem &&
18+
driveItem.Type != DriveType.Network;
19+
20+
public override bool IsAccessibleGlobally
21+
=> false;
22+
23+
public override Task ExecuteAsync(object? parameter = null)
24+
{
25+
return StorageSenseHelper.OpenStorageSenseAsync(SidebarContext?.RightClickedItem?.Path ?? string.Empty);
26+
}
27+
}
28+
}

src/Files.App/Data/Commands/Manager/CommandCodes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public enum CommandCodes
116116
OpenSettings,
117117
OpenStorageSense,
118118
OpenStorageSenseFromHome,
119+
OpenStorageSenseFromSidebar,
119120
OpenTerminal,
120121
OpenTerminalAsAdmin,
121122
OpenTerminalFromSidebar,

src/Files.App/Data/Commands/Manager/CommandManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public IRichCommand this[HotKey hotKey]
118118
public IRichCommand OpenClassicProperties => commands[CommandCodes.OpenClassicProperties];
119119
public IRichCommand OpenStorageSense => commands[CommandCodes.OpenStorageSense];
120120
public IRichCommand OpenStorageSenseFromHome => commands[CommandCodes.OpenStorageSenseFromHome];
121+
public IRichCommand OpenStorageSenseFromSidebar => commands[CommandCodes.OpenStorageSenseFromSidebar];
121122
public IRichCommand OpenSettings => commands[CommandCodes.OpenSettings];
122123
public IRichCommand OpenTerminal => commands[CommandCodes.OpenTerminal];
123124
public IRichCommand OpenTerminalAsAdmin => commands[CommandCodes.OpenTerminalAsAdmin];
@@ -317,6 +318,7 @@ public IEnumerator<IRichCommand> GetEnumerator() =>
317318
[CommandCodes.OpenClassicProperties] = new OpenClassicPropertiesAction(),
318319
[CommandCodes.OpenStorageSense] = new OpenStorageSenseAction(),
319320
[CommandCodes.OpenStorageSenseFromHome] = new OpenStorageSenseFromHomeAction(),
321+
[CommandCodes.OpenStorageSenseFromSidebar] = new OpenStorageSenseFromSidebarAction(),
320322
[CommandCodes.OpenSettings] = new OpenSettingsAction(),
321323
[CommandCodes.OpenTerminal] = new OpenTerminalAction(),
322324
[CommandCodes.OpenTerminalAsAdmin] = new OpenTerminalAsAdminAction(),

src/Files.App/Data/Commands/Manager/ICommandManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public interface ICommandManager : IEnumerable<IRichCommand>
104104
IRichCommand OpenClassicProperties { get; }
105105
IRichCommand OpenStorageSense { get; }
106106
IRichCommand OpenStorageSenseFromHome { get; }
107+
IRichCommand OpenStorageSenseFromSidebar { get; }
107108
IRichCommand OpenSettings { get; }
108109
IRichCommand OpenTerminal { get; }
109110
IRichCommand OpenTerminalAsAdmin { get; }

src/Files.App/ViewModels/UserControls/SidebarViewModel.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using Files.App.Helpers.ContextFlyouts;
55
using Files.App.UserControls.Sidebar;
6-
using Files.App.ViewModels.Dialogs;
76
using Microsoft.UI.Input;
87
using Microsoft.UI.Xaml;
98
using Microsoft.UI.Xaml.Controls;
@@ -12,13 +11,11 @@
1211
using System.Collections.Specialized;
1312
using System.IO;
1413
using System.Windows.Input;
15-
using Windows.ApplicationModel.DataTransfer.DragDrop;
1614
using Windows.ApplicationModel.DataTransfer;
15+
using Windows.ApplicationModel.DataTransfer.DragDrop;
1716
using Windows.Storage;
1817
using Windows.System;
1918
using Windows.UI.Core;
20-
using Files.Core.Storage;
21-
using Files.Core.Storage.Extensions;
2219

2320
namespace Files.App.ViewModels.UserControls
2421
{
@@ -1063,6 +1060,7 @@ private List<ContextMenuFlyoutItemViewModel> GetLocationItemMenuItems(INavigatio
10631060
CommandParameter = menu,
10641061
ShowItem = options.ShowProperties
10651062
},
1063+
new ContextMenuFlyoutItemViewModelBuilder(Commands.OpenStorageSenseFromSidebar).Build(),
10661064
new ContextMenuFlyoutItemViewModel()
10671065
{
10681066
ItemType = ContextMenuFlyoutItemType.Separator,

0 commit comments

Comments
 (0)