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

Add UI for adding, renaming, and deleting a color scheme #8403

Merged
121 commits merged into from
Dec 17, 2020

Conversation

carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented Nov 25, 2020

Introduces the following UI controls to the ColorSchemes page:

  • "Add new" button
    • next to dropdown selector
    • adds a new color scheme named ("Color Scheme #" where # is the number of color schemes you have)
  • "Rename" Button
    • next to the selector
    • replaces the ComboBox with a TextBox and the accept/cancel buttons appear
  • "Delete" button
    • bottom of the page
    • opens flyout, when confirmed, deletes the current color scheme and selects another one

This also adds a Delete button to the Profiles page. The Hide checkbox was moved above the Delete button.

References

#1564 - Settings UI
#6800 - Settings UI Completion Epic

Detailed Description of the Pull Request / Additional comments

Color Schemes:

  • Deleting a color scheme selects another one from the list available
  • Rename replaces the combobox with a textbox to allow editing
  • The Add New button creates a new color scheme named "Color Scheme X" where X is the number of schemes defined
  • In-box color schemes cannot be deleted

Profile:

  • Deleting a profile selects another one from the list available
  • the rename button does not exist (yet), because it needs a modification to the NavigationView's Header Template
  • The delete button is disabled for in-box profiles (CMD and Windows Powershell) and dynamic profiles

Validation Steps Performed

Color Schemes - Add New
✅ Creates a new color scheme named "Color Scheme X" (X being the number of color schemes)
✅ The new color scheme can be renamed/deleted/modified

Color Schemes - Rename
✅ You cannot rename an in-box color scheme
✅ The rename button has a tooltip
✅ Clicking the rename button replaces the combobox with a textbox
✅ Accept --> changes name
✅ Cancel --> does not change the name
✅ accepting/cancelling the rename operation updates the combo box appropriately

Color Schemes - Delete
✅ Clicking delete produces a flyout to confirm deletion
✅ Deleting a color scheme removes it from the list and select the one under it
✅ Deleting the last color scheme selects the last available color scheme after it's deleted
✅ In-box color schemes have the delete button disabled, and a disclaimer appears next to it

Profile- Delete
✅ Base layer presents a disclaimer at the top, and hides the delete button
✅ Dynamic and in-box profiles disable the delete button and show the appropriate disclaimer next to the disabled button
✅ Clicking delete produces a flyout to confirm deletion
✅ Regular profiles have a delete button that is styled appropriately
✅ Clicking the delete profile button opens a content dialog. Confirmation deletes the profile and navigates to the profile indexed under it (deleting the last one redirects to the last one)

Demo

Refer to this post [here](#8403 (comment).
Confirmation flyout demo: #8403 (comment)

carlos-zamora and others added 30 commits September 17, 2020 18:33
This commit introduces a rough prototype of the Settings UI as the
`TerminalSettingsEditor`. This project was added to OpenConsole.sln and
deploys as a standalone app. Some databinding is configured to a fake
TerminalSettingsModel (located in the ObjectModel folder).

This commit will start the settings UI feature branch, which will
receive a full review on merge-back into main.

References #6720 - Settings UI Spec and Design
References #1564 - Settings UI Feature/Epic
This PR's only purpose is to convert the TSE project into a DLL while getting rid of unnecessary files in the meantime, namely the `App.*` files and moving its `ResourceDictionary` into a file called `CommonResources.xaml`.

In the process, I needed to move all the `Model` classes under `Editor` since it would have been a huge pain to try to add a Model dll alongside the Editor dll. I figured it also wouldn't matter too much since we'll be deleting the `Model` namespace in favor of using the incoming TSM.

While this doesn't contain any code of putting the Settings UI in a tab, I figured it would be nice to push this particular part as its own standalone PR.
This commit introduces a rough prototype of the Settings UI as the
`TerminalSettingsEditor`. This project was added to OpenConsole.sln and
deploys as a standalone app. Some databinding is configured to a fake
TerminalSettingsModel (located in the ObjectModel folder).

This commit will start the settings UI feature branch, which will
receive a full review on merge-back into main.

References #6720 - Settings UI Spec and Design
References #1564 - Settings UI Feature/Epic
This PR's only purpose is to convert the TSE project into a DLL while getting rid of unnecessary files in the meantime, namely the `App.*` files and moving its `ResourceDictionary` into a file called `CommonResources.xaml`.

In the process, I needed to move all the `Model` classes under `Editor` since it would have been a huge pain to try to add a Model dll alongside the Editor dll. I figured it also wouldn't matter too much since we'll be deleting the `Model` namespace in favor of using the incoming TSM.

While this doesn't contain any code of putting the Settings UI in a tab, I figured it would be nice to push this particular part as its own standalone PR.
…7802)

This PR's goal was to add an option to the `OpenSettings` keybinding to open the Settings UI in a tab. In order to implement that, a couple of changes had to be made to `Tab`, specifically:

- Introduce a tab interface named `ITab`
- Create/Rename two new Tab classes that implement `ITab` called `SettingsTab` and `TerminalTab` 

I've also put some `TODOs` that I wanted to get some thoughts on - I'll make a follow up PR but perhaps they can be revisited when we flesh out the Settings UI more.
- Does a Settings UI tab shutdown need to do anything special for cleanup?
- Does a Settings UI tab need to have `GetActiveTitle`? Maybe depending on which page in the UI is open?
- Technically, I can't focus a `Grid` control, so I'll need to figure out what to `Focus` when the tab is selected.
- The Settings UI tab doesn't have a `TermControl`, so once focus is moved to that tab, users won't be able to `nextTab/prevTab` out of it (along with all other keybindings).

References #1564, #5915
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? -->
## Summary of the Pull Request
Moved all strings into resources file for localization.

<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> 
## References
#1564 - Epic

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [ ] Closes #xxx
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [ ] Schema updated.
* [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

<!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
Added save and reset buttons.
Added warning message for unsaved settings.

![save/reset buttons and warning](https://user-images.githubusercontent.com/48369326/96289952-b6221800-0f9a-11eb-9d98-bd62c17aca19.png)

## References
#1564 - Settings UI Epic
This import is required to make localized resources work.
This PR's main goal was to get rid of all our ObjectModel references and replace them with references to TSM. 

There's a lot of places in the SUI where I wasn't able to easily drop in the TSM. Usually those settings types aren't as simple as a boolean, so they'll require some templating and finessing. For those settings, I've either commented them out for now or attempted to replace them. Here's a TLDR of what I've done in this PR.

- Since `MainPage` is the entry point, it gets a `CascadiaSettings` object to hold on to, and that's the settings object the rest of the pages will bind to.
- Deleted everything inside of `ObjectModel` along with their references.
- Replaced the ObjectModel references in the `.xaml` files with a reference to the settings object obtained in `MainPage`
- Commented out a couple of settings here and there that might need converters and/or templating.
- Attempted to write out most of the templating and data binding code for `ColorSchemes.xaml`
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? -->
## Summary of the Pull Request
Fixes the last bit of missing localization for the settings UI

<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> 
## References

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [ ] Closes #xxx
* [ ] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [ ] Schema updated.
* [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

<!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? -->
## Summary of the Pull Request
Updated icons for:
- Startup
- Appearance
- Color schemes (moved the palette icon from Appearance to here)
- Profiles

![image](https://user-images.githubusercontent.com/48369326/96916583-97b99200-145c-11eb-9301-df7b824fb1da.png)

<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> 
## References

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [ ] Closes #xxx
* [ ] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [ ] Schema updated.
* [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

<!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
This PR fleshes out the Settings UI's ColorSchemes page so that it's
able to display all your defined color schemes. It'll allow the user to
modify all the colors of the scheme through either a color picker or
entering a hex color in the TextBoxes. If the user enters an invalid hex
code, the TextBox will automatically revert back to the original hex.
Since we haven't hooked up the save button just yet, making any changes
to a color scheme will modify the color scheme only for the currently
open Terminal instance. 

References #1564
When I did the polishing I forgot to do the Advanced page under profiles. I fixed that here.
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? -->
## Summary of the Pull Request
Removed the following from the navigation menu:
- Search bar
- Home page
- Keyboard page

Changed landing page to Launch page

![image](https://user-images.githubusercontent.com/48369326/97476068-3afe2180-190b-11eb-9c9b-9b0c07a6974c.png)

<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> 
## References
#1564 

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [ ] Closes #xxx
* [ ] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [ ] Schema updated.
* [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

<!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
This PR will make the "Open JSON file" navigation view item in the Settings UI will open the user's settings file. Normally, `NavigationViewItems` raise their parent's `ItemInvoked` handler, but when a `NavViewItem` is in the `NavigationView.PaneFooter`, it doesn't do that. So, we have to hook up `OpenJson`'s `Tapped` and `KeyDown` handler to detect both a tap event and the enter keydown events.

References #1564
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? -->
## Summary of the Pull Request
Fixed the resizing bug where long text buttons get cut off, hid the unsaved changes warning, and changed "save" to "apply"

![MicrosoftTeams-image (1)](https://user-images.githubusercontent.com/48369326/97494176-2f1e5980-1923-11eb-8980-604bd5a067e5.png)

![image](https://user-images.githubusercontent.com/48369326/97494207-3a718500-1923-11eb-9409-7a95ecb50536.png)

<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> 
## References
#1564 

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [ ] Closes #xxx
* [ ] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [ ] Schema updated.
* [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

<!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
@carlos-zamora
Copy link
Member Author

I’m still holding out for that flyout on the delete button asking the user to confirm it! It’s a destructive operation, doing it instantly without asking will result in data loss

Color Scheme Confirmation Dialog

Profile Confirmation Dialog

Since you can see the name behind the dialog, figured it'd be fine to show not include the name of the profile/scheme in the content dialog. But I'm open to changing that. Just let me know 😊

@DHowett
Copy link
Member

DHowett commented Dec 17, 2020

Can we not use a simple flyout? Content dialog seems too heavyhanded. I don’t mean “flyout”, i mean Flyout. The class.

@htcfreek
Copy link

I’m still holding out for that flyout on the delete button asking the user to confirm it! It’s a destructive operation, doing it instantly without asking will result in data loss

Color Scheme Confirmation Dialog

Profile Confirmation Dialog

Since you can see the name behind the dialog, figured it'd be fine to show not include the name of the profile/scheme in the content dialog. But I'm open to changing that. Just let me know 😊

Should we define the "no" button as default?

@carlos-zamora
Copy link
Member Author

Replaced the contentdialog with the flyout so it feels less aggressive. Loving it!

Demo - Flyouts

Delete Profile

Delete Color Scheme

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

14/30

src/cascadia/TerminalSettingsModel/Profile.idl Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/ColorScheme.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Profiles.idl Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Profiles.h Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Profiles.h Outdated Show resolved Hide resolved
@@ -64,6 +100,24 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
biButton.IsChecked(biButton.Tag().as<int32_t>() == biAlignmentVal);
}

// Set the text disclaimer for the text box
// For an unknown reason, data-binding the text does not compile (using x:Bind)
Copy link
Member

Choose a reason for hiding this comment

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

every compiler error has a reason.

Copy link
Member

Choose a reason for hiding this comment

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

(don't leave comments like this.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Removing the "for an unknown reason..." part. IIRC, the error came up in the XAML code, but I don't have XAML symbols with me so I can't look into it all the way.

src/cascadia/TerminalSettingsEditor/Profiles.cpp Outdated Show resolved Hide resolved
@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Dec 17, 2020
@zadjii-msft zadjii-msft dismissed their stale review December 17, 2020 22:25

I'm unblocking this because I'm unsure if I'll have a chance to get back to this tonight 😬

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.

Okay yea, passing the event handler in the state is wack, but I don't have a better idea.

@@ -233,19 +235,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

void MainPage::_Navigate(const Editor::ProfileViewModel& profile)
{
auto state{ winrt::make_self<ProfilePageNavigationState>(profile, _settingsClone.GlobalSettings().ColorSchemes(), *this) };
auto state{ winrt::make<ProfilePageNavigationState>(profile, _settingsClone.GlobalSettings().ColorSchemes(), *this) };
Copy link
Member

Choose a reason for hiding this comment

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

woah wait why is this a make and not a make_self? Just curious

Copy link
Member Author

Choose a reason for hiding this comment

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

No reason, really. I've been using winrt::make for all the other navigation states so I guess to be consistent

_Foreground{ defaultFg },
_Background{ defaultBg },
_SelectionBackground{ DEFAULT_FOREGROUND },
_CursorColor{ cursorColor }
Copy link
Member

Choose a reason for hiding this comment

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

LOVE IT

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

Looks great. I love it.

@carlos-zamora carlos-zamora added the AutoMerge Marked for automatic merge by the bot when requirements are met label Dec 17, 2020
@ghost
Copy link

ghost commented Dec 17, 2020

Hello @carlos-zamora!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 33470ad into main Dec 17, 2020
@ghost ghost deleted the dev/cazamor/sui/rename-and-delete branch December 17, 2020 23:14
mpela81 pushed a commit to mpela81/terminal that referenced this pull request Jan 28, 2021
)

Introduces the following UI controls to the ColorSchemes page:
- "Add new" button
  - next to dropdown selector
  - adds a new color scheme named ("Color Scheme #" where # is the number of color schemes you have)
- "Rename" Button
  - next to the selector
  - replaces the ComboBox with a TextBox and the accept/cancel buttons appear
- "Delete" button
  - bottom of the page
  - opens flyout, when confirmed, deletes the current color scheme and selects another one

This also adds a Delete button to the Profiles page. The Hide checkbox was moved above the Delete button.

## References
microsoft#1564 - Settings UI
microsoft#6800 - Settings UI Completion Epic

## Detailed Description of the Pull Request / Additional comments

**Color Schemes:**
- Deleting a color scheme selects another one from the list available
- Rename replaces the combobox with a textbox to allow editing
- The Add New button creates a new color scheme named "Color Scheme X" where X is the number of schemes defined
- In-box color schemes cannot be deleted

**Profile:**
- Deleting a profile selects another one from the list available
- the rename button does not exist (yet), because it needs a modification to the NavigationView's Header Template
- The delete button is disabled for in-box profiles (CMD and Windows Powershell) and dynamic profiles

## Validation Steps Performed
**Color Schemes - Add New**
✅ Creates a new color scheme named "Color Scheme X" (X being the number of color schemes)
✅ The new color scheme can be renamed/deleted/modified

**Color Schemes - Rename**
✅ You cannot rename an in-box color scheme
✅ The rename button has a tooltip
✅ Clicking the rename button replaces the combobox with a textbox
✅ Accept --> changes name
✅ Cancel --> does not change the name
✅ accepting/cancelling the rename operation updates the combo box appropriately

**Color Schemes - Delete**
✅ Clicking delete produces a flyout to confirm deletion
✅ Deleting a color scheme removes it from the list and select the one under it
✅ Deleting the last color scheme selects the last available color scheme after it's deleted
✅ In-box color schemes have the delete button disabled, and a disclaimer appears next to it

**Profile- Delete**
✅ Base layer presents a disclaimer at the top, and hides the delete button
✅ Dynamic and in-box profiles disable the delete button and show the appropriate disclaimer next to the disabled button
✅ Clicking delete produces a flyout to confirm deletion
✅ Regular profiles have a delete button that is styled appropriately
✅ Clicking the delete profile button opens a content dialog. Confirmation deletes the profile and navigates to the profile indexed under it (deleting the last one redirects to the last one)


## Demo
Refer to this post [here](microsoft#8403 (comment).
Confirmation flyout demo: microsoft#8403 (comment)
Copy link

@stephenanthonylewis stephenanthonylewis left a comment

Choose a reason for hiding this comment

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

L

@DHowett
Copy link
Member

DHowett commented Feb 9, 2021

@stephenanthonylewis Do explain why it was necessary to sign off on an already-completed pull request from three months ago three times and e-mail the entire team about it 😉

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings UI Anything specific to the SUI AutoMerge Marked for automatic merge by the bot when requirements are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants