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

Disable duplicate button without selected profile #12096

Merged
3 commits merged into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/cascadia/TerminalSettingsEditor/AddProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_State.RequestDuplicate(selected.try_as<Model::Profile>().Guid());
}
}

void AddProfile::ProfilesSelectionChanged(const IInspectable& /*sender*/,
const Windows::UI::Xaml::RoutedEventArgs& /*eventArgs*/)
{
if (!IsProfileSelected())
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
{
IsProfileSelected(true);
}
}
}
3 changes: 3 additions & 0 deletions src/cascadia/TerminalSettingsEditor/AddProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation

void AddNewClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
void DuplicateClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
void ProfilesSelectionChanged(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);

WINRT_PROPERTY(Editor::AddProfilePageNavigationState, State, nullptr);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
WINRT_OBSERVABLE_PROPERTY(bool, IsProfileSelected, _PropertyChangedHandlers, nullptr);
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalSettingsEditor/AddProfile.idl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ namespace Microsoft.Terminal.Settings.Editor
event AddNewArgs AddNew;
};

[default_interface] runtimeclass AddProfile : Windows.UI.Xaml.Controls.Page
[default_interface] runtimeclass AddProfile : Windows.UI.Xaml.Controls.Page, Windows.UI.Xaml.Data.INotifyPropertyChanged
{
AddProfile();
AddProfilePageNavigationState State { get; };
Boolean IsProfileSelected { get; };
}
}
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsEditor/AddProfile.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<local:SettingContainer x:Uid="AddProfile_Duplicate">
<muxc:RadioButtons x:Name="Profiles"
AutomationProperties.AccessibilityView="Content"
SelectionChanged="ProfilesSelectionChanged"
ItemsSource="{x:Bind State.Settings.AllProfiles, Mode=OneWay}">
<muxc:RadioButtons.ItemTemplate>
<DataTemplate x:DataType="model:Profile">
Expand Down Expand Up @@ -72,6 +73,7 @@
AutomationProperties.AutomationId="AddProfile_DuplicateButton"
AutomationProperties.Name="{Binding Tag, RelativeSource={RelativeSource Self}}"
Click="DuplicateClick"
IsEnabled="{x:Bind IsProfileSelected, Mode=OneWay}"
Style="{StaticResource AccentButtonStyle}">
<Button.Content>
<StackPanel Orientation="Horizontal">
Expand Down