Skip to content

Commit

Permalink
last bit of polish
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-zamora committed Oct 8, 2024
1 parent 577ca8b commit 4d5616c
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 21 deletions.
5 changes: 1 addition & 4 deletions src/cascadia/TerminalSettingsEditor/MainPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
// Early exit if the last breadcrumb was a FolderEntry in the NewTabMenu
if (const auto& breadcrumbFolderEntry{ crumb->Tag().try_as<Editor::FolderEntryViewModel>() })
{
// TODO CARLOS: It's _a lot_ of extra work to figure out where this folder is and recreate the breadcrumbs
// It's _a lot_ of extra work to figure out where this folder is and recreate the breadcrumbs
// (and that assumes that the folder even exists!) so for now we'll just navigate to the base page
_newTabMenuPageVM.CurrentFolder(nullptr);
_Navigate(breadcrumbFolderEntry, BreadcrumbSubPage::None);
Expand Down Expand Up @@ -369,7 +369,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

void MainPage::_SetupNTMEventHandling()
{
// TODO CARLOS: validate
_ntmViewModelChangedRevoker = _newTabMenuPageVM.PropertyChanged(winrt::auto_revoke, [this](auto&&, const PropertyChangedEventArgs& args) {
const auto settingName{ args.PropertyName() };
if (settingName == L"CurrentFolder")
Expand Down Expand Up @@ -514,7 +513,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

void MainPage::_Navigate(const Editor::NewTabMenuEntryViewModel& ntmEntryVM, BreadcrumbSubPage subPage)
{
// TODO CARLOS: validate
_PreNavigateHelper();

_SetupNTMEventHandling();
Expand Down Expand Up @@ -577,7 +575,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
else if (const auto ntmEntryViewModel = tag.try_as<NewTabMenuEntryViewModel>())
{
// TODO CARLOS: validate
_Navigate(*ntmEntryViewModel, subPage);
}
else
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsEditor/NewTabMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void NewTabMenu::FolderPickerDialog_Opened(const IInspectable& /*sender*/, const Controls::ContentDialogOpenedEventArgs& /*e*/)
{
_ViewModel.CurrentFolderTreeViewSelectedItem(nullptr);
_ViewModel.GenerateFolderTree();
}

void NewTabMenu::FolderPickerDialog_PrimaryButtonClick(const IInspectable& /*sender*/, const Controls::ContentDialogButtonClickEventArgs& /*e*/)
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsEditor/NewTabMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

// FolderPickerDialog handlers
void FolderPickerDialog_Opened(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::Controls::ContentDialogOpenedEventArgs& e);
void FolderPickerDialog_Closed(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::Controls::ContentDialogClosedEventArgs& e);
void FolderPickerDialog_PrimaryButtonClick(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::UI::Xaml::Controls::ContentDialogButtonClickEventArgs& e);

// NTM Entry handlers
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalSettingsEditor/NewTabMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
<TextBlock x:Uid="NewTabMenu_CurrentFolderTextBlock"
Style="{StaticResource TextBlockSubHeaderStyle}" />

<!-- TODO CARlOS: Icon -->
<!-- TODO CARLOS: Icon -->
<!-- Once PR #17965 merges, we can add that kind of control to set an icon -->

<!-- Name -->
Expand Down
48 changes: 37 additions & 11 deletions src/cascadia/TerminalSettingsEditor/NewTabMenuViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,23 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
if (_CurrentFolder)
{
CurrentFolderName(_CurrentFolder.Name());
_CurrentFolder.PropertyChanged({ this, &NewTabMenuViewModel::_FolderPropertyChanged });
}
_NotifyChanges(L"IsFolderView", L"CurrentView");
}
});
}

void NewTabMenuViewModel::_FolderPropertyChanged(const IInspectable& /*sender*/, const Windows::UI::Xaml::Data::PropertyChangedEventArgs& args)
{
const auto viewModelProperty{ args.PropertyName() };
if (viewModelProperty == L"Name")
{
// FolderTree needs to be updated when a folder is renamed
_folderTreeCache = nullptr;
}
}

hstring NewTabMenuViewModel::CurrentFolderName() const
{
if (!_CurrentFolder)
Expand All @@ -161,6 +172,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
if (_CurrentFolder && _CurrentFolder.Name() != value)
{
_CurrentFolder.Name(value);
_NotifyChanges(L"CurrentFolderName");
}
}

Expand All @@ -178,6 +190,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
if (_CurrentFolder && _CurrentFolder.Inlining() != value)
{
_CurrentFolder.Inlining(value);
_NotifyChanges(L"CurrentFolderInlining");
}
}

Expand All @@ -187,14 +200,15 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
return {};
}
return _CurrentFolder.Inlining();
return _CurrentFolder.AllowEmpty();
}

void NewTabMenuViewModel::CurrentFolderAllowEmpty(bool value)
{
if (_CurrentFolder && _CurrentFolder.Inlining() != value)
if (_CurrentFolder && _CurrentFolder.AllowEmpty() != value)
{
_CurrentFolder.Inlining(value);
_CurrentFolder.AllowEmpty(value);
_NotifyChanges(L"CurrentFolderAllowEmpty");
}
}

Expand Down Expand Up @@ -279,16 +293,21 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
if (CurrentView().IndexOf(vm, idx))
{
CurrentView().RemoveAt(idx);

if (vm.try_as<Editor::FolderEntryViewModel>())
{
_folderTreeCache = nullptr;
}
}
}

void NewTabMenuViewModel::RequestMoveEntriesToFolder(const Windows::Foundation::Collections::IVector<Editor::NewTabMenuEntryViewModel>& entries, const Editor::FolderEntryViewModel& destinationFolder)
{
for (auto&& e : entries)
{
// Remove entry from the current layer
// Remove entry from the current layer,
// and add it to the destination folder
RequestDeleteEntry(e);

destinationFolder.Entries().Append(e);
}
}
Expand Down Expand Up @@ -321,8 +340,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

CurrentView().Append(make<FolderEntryViewModel>(folderEntry));

// Clear the field after adding the entry
// Reset state after adding the entry
AddFolderName({});
_folderTreeCache = nullptr;

_PrintAll();
}
Expand Down Expand Up @@ -354,10 +374,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_PrintAll();
}

// TODO CARLOS:
// - validate
// - reset cache when needed
Collections::IObservableVector<Editor::FolderTreeViewEntry> NewTabMenuViewModel::FolderTree()
void NewTabMenuViewModel::GenerateFolderTree()
{
if (!_folderTreeCache)
{
Expand All @@ -374,7 +391,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
root.Children().Append(winrt::make<FolderTreeViewEntry>(entry.as<Editor::FolderEntryViewModel>()));
}
}
_NotifyChanges(L"FolderTree");
}
}

Collections::IObservableVector<Editor::FolderTreeViewEntry> NewTabMenuViewModel::FolderTree() const
{
// We could do this...
// if (!_folderTreeCache){ GenerateFolderTree(); }
// But FolderTree() gets called when we open the page.
// Instead, we generate the tree as needed using GenerateFolderTree()
// which caches the tree.
return _folderTreeCache;
}

Expand Down Expand Up @@ -589,7 +616,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
_Entries = _ConvertToViewModelEntries(_FolderEntry.RawEntries());

