Skip to content
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

Feature: Added an option to manage tags when right clicking on the sidebar #16475

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions src/Files.App/Actions/Open/OpenSettingsAction.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.App.Dialogs;

namespace Files.App.Actions
{
internal sealed class OpenSettingsAction : BaseUIAction, IAction
Expand All @@ -21,6 +23,9 @@ public HotKey HotKey
public Task ExecuteAsync(object? parameter = null)
{
var dialog = dialogService.GetDialog(viewModel);
if (parameter is not null && parameter is SettingsDialogNavigationParams navParams)
((SettingsDialog)dialog).NavigateTo(navParams);

return dialog.TryShowAsync();
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Data/Contracts/INavigationControlItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public sealed class ContextMenuOptions
{
public bool IsLibrariesHeader { get; set; }

public bool IsTagsHeader { get; set; }

public bool ShowHideSection { get; set; }

public bool IsLocationItem { get; set; }
Expand Down
10 changes: 10 additions & 0 deletions src/Files.App/Data/Parameters/SettingsDialogNavigationParams.cs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be best to leave 'Dialog' out of the name as we're planning to remove the settings dialog in the future.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

namespace Files.App.Data.Parameters
{
public sealed class SettingsDialogNavigationParams
{
public SettingsPageKind PageKind { get; set; }
}
}
17 changes: 13 additions & 4 deletions src/Files.App/Dialogs/SettingsDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
// Licensed under the MIT License. See the LICENSE.

using Files.App.Views.Settings;
using Files.App.ViewModels.Dialogs;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Threading.Tasks;
using Files.App.Data.Enums;
using Microsoft.UI.Xaml.Media.Animation;

namespace Files.App.Dialogs
Expand All @@ -32,6 +28,19 @@ public SettingsDialog()
return (DialogResult)await base.ShowAsync();
}

public void NavigateTo(SettingsDialogNavigationParams navParams)
{
var defaultTag = SettingsPageKind.AppearancePage.ToString();
var oldSelection = MainSettingsNavigationView.MenuItems.FirstOrDefault(item => ((NavigationViewItem)item).IsSelected) as NavigationViewItem;
var targetSection = MainSettingsNavigationView.MenuItems.FirstOrDefault(
item => Enum.Parse<SettingsPageKind>(((NavigationViewItem)item).Tag.ToString() ?? defaultTag) == navParams.PageKind
);
if (oldSelection is not null)
oldSelection.IsSelected = false;

MainSettingsNavigationView.SelectedItem = targetSection;
}

private void Current_SizeChanged(object sender, WindowSizeChangedEventArgs e)
{
UpdateDialogLayout();
Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -4001,4 +4001,7 @@
<data name="DataStreamsAreHiddenDescription" xml:space="preserve">
<value>Would you like to display alternate data streams? You can modify this setting anytime from the files and folders settings page.</value>
</data>
<data name="ManageTags" xml:space="preserve">
<value>Manage tags</value>
</data>
</root>
10 changes: 9 additions & 1 deletion src/Files.App/ViewModels/UserControls/SidebarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
{
break;
}
section = BuildSection("FileTags".GetLocalizedResource(), sectionType, new ContextMenuOptions { ShowHideSection = true }, false);
section = BuildSection("FileTags".GetLocalizedResource(), sectionType, new ContextMenuOptions { IsTagsHeader = true, ShowHideSection = true }, false);
icon = new BitmapImage(new Uri(Constants.FluentIconsPaths.FileTagsIcon));
section.IsHeader = true;
section.IsExpanded = UserSettingsService.GeneralSettingsService.IsFileTagsSectionExpanded;
Expand Down Expand Up @@ -1070,6 +1070,14 @@ private List<ContextMenuFlyoutItemViewModel> GetLocationItemMenuItems(INavigatio
Tag = "ItemOverflow",
IsEnabled = false,
IsHidden = !options.ShowShellItems,
},
new ContextMenuFlyoutItemViewModel()
{
Text = "ManageTags".GetLocalizedResource(),
Glyph = "\uE8EC",
Command = Commands.OpenSettings,
CommandParameter = new SettingsDialogNavigationParams() { PageKind = SettingsPageKind.TagsPage },
ShowItem = options.IsTagsHeader
}
}.Where(x => x.ShowItem).ToList();
}
Expand Down