-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce feature flag for editable actions page (#10581)
## Summary of the Pull Request Adds a feature flag `Feature_EditableActionsPage` that controls whether the Actions page in the Settings UI is read-only vs editable. The editable version is disabled for `Release` builds and enabled everywhere else (i.e. Dev, Preview, etc...). Validated using `<stage>` `AlwaysEnabled` and `AlwaysDisabled`. ## References #6900 - Actions Page Epic ## PR Checklist Closes #10578
- Loading branch information
1 parent
cdecfcd
commit f03cacf
Showing
7 changed files
with
406 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "pch.h" | ||
#include "ReadOnlyActions.h" | ||
#include "ReadOnlyActions.g.cpp" | ||
#include "ReadOnlyActionsPageNavigationState.g.cpp" | ||
#include "EnumEntry.h" | ||
|
||
using namespace winrt::Windows::Foundation; | ||
using namespace winrt::Windows::System; | ||
using namespace winrt::Windows::UI::Core; | ||
using namespace winrt::Windows::UI::Xaml::Navigation; | ||
using namespace winrt::Microsoft::Terminal::Settings::Model; | ||
|
||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | ||
{ | ||
ReadOnlyActions::ReadOnlyActions() | ||
{ | ||
InitializeComponent(); | ||
|
||
_filteredActions = winrt::single_threaded_observable_vector<Command>(); | ||
} | ||
|
||
void ReadOnlyActions::OnNavigatedTo(const NavigationEventArgs& e) | ||
{ | ||
_State = e.Parameter().as<Editor::ReadOnlyActionsPageNavigationState>(); | ||
|
||
std::vector<Command> keyBindingList; | ||
for (const auto& [_, command] : _State.Settings().GlobalSettings().ActionMap().NameMap()) | ||
{ | ||
// Filter out nested commands, and commands that aren't bound to a | ||
// key. This page is currently just for displaying the actions that | ||
// _are_ bound to keys. | ||
if (command.HasNestedCommands() || !command.Keys()) | ||
{ | ||
continue; | ||
} | ||
keyBindingList.push_back(command); | ||
} | ||
std::sort(begin(keyBindingList), end(keyBindingList), CommandComparator{}); | ||
_filteredActions = single_threaded_observable_vector<Command>(std::move(keyBindingList)); | ||
} | ||
|
||
Collections::IObservableVector<Command> ReadOnlyActions::FilteredActions() | ||
{ | ||
return _filteredActions; | ||
} | ||
|
||
void ReadOnlyActions::_OpenSettingsClick(const IInspectable& /*sender*/, | ||
const Windows::UI::Xaml::RoutedEventArgs& /*eventArgs*/) | ||
{ | ||
const CoreWindow window = CoreWindow::GetForCurrentThread(); | ||
const auto rAltState = window.GetKeyState(VirtualKey::RightMenu); | ||
const auto lAltState = window.GetKeyState(VirtualKey::LeftMenu); | ||
const bool altPressed = WI_IsFlagSet(lAltState, CoreVirtualKeyStates::Down) || | ||
WI_IsFlagSet(rAltState, CoreVirtualKeyStates::Down); | ||
|
||
const auto target = altPressed ? SettingsTarget::DefaultsFile : SettingsTarget::SettingsFile; | ||
|
||
_State.RequestOpenJson(target); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#pragma once | ||
|
||
#include "ReadOnlyActions.g.h" | ||
#include "ReadOnlyActionsPageNavigationState.g.h" | ||
#include "Utils.h" | ||
|
||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | ||
{ | ||
struct CommandComparator | ||
{ | ||
bool operator()(const Model::Command& lhs, const Model::Command& rhs) const | ||
{ | ||
return lhs.Name() < rhs.Name(); | ||
} | ||
}; | ||
|
||
struct ReadOnlyActionsPageNavigationState : ReadOnlyActionsPageNavigationStateT<ReadOnlyActionsPageNavigationState> | ||
{ | ||
public: | ||
ReadOnlyActionsPageNavigationState(const Model::CascadiaSettings& settings) : | ||
_Settings{ settings } {} | ||
|
||
void RequestOpenJson(const Model::SettingsTarget target) | ||
{ | ||
_OpenJsonHandlers(nullptr, target); | ||
} | ||
|
||
WINRT_PROPERTY(Model::CascadiaSettings, Settings, nullptr) | ||
TYPED_EVENT(OpenJson, Windows::Foundation::IInspectable, Model::SettingsTarget); | ||
}; | ||
|
||
struct ReadOnlyActions : ReadOnlyActionsT<ReadOnlyActions> | ||
{ | ||
public: | ||
ReadOnlyActions(); | ||
|
||
void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e); | ||
|
||
Windows::Foundation::Collections::IObservableVector<winrt::Microsoft::Terminal::Settings::Model::Command> FilteredActions(); | ||
|
||
WINRT_PROPERTY(Editor::ReadOnlyActionsPageNavigationState, State, nullptr); | ||
|
||
private: | ||
friend struct ReadOnlyActionsT<ReadOnlyActions>; // for Xaml to bind events | ||
Windows::Foundation::Collections::IObservableVector<winrt::Microsoft::Terminal::Settings::Model::Command> _filteredActions{ nullptr }; | ||
|
||
void _OpenSettingsClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs); | ||
}; | ||
} | ||
|
||
namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation | ||
{ | ||
BASIC_FACTORY(ReadOnlyActions); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import "EnumEntry.idl"; | ||
|
||
namespace Microsoft.Terminal.Settings.Editor | ||
{ | ||
runtimeclass ReadOnlyActionsPageNavigationState | ||
{ | ||
Microsoft.Terminal.Settings.Model.CascadiaSettings Settings; | ||
void RequestOpenJson(Microsoft.Terminal.Settings.Model.SettingsTarget target); | ||
event Windows.Foundation.TypedEventHandler<Object, Microsoft.Terminal.Settings.Model.SettingsTarget> OpenJson; | ||
}; | ||
|
||
[default_interface] runtimeclass ReadOnlyActions : Windows.UI.Xaml.Controls.Page | ||
{ | ||
ReadOnlyActions(); | ||
ReadOnlyActionsPageNavigationState State { get; }; | ||
|
||
IObservableVector<Microsoft.Terminal.Settings.Model.Command> FilteredActions { get; }; | ||
|
||
} | ||
} |
Oops, something went wrong.