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

settings.json parent folder functionality #15417

Closed
wants to merge 2 commits into from

Conversation

AbdullahAlmanei
Copy link

Summary of the Pull Request

Added menu flyout to "Open JSON" that takes you to the JSON parent folder instead.
This is in response to #12382
Added comments for the one function I had to implement for the path. Nothing complicated.

Copy link
Author

Choose a reason for hiding this comment

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

Messy formatting, should clean up.

Copy link
Member

Choose a reason for hiding this comment

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

tools\runformat.cmd from this repo will help reformat files automatically 😉

Copy link
Member

Choose a reason for hiding this comment

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

If you prefer PowerShell (like me), you can also do the following:

Import-Module .\tools\OpenConsole.psm1
Invoke-CodeFormat

Then, just be sure to commit the changes with git.

@AbdullahAlmanei
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

Overall, I'm cool with this. If you get really stuck with the Resources thing, then we can always just merge as-is and have the core team fix in post ☺️

(sorry for the delays, we were all a little preoccupied with Build last week)

Copy link
Member

Choose a reason for hiding this comment

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

tools\runformat.cmd from this repo will help reformat files automatically 😉

<muxc:NavigationViewItem.ContextFlyout>
<MenuFlyout>
<MenuFlyoutItem
x:Name="OpenJsonFolderNavItem"
Copy link
Member

Choose a reason for hiding this comment

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

If you give this a x:Uid, like:

            <muxc:NavigationViewItem x:Name="OpenJsonFolderNavItem"
                                     x:Uid="Nav_OpenJsonFolder"

Then you should be able to set the text in the TerminalSettingsEditor\Resources\en-us\resources.resw like:

  <data name="Nav_OpenJsonFolder.Text" xml:space="preserve">
    <value>Open JSON folder</value>
  </data>

And even the tooltip should be settable with

  <data name="Nav_OpenJsonFolder.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
    <value>Open the folder holding your settings.json file.</value>
  </data>

And if that doesn't work, then there's something wacky going on with XAML

Copy link
Author

Choose a reason for hiding this comment

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

This is exactly what I attempted originally. The thing is, NavigationViewItem.ContextFlyout doesn't take a x:Name and a x:Uid attribute. Moreover, adding the attributes to the Menuflyout or the MenuflyoutItem simply crashes the settings menu all together.

I have successfully set up different navigation items with the exact same x:Name and x:Uid, and I set the data through the .resw file. It works for most Navigation Items, but not with Menuflyouts for some reason.

I think this has something to do with the XAML or how it's wired to the rest of the program.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm... Mind committing your changes anyways? I tried the suggested changes on my end, and it worked fine. I'd be happy to take a closer look at your approach and let you know how to fix it :)

Also, you're not referencing the name OpenJsonFolderNavItem anywhere, so you might as well remove it.

Copy link
Author

Choose a reason for hiding this comment

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

It's a relic of me trying to get the resources to work! Curious that it works on your end. Must be my system. I'll commit the changes, maybe I am doing something wrong, too. I appreciate the feedback!

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Good progress! Just a few things before I sign off.

I'm also going to add the "Needs-Discussion" tag so we discuss this as a team. Specifically...

  • I have concerns that this feature might not be discoverable
  • Should we update the "new tab dropdown" "open settings" item so that if you click it with a specific modifier, it'll open the folder.
    • Should the same be done for the settings button in the settings UI (the one you're messing with right now), instead of adding a flyout?

Feel free to brainstorm and discuss in this PR too. :)

@@ -63,7 +63,8 @@ namespace Microsoft.Terminal.Settings.Model
SettingsFile = 0,
DefaultsFile,
AllFiles,
SettingsUI
SettingsUI,
SettingsFolder
Copy link
Member

Choose a reason for hiding this comment

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

(Related to this PR, but not necessary to make this change in this PR) IMO, at this point, we should fully commit and also add this as a parameter to the openSettings action. If you're interested in doing that, I think you'd mainly have to update...

  • ActionArgs.cpp OpenSettingsArgs::GenerateName()
  • TerminalSettingsSerializationHelpers.h JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::SettingsTarget)
  • Resources.resw in the TerminalSettingsModel project (this is where you update the resource key for GenerateName())

Since you already updated TerminalPage::_LaunchSettings(), this should just work outright!

If you're not interested though, let me know. Happy to do it as a follow up myself :)

Copy link
Member

Choose a reason for hiding this comment

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

If you prefer PowerShell (like me), you can also do the following:

Import-Module .\tools\OpenConsole.psm1
Invoke-CodeFormat

Then, just be sure to commit the changes with git.