// TODO CARLOS: we need to use this revoker somewhere
_entriesChangedRevoker = _Entries.VectorChanged(winrt::auto_revoke, [this](auto&&, const IVectorChangedEventArgs& args) {
switch (args.CollectionChange())
{
Expand Down
10 changes: 5 additions & 5 deletions src/cascadia/TerminalSettingsEditor/NewTabMenuViewModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
public:
NewTabMenuViewModel(Model::CascadiaSettings settings);
void UpdateSettings(const Model::CascadiaSettings& settings);
void GenerateFolderTree();

bool IsRemainingProfilesEntryMissing() const;
bool IsFolderView() const noexcept;
Expand All @@ -44,8 +45,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
bool CurrentFolderAllowEmpty() const;
void CurrentFolderAllowEmpty(bool value);

Windows::Foundation::Collections::IObservableVector<Model::Profile> AvailableProfiles() { return _Settings.AllProfiles(); }
Windows::Foundation::Collections::IObservableVector<Editor::FolderTreeViewEntry> FolderTree();
Windows::Foundation::Collections::IObservableVector<Model::Profile> AvailableProfiles() const { return _Settings.AllProfiles(); }
Windows::Foundation::Collections::IObservableVector<Editor::FolderTreeViewEntry> FolderTree() const;
Windows::Foundation::Collections::IObservableVector<Editor::NewTabMenuEntryViewModel> CurrentView() const;
VIEW_MODEL_OBSERVABLE_PROPERTY(Editor::FolderEntryViewModel, CurrentFolder, nullptr);
VIEW_MODEL_OBSERVABLE_PROPERTY(Editor::FolderTreeViewEntry, CurrentFolderTreeViewSelectedItem, nullptr);
Expand All @@ -60,12 +61,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
private:
Model::CascadiaSettings _Settings{ nullptr };
Windows::Foundation::Collections::IObservableVector<Editor::NewTabMenuEntryViewModel> _rootEntries;
Windows::Foundation::Collections::IObservableVector<Editor::NewTabMenuEntryViewModel>::VectorChanged_revoker _rootEntriesChangedRevoker;

Windows::Foundation::Collections::IObservableVector<Editor::FolderTreeViewEntry> _folderTreeCache;
Windows::Foundation::Collections::IObservableVector<Editor::NewTabMenuEntryViewModel>::VectorChanged_revoker _CurrentViewChangedRevoker;
Windows::Foundation::Collections::IObservableVector<Editor::NewTabMenuEntryViewModel>::VectorChanged_revoker _rootEntriesChangedRevoker;

static bool _IsRemainingProfilesEntryMissing(const Windows::Foundation::Collections::IVector<Editor::NewTabMenuEntryViewModel>& entries);
void _FolderPropertyChanged(const IInspectable& sender, const Windows::UI::Xaml::Data::PropertyChangedEventArgs& args);

void _PrintAll();
#ifdef _DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Microsoft.Terminal.Settings.Editor
{
NewTabMenuViewModel(Microsoft.Terminal.Settings.Model.CascadiaSettings settings);
void UpdateSettings(Microsoft.Terminal.Settings.Model.CascadiaSettings settings);
void GenerateFolderTree();

FolderEntryViewModel CurrentFolder;
Boolean IsFolderView { get; };
Expand Down

1 comment on commit 4d5616c

@github-actions
Copy link

Choose a reason for hiding this comment

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

@check-spelling-bot Report

🔴 Please review

See the 📜action log or 📝 job summary for details.

Unrecognized words (2)

mpe
Profiels

Previously acknowledged words that are now absent vtio vtpt 🫥
To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the [email protected]:microsoft/terminal.git repository
on the dev/cazamor/SUI/newTabMenu branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/microsoft/terminal/actions/runs/11244692818/attempts/1'
Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary

This includes both expected items (2221) from .github/actions/spelling/expect/04cdb9b77d6827c0202f51acd4205b017015bfff.txt
.github/actions/spelling/expect/alphabet.txt
.github/actions/spelling/expect/expect.txt
.github/actions/spelling/expect/web.txt and unrecognized words (2)

Dictionary Entries Covers Uniquely
cspell:cpp/src/lang-jargon.txt 11 1 1
cspell:swift/src/swift.txt 53 1 1
cspell:gaming-terms/dict/gaming-terms.txt 59 1 1
cspell:monkeyc/src/monkeyc_keywords.txt 123 1 1
cspell:cryptocurrencies/cryptocurrencies.txt 125 1 1

Consider adding them (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:

      with:
        extra_dictionaries:
          cspell:cpp/src/lang-jargon.txt
          cspell:swift/src/swift.txt
          cspell:gaming-terms/dict/gaming-terms.txt
          cspell:monkeyc/src/monkeyc_keywords.txt
          cspell:cryptocurrencies/cryptocurrencies.txt

To stop checking additional dictionaries, add (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:

check_extra_dictionaries: ''
Errors (1)

See the 📜action log or 📝 job summary for details.

❌ Errors Count
❌ ignored-expect-variant 6

See ❌ Event descriptions for more information.

✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.