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

Dyn 4715 package name special characters #12802

Merged
merged 29 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
98dfeda
Merge pull request #1 from DynamoDS/master
jesusalvino Jan 18, 2022
8a8e4bb
Merge branch 'DynamoDS:master' into master
jesusalvino Jan 26, 2022
c214c77
Merge branch 'DynamoDS:master' into master
jesusalvino Jan 28, 2022
422cee9
Merge branch 'DynamoDS:master' into master
jesusalvino Feb 6, 2022
f815528
Merge branch 'DynamoDS:master' into master
jesusalvino Feb 8, 2022
d48c72a
Merge branch 'DynamoDS:master' into master
jesusalvino Feb 12, 2022
3671b95
Merge branch 'DynamoDS:master' into master
jesusalvino Feb 15, 2022
36ea946
Merge branch 'DynamoDS:master' into master
jesusalvino Feb 22, 2022
d7bb37b
Merge branch 'DynamoDS:master' into master
jesusalvino Mar 1, 2022
32befba
Merge branch 'DynamoDS:master' into master
jesusalvino Mar 7, 2022
2f2b375
Merge branch 'DynamoDS:master' into master
jesusalvino Mar 7, 2022
6ed0cb8
Merge branch 'DynamoDS:master' into master
jesusalvino Mar 8, 2022
76b40f5
Merge branch 'DynamoDS:master' into master
jesusalvino Mar 11, 2022
b9505de
Merge branch 'DynamoDS:master' into master
jesusalvino Mar 14, 2022
150f432
Merge branch 'DynamoDS:master' into master
jesusalvino Mar 16, 2022
c088daf
Merge branch 'DynamoDS:master' into master
jesusalvino Mar 17, 2022
2493ac0
Merge branch 'DynamoDS:master' into master
jesusalvino Mar 22, 2022
4c6041e
Merge branch 'DynamoDS:master' into master
jesusalvino Mar 24, 2022
4f6b37c
Merge branch 'DynamoDS:master' into master
jesusalvino Mar 31, 2022
e095a69
Merge branch 'DynamoDS:master' into master
jesusalvino Apr 11, 2022
d0404c8
Preventing Special Characters in the Publish Package
jesusalvino Apr 14, 2022
776242c
Updating Warning name and comments
jesusalvino Apr 14, 2022
7c4e4ce
Updating the SpecialAndInvalidCharacters function to the .Net Library
jesusalvino Apr 18, 2022
5df10f1
Refactoring the SpecialAndInvalidCharacters to single line
jesusalvino Apr 19, 2022
72cdbdc
Updating the accesibility level of the SpecialAndInvalidCharacters fu…
jesusalvino Apr 19, 2022
e864e85
Using the SpecialAndInvalidCharacters as a static property
jesusalvino Apr 19, 2022
52159ca
Restoring the function ContainsSpecialCharacters for testing purpose
jesusalvino Apr 20, 2022
e877a2c
Moving the place of the SpecialAndInvalidCharacters
jesusalvino Apr 20, 2022
250989e
Removing the InvalidCharacters static property
jesusalvino Apr 20, 2022
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
12 changes: 9 additions & 3 deletions src/DynamoCore/Search/SearchDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,17 @@ private static string[] SplitOnWhiteSpace(string s)
return s.Split(null);
}

private static bool ContainsSpecialCharacters(string element)
public static Char[] SpecialAndInvalidCharacters()
reddyashish marked this conversation as resolved.
Show resolved Hide resolved
{
return element.Contains("*") || element.Contains(".") || element.Contains(" ")
|| element.Contains("\\");
return new[] { '*', '.', ' ', '\\', '/', ':', '?', '<', '>', '|', '"' };
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
}

public static bool ContainsSpecialCharacters(string element)
{
Char[] invalidCharacters = SpecialAndInvalidCharacters();
return (!string.IsNullOrEmpty(element) && element.IndexOfAny(invalidCharacters) >= 0);
}

#endregion

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ Next assemblies were loaded several times:
{0}</value>
</data>
<data name="PackageNameCannotContainTheseCharacters" xml:space="preserve">
<value>The name of the package cannot contain /,\, or *.</value>
<value>The name of the package cannot contain</value>
<comment>ErrorString</comment>
</data>
<data name="PackageNeedAtLeastOneFile" xml:space="preserve">
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,7 @@ If the toggle is off custom packages that are not already loaded will load once
<comment>ErrorString</comment>
</data>
<data name="PackageNameCannotContainTheseCharacters" xml:space="preserve">
<value>The name of the package cannot contain /,\, or *.</value>
<value>The name of the package cannot contain</value>
<comment>ErrorString</comment>
</data>
<data name="PackageNeedAtLeastOneFile" xml:space="preserve">
Expand Down
156 changes: 122 additions & 34 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,40 @@
<Setter Property="Background" Value="#343434" />
</Style>