<muxc:NavigationViewItem.ContextFlyout>
<MenuFlyout>
<MenuFlyoutItem
x:Name="OpenJsonFolderNavItem"
Copy link
Member

Choose a reason for hiding this comment

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

Hmm... Mind committing your changes anyways? I tried the suggested changes on my end, and it worked fine. I'd be happy to take a closer look at your approach and let you know how to fix it :)

Also, you're not referencing the name OpenJsonFolderNavItem anywhere, so you might as well remove it.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jun 8, 2023
@carlos-zamora carlos-zamora added the Needs-Discussion Something that requires a team discussion before we can proceed label Jun 8, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jun 9, 2023
@AbdullahAlmanei
Copy link
Author

AbdullahAlmanei commented Jun 9, 2023

  • I have concerns that this feature might not be discoverable

I definitely agree; you'd have to right click by accident to discover it the way it's set up right now.

  • Should we update the "new tab dropdown" "open settings" item so that if you click it with a
    specific modifier, it'll open the folder.

The thing is, there's already an alt-click modifier currently. Wouldn't the tooltip get quite lengthy if we tried something like that?

  • Should the same be done for the settings button in the settings UI (the one you're messing with right now), instead of adding a flyout?

I do believe that we should apply whatever we decide is best universally. As in, it should be the same anywhere you can access the settings JSON.

Really, I think our options are either a modifier or some kind of drop down. The latter might result in a messy user experience . A possible approach to the former might to figure out some other place we can move the current modifier to. This is, of course, if we believe that the JSON folder is a more significant and frequent operation than accessing the default JSON file. (I believe that's the current applied modifier, I have to double-check.)

@AbdullahAlmanei
Copy link
Author

@carlos-zamora I committed the changes I talked about. However, do note that it's still not working on my local system. I have the output debug text file where the program crashes when I try to navigate to the settings menu at all. I have attached it here.
Output-Debug.txt

@carlos-zamora carlos-zamora removed the Needs-Discussion Something that requires a team discussion before we can proceed label Jun 12, 2023
Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Regarding my comment earlier about discoverability. We chatted about this PR more as a team. Two things came out of it:

  1. We feel it'd be best to prioritize this as an action and add it to the command palette. To do that, you'll have to...
    • follow the instructions from this comment. This hooks it up as an action.
    • add { "command": { "action": "openSettings", "target": "<JSON KEY FROM TerminalSettingsSerializationHelpers.h>" } }, to defaults.json. This adds it to the command palette for everyone. I'd add it next to the other openSettings actions.
  2. Since the context menu isn't very discoverable, we think long-term, a better design would be something like the following:
    • alternate design with folder icon appearing on hover
    • That way the folder icon appears on hover.
    • However, this is a much more tedious to do and will have accessibility concerns/issues. It's doable, but it should definitely be its own standalone PR.

That said, we'd like to pivot this PR to focus on accomplishing the first item above and remove the context menu functionality (so basically, revert all changes made to src/cascadia/TerminalSettingsEditor). Then, as a follow-up, the UI changes can be introduced with the design from the second point above.

How does that sound? Happy to help and provide any more guidance along the way. 😊

@@ -577,6 +577,10 @@
<data name="Nav_OpenJSON.Content" xml:space="preserve">
<value>Open JSON file</value>
<comment>Header for a menu item. This opens the JSON file that is used to log the app's settings.</comment>
</data>
<data name="Nav_OpenJSONFolder.Content" xml:space="preserve">
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<data name="Nav_OpenJSONFolder.Content" xml:space="preserve">
<data name="Nav_OpenJSONFolder.Text" xml:space="preserve">

Found the bug! This'll fix the crash!

@@ -577,6 +577,10 @@
<data name="Nav_OpenJSON.Content" xml:space="preserve">
<value>Open JSON file</value>
<comment>Header for a menu item. This opens the JSON file that is used to log the app's settings.</comment>
</data>
Copy link
Member

Choose a reason for hiding this comment

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

Also, make sure you use spaces here, not tabs.

If you want, you can also edit this file in Visual Studio. It gives you a table to work with, and always formats it correctly.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jun 15, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added the No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. label Jun 22, 2023
@microsoft-github-policy-service
Copy link
Contributor

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

2 similar comments
@microsoft-github-policy-service
Copy link
Contributor

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

@microsoft-github-policy-service
Copy link
Contributor

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

carlos-zamora pushed a commit that referenced this pull request Dec 5, 2024
Most of the logic is taken from the original PR (#15417) and adapted to work with the palette.

## References and Relevant Issues
[#12382](#12382)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants