terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Add functionality to settings `Open JSON file` entry to open the settings.json parent folder in Explorer

Open darkred opened this issue 3 years ago • 9 comments

Description of the new feature/enhancement

(this is a follow up to this issue #1460)

I have Windows Terminal latest stable, v1.12.10334.0 , on win11.

Currently, in the dropdown menu | 'Settings', there's an Open JSON file entry, clicking which opens the settings.json file only if the user has associated the .json file type with an installed editor, otherwise it shows the "Do you want to open this file?" windows dialog .

screen capture:

If you close the dialog, in order to manage to open the settings.json file manually, you'll have to look in the project wiki FAQ to find its location/path - there's no related info shown inside the app.

So, my suggestion is add functionality to "Open JSON file" settings entry to open the settings.json parent folder in Explorer.

Proposed technical implementation details (optional)

In details, my suggestion is, when clicking the Open JSON file entry, instead of attempting to open settings.json with the associated editor, to display a menu with two entries:

  • Open settings.json with associated editor
  • Open parent folder of settings.json in Explorer (in order to be able to open it manually).

  Or, alternatively/more simply, keep the current behavior (=attempt to open the file with the associated editor when leftclicking the "Open JSON file" entry), but when rightclicking it, to open its parent folder in file explorer (and update the entry tooltip respectively).

darkred avatar Feb 04 '22 23:02 darkred

This is a clever idea.

Other ideas to build on this:

We change the button at the bottom of the nav view to a "More options" button with a flyout, and in there, stick:

  • Open JSON file
  • Open settings folder
  • Reset to default settings (#947)

zadjii-msft avatar Feb 08 '22 11:02 zadjii-msft

@zadjii-msft I'll give this a punt if thats okay. Would need some pointers, particularly surrounding how the UI works!

Swinkid avatar Mar 16 '23 20:03 Swinkid

@Swinkid sorry I lost that in my inbox! Okay, here's some thoughts:

Note

Walkthrough

The "Open JSON File" button is defined here: https://github.com/microsoft/terminal/blob/fc90045cc37c4862f0d447f7ceb5fe1a20eea3fd/src/cascadia/TerminalSettingsEditor/MainPage.xaml#L156-L166

I think it'd be easy to add a context menu flyout to it. Probably something like


                <NavigationViewItem.ContextFlyout>
                    <MenuFlyoutItem></MenuFlyoutItem>
                </NavigationViewItem.ContextFlyout>

To set the .ContextFlyout on it

It might be harder to change that button to like, a split button. But OP did say it was okay to implement this as a right-click context menu.

As far as what the button should actually do - MainPage::OpenJsonTapped currently just bubbles a SettingsTarget to the handler in fire_and_forget TerminalPage::_LaunchSettings.

So I'd:

  • add a new SettingsTarget for SettingsDirectory to ActionArgs.idl
  • Add a button handler to the MenuFlyoutItem in MainPage that just calls _OpenJsonHandlers(nullptr, SettingsTarget::SettingsDirectory);
  • add a case in TerminalPage::_LaunchSettings to open the directory for the settings, rather than the file itself.

zadjii-msft avatar Apr 28 '23 11:04 zadjii-msft

Created a PR for this issue! Take a look here: #15417 I couldn't set the Tooltip and the text through the resources for some reason. (It kept crashing whenever I tried linking the resources to the flyout menu using x:Uid) I might have been missing something simple, but I am not sure what exactly.

AbdullahAlmanei avatar May 24 '23 09:05 AbdullahAlmanei

@zadjii-msft for #15417, would setting the text through resources be necessary? I've still not worked out why it's not working.

AbdullahAlmanei avatar May 30 '23 21:05 AbdullahAlmanei

The resources kinda are, actually. They're used for localization purposes, so only the .resw files get translated, and the .xaml files basically pick the correct translation up automatically.

That's pretty much entirely keyed off the x:Uid property in XAML. (I'll leave comments on the PR ☺️)

zadjii-msft avatar May 31 '23 11:05 zadjii-msft

@AbdullahAlmanei and @Swinkid are any of you working on this or is this up for grabs?

marcelwgn avatar Mar 21 '24 20:03 marcelwgn

@AbdullahAlmanei and @Swinkid are any of you working on this or is this up for grabs?

Go ahead!

Swinkid avatar Mar 21 '24 21:03 Swinkid

Hello, I noticed that this issue has a stale PR(#15417) that is almost a year old. In the PR it seems like a diferent solution was proposed and still needs to be done. Should the solution be based on what was discussed in #15417, or is the proposed solution in this thread still relevant? I would like to submit my own PR and want to know what direction I should be going in.

Ismith507 avatar May 01 '24 15:05 Ismith507