Skip to content

Commit 176a3c0

Browse files
committed
Fix: Allow dragging Shell: paths in sidebar reorder and remove old reorder dialog
1 parent 7456ba8 commit 176a3c0

6 files changed

Lines changed: 5 additions & 206 deletions

File tree

src/Files.App.Controls/Sidebar/SidebarItem.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void HandleItemChange()
9595

9696
if (Item is IDraggableSidebarItemModel draggableItem)
9797
{
98-
CanDrag = draggableItem.DropPath is not null && System.IO.Path.IsPathRooted(draggableItem.DropPath);
98+
CanDrag = IsValidDropPath(draggableItem.DropPath);
9999
UseReorderDrop = !IsGroupHeader && CanDrag && draggableItem.IsReorderDropItem;
100100
}
101101
else
@@ -148,9 +148,12 @@ private void HookupItemChangeListener(ISidebarItemModel? oldItem, ISidebarItemMo
148148
}
149149
}
150150

151+
private static bool IsValidDropPath(string? path)
152+
=> path is not null && (System.IO.Path.IsPathRooted(path) || path.StartsWith("Shell:", StringComparison.OrdinalIgnoreCase));
153+
151154
private void SidebarItem_DragStarting(UIElement sender, DragStartingEventArgs args)
152155
{
153-
if (Item is not IDraggableSidebarItemModel draggableItem || draggableItem.DropPath is not string dragPath || !System.IO.Path.IsPathRooted(dragPath))
156+
if (Item is not IDraggableSidebarItemModel draggableItem || draggableItem.DropPath is not string dragPath || !IsValidDropPath(dragPath))
154157
return;
155158

156159
try

src/Files.App/Dialogs/ReorderSidebarItemsDialog.xaml

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/Files.App/Dialogs/ReorderSidebarItemsDialog.xaml.cs

Lines changed: 0 additions & 95 deletions
This file was deleted.

src/Files.App/Services/App/AppDialogService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public DialogService()
2525
{ typeof(DecompressArchiveDialogViewModel), () => new DecompressArchiveDialog() },
2626
{ typeof(SettingsDialogViewModel), () => new SettingsDialog() },
2727
{ typeof(CreateShortcutDialogViewModel), () => new CreateShortcutDialog() },
28-
{ typeof(ReorderSidebarItemsDialogViewModel), () => new ReorderSidebarItemsDialog() },
2928
{ typeof(AddBranchDialogViewModel), () => new AddBranchDialog() },
3029
{ typeof(GitHubLoginDialogViewModel), () => new GitHubLoginDialog() },
3130
{ typeof(FileTooLargeDialogViewModel), () => new FileTooLargeDialog() },

src/Files.App/ViewModels/Dialogs/ReorderSidebarItemsDialogViewModel.cs

Lines changed: 0 additions & 30 deletions
This file was deleted.

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ public SidebarViewModel()
270270
PinItemCommand = new RelayCommand(PinItem);
271271
EjectDeviceCommand = new RelayCommand(EjectDevice);
272272
OpenPropertiesCommand = new RelayCommand<CommandBarFlyout>(OpenProperties);
273-
ReorderItemsCommand = new AsyncRelayCommand(ReorderItemsAsync);
274273
}
275274

276275
private Task<LocationItem> CreateItemHomeAsync()
@@ -896,8 +895,6 @@ public async void HandleItemInvokedAsync(object item, PointerUpdateKind pointerU
896895

897896
private ICommand OpenPropertiesCommand { get; }
898897

899-
private ICommand ReorderItemsCommand { get; }
900-
901898
private void PinItem()
902899
{
903900
if (rightClickedItem is DriveItem)
@@ -937,13 +934,6 @@ private void HideSection()
937934
}
938935
}
939936

940-
private async Task ReorderItemsAsync()
941-
{
942-
var dialog = new ReorderSidebarItemsDialogViewModel();
943-
var dialogService = Ioc.Default.GetRequiredService<IDialogService>();
944-
var result = await dialogService.ShowDialogAsync(dialog);
945-
}
946-
947937
private void OpenProperties(CommandBarFlyout menu)
948938
{
949939
EventHandler<object> flyoutClosed = null!;
@@ -1074,13 +1064,6 @@ private List<ContextMenuFlyoutItemViewModel> GetLocationItemMenuItems(INavigatio
10741064
ShowItem = options.ShowUnpinItem || isDriveItemPinned
10751065
},
10761066
new ContextMenuFlyoutItemViewModel()
1077-
{
1078-
Text = Strings.ReorderSidebarItemsDialogText.GetLocalizedResource(),
1079-
Glyph = "\uE8D8",
1080-
Command = ReorderItemsCommand,
1081-
ShowItem = isPinnedItem || item.Section is SectionType.Pinned
1082-
},
1083-
new ContextMenuFlyoutItemViewModel()
10841067
{
10851068
Text = string.Format(Strings.SideBarHideSectionFromSideBar_Text.GetLocalizedResource(), rightClickedItem.Text),
10861069
Glyph = "\uE77A",

0 commit comments

Comments
 (0)