Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into loc-…
Browse files Browse the repository at this point in the history
…fix-3
  • Loading branch information
zeusongit committed Jan 11, 2024
2 parents 52f1016 + 06ac24b commit e8ee660
Show file tree
Hide file tree
Showing 19 changed files with 644 additions and 76 deletions.
15 changes: 3 additions & 12 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

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

11 changes: 4 additions & 7 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ Don't worry, you'll have the option to save your work.</value>
<comment>Setting menu | Decimal inch</comment>
</data>
<data name="DynamoViewSettingMenuShowDataReportingDialog" xml:space="preserve">
<value>Agreement and _Terms of Use</value>
<value>Agreements for _Data Collection</value>
<comment>Dynamo menu | Show user agreement dialog about data collecting</comment>
</data>
<data name="DynamoViewSettingMenuFractionalFoot" xml:space="preserve">
Expand Down Expand Up @@ -2220,10 +2220,10 @@ Installing the latest update requires Dynamo and any host applications to close.
Do you want to install the latest Dynamo update?</value>
</data>
<data name="UsageReportPromptDialogTitle" xml:space="preserve">
<value>Agreement and Terms of Use</value>
<value>Agreements for Data Collection</value>
</data>
<data name="AgreeToMLAutocompleteTOUText" xml:space="preserve">
<value>I would like to participate in data collection</value>
<value>I would like to participate in data collection for Machine Learning Programs</value>
</data>
<data name="UseLevelKeepListStructureHint" xml:space="preserve">
<value>Keep 1 input list's nesting</value>
Expand Down Expand Up @@ -2315,9 +2315,6 @@ Uninstall the following packages: {0}?</value>
<data name="PackageSearchViewFilterByButton" xml:space="preserve">
<value>Filter by</value>
</data>
<data name="DynamoViewSettingMenuShowDataReportingDialogTooltip" xml:space="preserve">
<value>Display the dialog of agreement on data collecting and Machine Learning Node Autocomplete terms of use</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="psDynamoMesh" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\ViewModels\Watch3D\compiledShaders\psDynamoMesh;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
Expand Down Expand Up @@ -3882,4 +3879,4 @@ In certain complex graphs or host program scenarios, Automatic mode may cause in
<data name="GESUnitMillimeters" xml:space="preserve">
<value>Millimeters</value>
</data>
</root>
</root>
11 changes: 4 additions & 7 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@
<comment>Setting menu | Decimal inch</comment>
</data>
<data name="DynamoViewSettingMenuShowDataReportingDialog" xml:space="preserve">
<value>Agreement and _Terms of Use</value>
<value>Agreements for _Data Collection</value>
<comment>Dynamo menu | Show user agreement dialog about data collecting</comment>
</data>
<data name="DynamoViewSettingShowRunPreview" xml:space="preserve">
Expand Down Expand Up @@ -1151,10 +1151,10 @@ Don't worry, you'll have the option to save your work.</value>
<value>Cancel</value>
</data>
<data name="UsageReportPromptDialogTitle" xml:space="preserve">
<value>Agreement and Terms of Use</value>
<value>Agreements for Data Collection</value>
</data>
<data name="AgreeToMLAutocompleteTOUText" xml:space="preserve">
<value>I would like to participate in data collection</value>
<value>I would like to participate in data collection for Machine Learning Programs</value>
</data>
<data name="DynamoViewContextMenuClearLog" xml:space="preserve">
<value>Clear</value>
Expand Down Expand Up @@ -2605,9 +2605,6 @@ Uninstall the following packages: {0}?</value>
<data name="PackageSearchViewFilterByButton" xml:space="preserve">
<value>Filter by</value>
</data>
<data name="DynamoViewSettingMenuShowDataReportingDialogTooltip" xml:space="preserve">
<value>Display the dialog of agreement on data collecting and Machine Learning Node Autocomplete terms of use</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="psDynamoMesh" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\ViewModels\Watch3D\compiledShaders\psDynamoMesh;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
Expand Down Expand Up @@ -3869,4 +3866,4 @@ In certain complex graphs or host program scenarios, Automatic mode may cause in
<data name="GESUnitMillimeters" xml:space="preserve">
<value>Millimeters</value>
</data>
</root>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ internal void DisplayMachineLearningResults()

if (viewModelElement != null)
{
viewModelElement.AutoCompletionNodeMachineLearningInfo = new AutoCompletionNodeMachineLearningInfo(true, true, result.Score * 100);
viewModelElement.AutoCompletionNodeMachineLearningInfo = new AutoCompletionNodeMachineLearningInfo(true, true, Math.Round(result.Score * 100));
results.Add(viewModelElement);
}
}
Expand Down Expand Up @@ -407,7 +407,7 @@ internal void DisplayMachineLearningResults()

if (viewModelElement != null)
{
viewModelElement.AutoCompletionNodeMachineLearningInfo = new AutoCompletionNodeMachineLearningInfo(true, true, result.Score * 100);
viewModelElement.AutoCompletionNodeMachineLearningInfo = new AutoCompletionNodeMachineLearningInfo(true, true, Math.Round(result.Score * 100));
results.Add(viewModelElement);
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,6 @@
Command="{Binding Path=ToggleIsAnalyticsReportingApprovedCommand, Source={x:Static service:UsageReportingManager.Instance} }"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}}"
Visibility="{Binding HideReportOptions, Converter={StaticResource InverseBoolToVisibilityCollapsedConverter}}">
<MenuItem.ToolTip>
<ToolTip Content="{x:Static p:Resources.DynamoViewSettingMenuShowDataReportingDialogTooltip}" Style="{StaticResource GenericToolTipLight}"/>
</MenuItem.ToolTip>
</MenuItem>
<Separator />
<MenuItem Header="{x:Static p:Resources.DynamoViewDynamoMenuPreferences}"
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoPackages/PackageManagerSearchElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public int Votes
public string LatestVersion { get { return Header.versions != null ? Header.versions[Header.versions.Count - 1].version : String.Empty; } }
public string LatestVersionCreated { get { return Header.versions[Header.versions.Count - 1].created; } }

