Skip to content

Commit

Permalink
Cp 13834 13859 (#13862)
Browse files Browse the repository at this point in the history
* ALSO-5603 Add parameter hiding autocomplete options from the UI (#13834)

* ALSO-5603 Add parameter hiding autocomplete options from the UI

* ALSO-5603 Use IPreferences for hide autocomplete option

This needs to avoid breaking compatibility

* ALSO-5603 Add hide autocomplete option to the settings

* ALSO-5603 Fix unit test

* ALSO-5603 Hide missing ML complete controls if hiding option is set (#13859)

---------

Co-authored-by: spodo99 <[email protected]>
  • Loading branch information
sm6srw and spodo99 authored Mar 31, 2023
1 parent d4f200d commit ac1ae39
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
12 changes: 12 additions & 0 deletions src/DynamoCore/Configuration/IPreferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@ internal interface IDisablePackageLoadingPreferences
bool DisableCustomPackageLocations { get; set; }
}

/// <summary>
/// Temporary interface to avoid breaking changes.
/// TODO: Merge with StartupConfiguration for 3.0 (DYN-1699)
/// </summary>
internal interface IHideAutocompleteMethodOptions
{
/// <summary>
/// If true, autocomplete method options are hidden from UI
/// </summary>
bool HideAutocompleteMethodOptions { get; set; }
}

/// <summary>
/// Represents data about active state of preview background
/// </summary>
Expand Down
8 changes: 7 additions & 1 deletion src/DynamoCore/Configuration/PreferenceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal static void CopyProperties(this PreferenceSettings source, PreferenceSe
/// from a XML file from DYNAMO_SETTINGS_FILE.
/// When GUI is closed, the settings are saved back into the XML file.
/// </summary>
public class PreferenceSettings : NotificationObject, IPreferences, IRenderPrecisionPreference, IDisablePackageLoadingPreferences, ILogSource
public class PreferenceSettings : NotificationObject, IPreferences, IRenderPrecisionPreference, IDisablePackageLoadingPreferences, ILogSource, IHideAutocompleteMethodOptions
{
private string numberFormat;
private string lastUpdateDownloadPath;
Expand Down Expand Up @@ -525,6 +525,11 @@ public string PythonTemplateFilePath
/// </summary>
public int MLRecommendationNumberOfResults { get; set; }

/// <summary>
/// If true, autocomplete method options are hidden from UI
/// </summary>
public bool HideAutocompleteMethodOptions { get; set; }

/// <summary>
/// This defines if user wants to see the enabled Dynamo Notification Center.
/// </summary>
Expand Down Expand Up @@ -767,6 +772,7 @@ public PreferenceSettings()
HideNodesBelowSpecificConfidenceLevel = false;
MLRecommendationConfidenceLevel = 10;
MLRecommendationNumberOfResults = 10;
HideAutocompleteMethodOptions = false;
EnableNotificationCenter = true;
isStaticSplashScreenEnabled = true;
DefaultPythonEngine = string.Empty;
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ protected DynamoViewModel(StartConfiguration startConfiguration)
model.ComputeModelDeserialized += model_ComputeModelDeserialized;
model.RequestNotification += model_RequestNotification;

preferencesViewModel = new PreferencesViewModel(this);
preferencesViewModel = new PreferencesViewModel(this);

if (!DynamoModel.IsTestMode && !DynamoModel.IsHeadless)
{
Expand Down
11 changes: 11 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,17 @@ public bool NotificationCenterIsChecked

#region [ Node Autocomplete ]

/// <summary>
/// If true, autocomplete method options are hidden from UI
/// </summary>
public bool HideAutocompleteMethodOptions
{
get
{
return preferenceSettings.HideAutocompleteMethodOptions;
}
}

/// <summary>
/// Controls the IsChecked property in the "Node autocomplete" toogle button
/// </summary>
Expand Down
7 changes: 4 additions & 3 deletions src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -743,19 +743,20 @@
</Image>
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0,-5,0,0" Grid.Row="1">
<StackPanel Orientation="Horizontal" Margin="0,-5,0,0" Grid.Row="1"
Visibility="{Binding HideAutocompleteMethodOptions, Converter={StaticResource InverseBoolToVisibilityCollapsedConverter}}">
<!-- This Grid contains controls for selecting the Node autocomplete method -->
<Grid Margin="60,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.Row="0"
<Label Grid.Row="0"
Margin="-8,15,10,3"
Content="{x:Static p:Resources.PreferencesNodeAutocompleteMethod}"
Foreground="{StaticResource PreferencesWindowFontColor}"/>
<Grid Grid.Row="1">
<Grid Grid.Row="1" >
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="colObjectType" Width="Auto"/>
<ColumnDefinition x:Name="colMachineLearning" Width="Auto"/>
Expand Down
1 change: 1 addition & 0 deletions test/settings/DynamoSettings-NewSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<HideNodesBelowSpecificConfidenceLevel>true</HideNodesBelowSpecificConfidenceLevel>
<MLRecommendationConfidenceLevel>99</MLRecommendationConfidenceLevel>
<MLRecommendationNumberOfResults>5</MLRecommendationNumberOfResults>
<HideAutocompleteMethodOptions>true</HideAutocompleteMethodOptions>
<EnableNotificationCenter>false</EnableNotificationCenter>
<EnableStaticSplashScreen>false</EnableStaticSplashScreen>
<DefaultPythonEngine/>
Expand Down

0 comments on commit ac1ae39

Please sign in to comment.