<!-- Generic Dynamo ToolTip -->
<Style x:Key="GenericToolTipLight" TargetType="ToolTip">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="MaxWidth" Value="300" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToolTip">
<Grid x:Name="PopupGrid">
<Grid x:Name="ShadowBackground" Background="Transparent">
<Path Margin="5 0 0 0" Width="20" Height="6" HorizontalAlignment="Left" VerticalAlignment="Top" Data="M0,6 L6,0 12,6Z" Stroke="Gray" Fill="White" Stretch="None" />
<Border BorderThickness="1 0 1 1" CornerRadius="3" Margin="0 5 7 7" BorderBrush="#999999" Background="white" Padding="10,8">
<ContentPresenter/>
</Border>
<Border BorderThickness="0 1 0 0" CornerRadius="0 0 3 0" Margin="16 5 9 0" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="7" BorderBrush="#999999" />
<Border BorderThickness="0 1 0 0" CornerRadius="3 0 0 0" Margin="0 5 0 0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="7" Width="6" BorderBrush="#999999" />
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Resources>
<Style TargetType="ContentPresenter">
<Style.Resources>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="FontFamily" Value="{StaticResource ArtifaktElementRegular}" />
<Setter Property="FontSize" Value="12px" />
<Setter Property="Foreground" Value="#232323" />
</Style>
</Style.Resources>
</Style>
</Style.Resources>
</Style>

<Image x:Key="ComboDownIcon_normal" Source="pack://application:,,,/DynamoCoreWpf;component/UI/Images/tick_selected.png" />

<ControlTemplate x:Key="ComboBoxToggleButton" TargetType="ToggleButton">
Expand Down Expand Up @@ -723,6 +757,94 @@
</Setter>
</Style>

<Style x:Key="InputStyleWithIcon" TargetType="{x:Type TextBox}">
Copy link
Contributor

@QilongTang QilongTang Apr 14, 2022

Choose a reason for hiding this comment

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

What are the changes to this style?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What are the changes to this style?

adds an extra space to the right side of the input to draw the Icon that will be displayed if required

<Setter Property="Margin" Value="0,0,0,12" />
<Setter Property="MinWidth" Value="62px" />
<Setter Property="CaretBrush" Value="{StaticResource PrimaryCharcoal200Brush}" />
<Setter Property="Padding" Value="10,12,10,8"/>
<Setter Property="FontFamily" Value="{StaticResource ArtifaktElementRegular}"/>
<Setter Property="FontSize" Value="12px" />
<Setter Property="Foreground" Value="{StaticResource PrimaryCharcoal200Brush}"/>
<Setter Property="TextWrapping" Value="Wrap"/>

<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="25" />
</Grid.ColumnDefinitions>
<Border Grid.Row="0"
Grid.ColumnSpan="2"
Background="#353535"
BorderBrush="Transparent"
BorderThickness="1"
/>
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center"/>
<Label x:Name="WaterMarkLabel"
Grid.Row="0"
Padding="13,13,10,8"
Content="{TemplateBinding Tag}"
VerticalAlignment="Center"
Visibility="Collapsed"
FontFamily="{StaticResource ArtifaktElementRegular}"
FontSize="12px"
Foreground="{StaticResource PrimaryCharcoal200Brush}"
IsHitTestVisible="False"
Opacity="0.5"/>
<!-- This is the Canvas for the exclamation mark appearing when the Style that the user is trying to insert already exists -->
<Canvas Grid.Column="1" Margin="0,5,5,0"
Visibility="{Binding Path=IsWarningEnabled, Converter={StaticResource BooleanToVisibilityConverter}}">
<Canvas.ToolTip>
<ToolTip Content="{Binding CurrentWarningMessage}" Style="{StaticResource GenericToolTipLight}"/>
</Canvas.ToolTip>
<Path Fill="#FAA21B">
<Path.Data>
<CombinedGeometry GeometryCombineMode="Exclude">
<CombinedGeometry.Geometry1>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure IsClosed="True" StartPoint="10,5">
<PathFigure.Segments>
<PathSegmentCollection>
<LineSegment Point="18,20" />
<LineSegment Point="2,20" />
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<GeometryGroup FillRule="EvenOdd">
<EllipseGeometry Center="10,18" RadiusX="1.5" RadiusY="1.5"/>
<RectangleGeometry Rect="8.5,8.5,3,7.5"/>
</GeometryGroup>
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
</Canvas>
</Grid>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Text" Value=""/>
</MultiTrigger.Conditions>
<Setter Property="Visibility" TargetName="WaterMarkLabel" Value="Visible"/>
</MultiTrigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{StaticResource PrimaryCharcoal200Brush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="LabelStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="{StaticResource ArtifaktElementBold}" />
<Setter Property="FontWeight" Value="Bold" />
Expand Down Expand Up @@ -1899,40 +2021,6 @@
</Setter>
</Style>

<!-- Generic Dynamo ToolTip -->
<Style x:Key="GenericToolTipLight" TargetType="ToolTip">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="MaxWidth" Value="300" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToolTip">
<Grid x:Name="PopupGrid">
<Grid x:Name="ShadowBackground" Background="Transparent">
<Path Margin="5 0 0 0" Width="20" Height="6" HorizontalAlignment="Left" VerticalAlignment="Top" Data="M0,6 L6,0 12,6Z" Stroke="Gray" Fill="White" Stretch="None" />
<Border BorderThickness="1 0 1 1" CornerRadius="3" Margin="0 5 7 7" BorderBrush="#999999" Background="white" Padding="10,8">
<ContentPresenter/>
</Border>
<Border BorderThickness="0 1 0 0" CornerRadius="0 0 3 0" Margin="16 5 9 0" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="7" BorderBrush="#999999" />
<Border BorderThickness="0 1 0 0" CornerRadius="3 0 0 0" Margin="0 5 0 0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="7" Width="6" BorderBrush="#999999" />
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Resources>
<Style TargetType="ContentPresenter">
<Style.Resources>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="FontFamily" Value="{StaticResource ArtifaktElementRegular}" />
<Setter Property="FontSize" Value="12px" />
<Setter Property="Foreground" Value="#232323" />
</Style>
</Style.Resources>
</Style>
</Style.Resources>
</Style>

<Style x:Key="StartPageListBox" TargetType="ListBox">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="OverridesDefaultStyle" Value="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,40 @@ public PackageUploadRequestBody BaseVersionHeader
}
}

