Skip to content

Commit

Permalink
DYN-6010 Enable Node Help Docs Sharing DYN files (#14441)
Browse files Browse the repository at this point in the history
* DYN-6010 Enable Node Help Docs Sharing DYN files

The NodeHelpSharedDocs folder already exists then I just modified the DynamoCore.csproj so the dyn files will be copied to the shared folder NodeHelpSharedDocs (then the en-US/fallbacks_docs folder won't contain dyn files anymore).
So when inserting a graph DocumentationBrowser will be using the dyn files stored in the NodeHelpSharedDocs  folder.

* DYN-6010 Enable Node Help Docs Sharing DYN files Code Review

Adding Unit Test that will be validating the result of the GetGraphLinkFromMDLocation( method.
  • Loading branch information
RobertGlobant20 authored Oct 5, 2023
1 parent dbacf52 commit 7f6eb69
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public partial class DocumentationBrowserView : UserControl, IDisposable
internal string WebBrowserUserDataFolder { get; set; }
internal string FallbackDirectoryName { get; set; }
//This folder will be used to store images and dyn files previosuly located in /rootDirectory/en-US/fallback_docs so we don't need to copy all those files per each language
internal const string SharedDocsDirectoryName = "NodeHelpSharedDocs";
internal static readonly string SharedDocsDirectoryName = "NodeHelpSharedDocs";

//Path in which the virtual folder for loading images will be created
internal string VirtualFolderPath { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,9 @@ internal void InsertGraph()
private string DynamoGraphFromMDFilePath(string path)
{
path = HttpUtility.UrlDecode(path);
return Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)) + ".dyn";
var rootLevelDir = Path.GetDirectoryName(path);
var imagesLocation = Path.Combine(new DirectoryInfo(rootLevelDir).Parent.Parent.FullName, DocumentationBrowserView.SharedDocsDirectoryName);
return Path.Combine(imagesLocation, Path.GetFileNameWithoutExtension(path)) + ".dyn";
}


Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCore/DynamoCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
<Copy SourceFiles="$(SolutionDir)..\doc\distrib\InstrumentationConsent.rtf" DestinationFolder="$(OutputPath)" />
<Copy SourceFiles="$(SolutionDir)..\doc\distrib\ADPAnalyticsConsent.rtf" DestinationFolder="$(OutputPath)" />
<Copy SourceFiles="@(NodeHelpMDFiles)" DestinationFolder="$(OutputPath)\en-US\fallback_docs\" />
<Copy SourceFiles="@(NodeHelpDYNFiles)" DestinationFolder="$(OutputPath)\en-US\fallback_docs\" />
<Copy SourceFiles="@(NodeHelpDYNFiles)" DestinationFolder="$(OutputPath)\NodeHelpSharedDocs\" />
<Copy SourceFiles="@(NodeHelpTXTFiles)" DestinationFolder="$(OutputPath)\en-US\fallback_docs\" />
<Copy SourceFiles="@(NodeHelpSATFiles)" DestinationFolder="$(OutputPath)\en-US\fallback_docs\" />
<Copy SourceFiles="@(NodeHelpJpgImageFiles)" DestinationFolder="$(OutputPath)\NodeHelpSharedDocs\" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,44 @@ public void AddGraphInSpecificLocationToWorkspace()
Assert.AreEqual(ViewModel.Model.CurrentWorkspace.Nodes.Count(), 5);
}

[Test]
public void Validate_GetGraphLinkFromMDLocation()
{
var nodeName = "Number";
this.ViewModel.ExecuteCommand(
new DynamoModel.CreateNodeCommand(
Guid.NewGuid().ToString(), nodeName, 0, 0, false, false)
);

//Validates that we have just one node in the CurrentWorkspace
Assert.AreEqual(ViewModel.Model.CurrentWorkspace.Nodes.Count(), 1);

var node = ViewModel.Model.CurrentWorkspace.Nodes.FirstOrDefault();

//In this call the GetGraphLinkFromMDLocation() method is executed internally
RequestNodeDocs(node);

// Show the DocumentationBrowser so we can get the DocumentationBrowserViewModel
ShowDocsBrowser();
var docsView = GetDocsTabItem().Content as DocumentationBrowserView;
var docsViewModel = docsView.DataContext as DocumentationBrowserViewModel;

//Due that graphPath is a private we use reflection to get the value.
FieldInfo type = typeof(DocumentationBrowserViewModel).GetField("graphPath", BindingFlags.NonPublic | BindingFlags.Instance);
var graphPathValue = type.GetValue(docsViewModel);

var dynFileName = Path.GetFileNameWithoutExtension(docsViewModel.Link.AbsolutePath) + ".dyn";

//This will return a path with the NodeHelpSharedDocs + dyn file name
var sharedFilesPath = Path.Combine(DocumentationBrowserView.SharedDocsDirectoryName, dynFileName);

Assert.IsNotNull(graphPathValue);
Assert.IsTrue(!string.IsNullOrEmpty(graphPathValue.ToString()));

//Chech that the pathPath contains "NodeHelpSharedDocs//dynfilename"
Assert.That(graphPathValue.ToString().Contains(sharedFilesPath));
}

#region Helpers

private DocumentationBrowserViewExtension SetupNewViewExtension(bool runLoadedMethod = false)
Expand Down

0 comments on commit 7f6eb69

Please sign in to comment.