Skip to content

Commit 76f92d4

Browse files
DYN-8904: Hide cluster-single toggle depending on feature flag, grey out unavailable options. (#16314)
Co-authored-by: john pierson <sixtysecondrevit@gmail.com>
1 parent f1b7a16 commit 76f92d4

4 files changed

Lines changed: 80 additions & 32 deletions

File tree

src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4938,6 +4938,7 @@
49384938
</BulletDecorator.Bullet>
49394939
<!-- Text element next to each radio button -->
49404940
<TextBlock Margin="3,1,0,0"
4941+
Name="LabelTextBlock"
49414942
FontFamily="Calibri"
49424943
FontSize="12"
49434944
FontWeight="Regular"
@@ -4958,6 +4959,16 @@
49584959
<Setter TargetName="MainEllipse" Property="Fill" Value="{StaticResource PreferencesWindowBackgroundColor}" />
49594960
<Setter TargetName="MainEllipse" Property="Stroke" Value="{StaticResource PreferencesWindowFontColor}" />
49604961
</Trigger>
4962+
<Trigger Property="IsEnabled" Value="False">
4963+
<Setter TargetName="LabelTextBlock" Property="Foreground" Value="{StaticResource TabItemUnSelected}"/>
4964+
</Trigger>
4965+
<MultiTrigger>
4966+
<MultiTrigger.Conditions>
4967+
<Condition Property="IsEnabled" Value="False"/>
4968+
<Condition Property="IsChecked" Value="True"/>
4969+
</MultiTrigger.Conditions>
4970+
<Setter TargetName="MainEllipse" Property="Fill" Value="{StaticResource TabItemUnSelected}"/>
4971+
</MultiTrigger>
49614972
</ControlTemplate.Triggers>
49624973
</ControlTemplate>
49634974
</Setter.Value>

src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@
947947
Width="{StaticResource ToggleButtonWidth}"
948948
Height="{StaticResource ToggleButtonHeight}"
949949
VerticalAlignment="Center"
950+
IsEnabled="{Binding Path=NodeAutocompleteIsChecked}"
950951
IsChecked="{Binding Path=NodeAutocompleteNewUIIsChecked}"
951952
Style="{StaticResource EllipseToggleButton1}"/>
952953
<Label Content="{x:Static p:Resources.PreferencesViewEnableNodeAutoCompleteNewUI}"
@@ -980,37 +981,11 @@
980981
<RowDefinition Height="*" />
981982
<RowDefinition Height="*" />
982983
</Grid.RowDefinitions>
983-
<Grid Grid.Row="0">
984-
<Grid.RowDefinitions>
985-
<RowDefinition Height="*" />
986-
<RowDefinition Height="*" />
987-
<RowDefinition Height="*" />
988-
<RowDefinition Height="*" />
989-
</Grid.RowDefinitions>
990-
<StackPanel Margin="-5,5,0,0" Orientation="Horizontal" Grid.Row="0">
991-
<Label Content="{x:Static p:Resources.MLRecommendationNumberOfResults}"
992-
VerticalAlignment="Center"
993-
Foreground="{StaticResource PreferencesWindowFontColor}"
994-
FontWeight="Normal"/>
995-
<TextBox Name="MLRecommendationResultsNumber"
996-
HorizontalAlignment="Left"
997-
Margin="2,0,0,0"
998-
MinWidth="25"
999-
Height="20"
1000-
FontWeight="Regular"
1001-
Text="{Binding MLRecommendationNumberOfResults}"
1002-
Background="{StaticResource PreferencesWindowBackgroundColor}"
1003-
Foreground="{StaticResource PreferencesWindowFontColor}"
1004-
BorderThickness="0,0,0,2"
1005-
PreviewTextInput="NumberValidationTextBox"
1006-
IsEnabled="{Binding Path=NodeAutocompleteMachineLearningIsChecked}"/>
1007-
</StackPanel>
1008-
</Grid>
1009-
<Label Grid.Row="1"
984+
<Label Grid.Row="0"
1010985
Margin="-5,5,0,0"
1011986
Content="{x:Static p:Resources.PreferencesNodeAutocompleteMethod}"
1012987
Foreground="{StaticResource PreferencesWindowFontColor}"/>
1013-
<Grid Grid.Row="2"
988+
<Grid Grid.Row="1"
1014989
Margin="0,5,0,5">
1015990
<Grid.ColumnDefinitions>
1016991
<ColumnDefinition x:Name="colObjectType" Width="Auto"/>
@@ -1023,11 +998,10 @@
1023998
Content="{x:Static p:Resources.ObjectType}"
1024999
IsEnabled="{Binding Path=NodeAutocompleteIsChecked}"/>
10251000
</Grid>
1026-
<Grid Grid.Row="3"
1001+
<Grid Grid.Row="2"
10271002
Margin="0,5,0,5">
10281003
<Grid.ColumnDefinitions>
10291004
<ColumnDefinition x:Name="colMachineLearning" Width="Auto"/>
1030-
<ColumnDefinition x:Name="colMLbetaTag" Width="Auto"/>
10311005
</Grid.ColumnDefinitions>
10321006
<RadioButton Grid.Column="0"
10331007
x:Name="RecommendedNodesRadioButton"
@@ -1038,6 +1012,49 @@
10381012
Click="RecommendedNodesRadioButton_Click"
10391013
IsEnabled="{Binding Path=NodeAutocompleteIsChecked}"/>
10401014
</Grid>
1015+
<Grid Grid.Row="3">
1016+
<Grid.RowDefinitions>
1017+
<RowDefinition Height="*" />
1018+
<RowDefinition Height="*" />
1019+
<RowDefinition Height="*" />
1020+
<RowDefinition Height="*" />
1021+
</Grid.RowDefinitions>
1022+
<StackPanel Margin="-5,0,0,0" Orientation="Horizontal" Grid.Row="0">
1023+
<Label Content="{x:Static p:Resources.MLRecommendationNumberOfResults}"
1024+
VerticalAlignment="Center"
1025+
Foreground="{StaticResource PreferencesWindowFontColor}"
1026+
FontWeight="Normal"/>
1027+
<TextBox Name="MLRecommendationResultsNumber"
1028+
HorizontalAlignment="Left"
1029+
Margin="2,0,0,0"
1030+
MinWidth="25"
1031+
Height="20"
1032+
FontWeight="Regular"
1033+
Text="{Binding MLRecommendationNumberOfResults}"
1034+
Background="{StaticResource PreferencesWindowBackgroundColor}"
1035+
Foreground="{StaticResource PreferencesWindowFontColor}"
1036+
BorderThickness="0,0,0,2"
1037+
PreviewTextInput="NumberValidationTextBox">
1038+
<TextBox.Style>
1039+
<Style TargetType="TextBox">
1040+
<!-- Default state -->
1041+
<Setter Property="IsEnabled" Value="False"/>
1042+
1043+
<!-- Enable only when both conditions are true -->
1044+
<Style.Triggers>
1045+
<MultiDataTrigger>
1046+
<MultiDataTrigger.Conditions>
1047+
<Condition Binding="{Binding NodeAutocompleteMachineLearningIsChecked}" Value="True"/>
1048+
<Condition Binding="{Binding NodeAutocompleteIsChecked}" Value="True"/>
1049+
</MultiDataTrigger.Conditions>
1050+
<Setter Property="IsEnabled" Value="True"/>
1051+
</MultiDataTrigger>
1052+
</Style.Triggers>
1053+
</Style>
1054+
</TextBox.Style>
1055+
</TextBox>
1056+
</StackPanel>
1057+
</Grid>
10411058
</Grid>
10421059
</StackPanel>
10431060
</Grid>

src/NodeAutoCompleteViewExtension/ViewModels/NodeAutoCompleteBarViewModel.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class NodeAutoCompleteBarViewModel : SearchViewModel
5656
public bool SwitchIsEnabled => ResultsLoaded && !IsInput;
5757
public bool IsSingleAutocomplete
5858
{
59-
get => _isSingleAutocomplete || IsInput;
59+
get => _isSingleAutocomplete || IsInput || !dynamoViewModel.IsDNAClusterPlacementEnabled;
6060
set
6161
{
6262
if (PortViewModel.PortType == PortType.Output && _isSingleAutocomplete != value)
@@ -388,6 +388,17 @@ public bool DisplayLowConfidence
388388
}
389389
}
390390

391+
/// <summary>
392+
/// Expose IsDNAClusterPlacementEnabled feature flag as readonly in the viewmodel
393+
/// </summary>
394+
public bool IsDNAClusterPlacementEnabled
395+
{
396+
get
397+
{
398+
return dynamoViewModel.IsDNAClusterPlacementEnabled;
399+
}
400+
}
401+
391402
internal event Action<NodeModel> ParentNodeRemoved;
392403

393404
internal MLNodeClusterAutoCompletionResponse FullResults { private set; get; }

src/NodeAutoCompleteViewExtension/Views/NodeAutoCompleteBarView.xaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717
Height="45"
1818
PreviewKeyDown="OnAutoCompleteKeyDown"
1919
>
20+
<Window.Style>
21+
<Style TargetType="Window">
22+
<Style.Triggers>
23+
<DataTrigger Binding="{Binding IsDNAClusterPlacementEnabled}" Value="False">
24+
<Setter Property="Width" Value="500"/>
25+
</DataTrigger>
26+
</Style.Triggers>
27+
</Style>
28+
</Window.Style>
2029
<Window.Resources>
2130
<ResourceDictionary>
2231
<ResourceDictionary.MergedDictionaries>
@@ -423,7 +432,7 @@
423432
</Style>
424433
</Button.Style>
425434
</Button>
426-
<Grid Grid.Column="8">
435+
<Grid Grid.Column="8" Visibility="{Binding IsDNAClusterPlacementEnabled, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=Collapse}">
427436
<ToggleButton x:Name="SwitchButton" Width="100" Height="36" FocusVisualStyle="{x:Null}"
428437
HorizontalAlignment="Center" VerticalAlignment="Center"
429438
Background="{StaticResource DarkGreyBrush}" BorderBrush="DarkGray" BorderThickness="2"

0 commit comments

Comments
 (0)