public IEnumerable<string> PackageVersions { get { return Header.versions.Select(x => x.version); } }
public IEnumerable<string> PackageVersions { get { return Header.versions.OrderByDescending(x => x.version).Select(x => x.version); } }

/// <summary>
/// Hosts dependencies specified for latest version of particular package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static void RenameFile(string file)

private static void RenameFile(string file, string baseName, string shortName)
{
var content = File.ReadAllText(file);
var content = HttpUtility.UrlDecode(File.ReadAllText(file));
content = content.Replace(baseName, shortName);
var path = Path.GetDirectoryName(file);
var newFile = Path.Combine(path, shortName + ".md");
Expand Down
21 changes: 18 additions & 3 deletions test/Libraries/SystemTestServices/SystemTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ protected virtual void StartDynamo(TestSessionConfiguration testConfig)
StartInTestMode = true,
PathResolver = pathResolver,
GeometryFactoryPath = preloader.GeometryFactoryPath,
ProcessMode = TaskProcessMode.Synchronous
ProcessMode = TaskProcessMode.Synchronous,
DynamoCorePath = testConfig.DynamoCorePath
});

ViewModel = DynamoViewModel.Start(
Expand Down Expand Up @@ -305,15 +306,29 @@ public void AssertPreviewCount(string guid, int count)
Assert.AreEqual(count, data.GetElements().ToList().Count);
}

public NodeModel GetNode<T>(string guid) where T : NodeModel
/// <summary>
/// Returns the NodeModel corresponding to the input guid
/// </summary>
/// <typeparam name="T">A NodeModel (or derived) type</typeparam>
/// <param name="guid">The node Guid</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
[Obsolete("This method will be removed in a future version of Dynamo")]
public NodeModel GetNode<T>(string guid) where T : class
{
bool isNodeModel = typeof(T) == typeof(NodeModel);
bool isDerivedFromNodeModel = typeof(T).IsSubclassOf(typeof(NodeModel));
if ( !isNodeModel && !isDerivedFromNodeModel)
{
throw new Exception($"{typeof(T)} is not of type NodeModel");
}
var allNodes = ViewModel.Model.CurrentWorkspace.Nodes;
var nodes = allNodes.Where(x => string.CompareOrdinal(x.GUID.ToString(), guid) == 0);
if (nodes.Count() < 1)
return null;
else if (nodes.Count() > 1)
throw new Exception("There are more than one nodes with the same GUID!");
return nodes.ElementAt(0) as T;
return nodes.ElementAt(0);
}

public object GetPreviewValue(string guid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,62 @@ public void CanRenameFile()
Assert.IsTrue(content.Contains("CoreNodeModels.HigherOrder.Map"));
}

[Test]
public void CanRenameFileLongName()
{
// Arrange
var originalOutDirName = "fallback_docs";
var filesDirectory = "LongNameFiles";
var emptySpaceChar = "%20";
var originalOutDir = new DirectoryInfo(Path.Combine(toolsTestFilesDirectory, originalOutDirName, filesDirectory));

tempDirectory = CreateTempOutputDirectory();
Assert.That(tempDirectory.Exists);

CopyFilesRecursively(originalOutDir, tempDirectory);

var originalMdFile = tempDirectory.GetFiles("*.md", SearchOption.TopDirectoryOnly)
.Select(x => x.Name).FirstOrDefault();
Assert.IsNotNull(originalMdFile);

//Check that the original MD file contains space characters URL encoded
var originalMdFileContent = Path.Combine(tempDirectory.FullName, originalMdFile);
Assert.IsTrue(File.ReadAllText(originalMdFileContent).Contains(emptySpaceChar));

// Act
var opts = new RenameOptions
{
InputMdDirectory = tempDirectory.FullName,
MaxLength = 90
};

//Rename all the files in the temp directory
RenameCommand.HandleRename(opts);

// Assert
var finalMdFile = tempDirectory.GetFiles("*.md", SearchOption.TopDirectoryOnly)
.Select(x => x.Name).FirstOrDefault();
Assert.IsNotNull(finalMdFile);

var hashedName = Path.GetFileNameWithoutExtension(finalMdFile);

//Validates that all the renamed files start with the hashed name
var allFiles = tempDirectory.GetFiles("*.*", SearchOption.TopDirectoryOnly).Select(x => x.Name);
foreach(var file in allFiles)
{
Assert.IsTrue(file.StartsWith(hashedName));
}

//Get the image file name renamed
var imageFile = tempDirectory.GetFiles("*.jpg", SearchOption.TopDirectoryOnly)
.Select(x => x.Name).FirstOrDefault();
Assert.IsNotNull(imageFile);

//Validates that the image file name is present inside the md file content.
var finalMdFileContent = Path.Combine(tempDirectory.FullName, finalMdFile);
Assert.IsTrue(File.ReadAllText(finalMdFileContent).Contains(imageFile));
}

[Test]
public void CanRenameFilesInADirectory()
{
Expand Down
Loading

0 comments on commit e8ee660

Please sign in to comment.