private bool isWarningEnabled;
/// <summary>
/// This flag will be in true when the Style that user is trying to add already exists (otherwise will be false - Default)
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
public bool IsWarningEnabled
{
get
{
return isWarningEnabled;
}
set
{
isWarningEnabled = value;
RaisePropertyChanged(nameof(IsWarningEnabled));
}
}

private string currentWarningMessage;
/// <summary>
/// This property will hold the warning message that has to be shown in the warning icon next to the TextBox
/// </summary>
public string CurrentWarningMessage
{
get
{
return currentWarningMessage;
}
set
{
currentWarningMessage = value;
RaisePropertyChanged(nameof(CurrentWarningMessage));
}
}

#endregion

internal PublishPackageViewModel()
Expand Down Expand Up @@ -770,6 +804,8 @@ public PublishPackageViewModel( DynamoViewModel dynamoViewModel ) : this()
{
this.dynamoViewModel = dynamoViewModel;
KnownHosts = initializeHostSelections();
//By Default the warning state of the Visual Settings tab (Group Styles section) will be disabled
isWarningEnabled = false;
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
}

private void ClearAllEntries()
Expand Down Expand Up @@ -1723,11 +1759,16 @@ private bool CanPublishLocally()

private bool CheckPackageValidity()
{
if (Name.Contains(@"\") || Name.Contains(@"/") || Name.Contains(@"*"))
if (Search.SearchDictionary<object>.ContainsSpecialCharacters(Name))
{
ErrorString = Resources.PackageNameCannotContainTheseCharacters;
ErrorString = Resources.PackageNameCannotContainTheseCharacters + " " + new String(Search.SearchDictionary<object>.SpecialAndInvalidCharacters());
EnableGroupStyleWarningState(ErrorString);
return false;
}
else
{
IsWarningEnabled = false;
}

if (Name.Length < 3)
{
Expand Down Expand Up @@ -1777,6 +1818,15 @@ private bool CheckPackageValidity()

return true;
}
}

/// <summary>
/// This method will enable the warning icon next to the GroupName TextBox and other buttons needed
/// </summary>
/// <param name="warningMessage">Message that will be displayed when the mouse is over the warning</param>
internal void EnableGroupStyleWarningState(string warningMessage)
{
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
CurrentWarningMessage = warningMessage;
IsWarningEnabled = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<ui:SharedResourceDictionary Source="{x:Static ui:SharedDictionaryManager.DynamoColorsAndBrushesDictionaryUri}" />
</ResourceDictionary.MergedDictionaries>
<controls:EmptyStringToFalseConverter x:Key="EmptyStringToFalseConverter" />
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
<Grid Height="29px"
HorizontalAlignment="Stretch"
Expand Down Expand Up @@ -419,7 +420,7 @@
</TextBlock.ToolTip>
</TextBlock>
<TextBox Name="packageNameInput"
Style="{StaticResource InputStyle}"
Style="{StaticResource InputStyleWithIcon}"
Tag="{x:Static p:Resources.PublishPackageViewPackageNameWatermark}"
IsEnabled ="{Binding Path=CanEditName}"
Text="{Binding Path=Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Expand Down