From 19052576f7fc11ebe11e5439b36cae75b376cd3d Mon Sep 17 00:00:00 2001 From: Roberto T Date: Fri, 8 Dec 2023 10:45:30 -0600 Subject: [PATCH] DYN-6524 Packages Tour Regression I did several updates for the Packages guide: I've splitted the functionality of collapseExpandPackage so now we will have one method for collapse and another one for expand, so the function collapseExpandPackage was renamed to expandPackageDiv. Some Steps in the dynamo_guides.json were modified to stick to the functionality of expanding the package when passing from Step8 to Step9. Finally I added a validation in the function that highlight a div so if the div is already highlighted when we don't add the functionality ( this will prevent showing the orange rectangle when closing the guide ). --- .../DocumentationBrowserViewModel.cs | 2 +- .../UI/GuidedTour/GuidesValidationMethods.cs | 46 +++++++++++++--- .../UI/GuidedTour/dynamo_guides.json | 52 +++++++++---------- .../web/library/library.html | 20 ++++++- 4 files changed, 84 insertions(+), 36 deletions(-) diff --git a/src/DocumentationBrowserViewExtension/DocumentationBrowserViewModel.cs b/src/DocumentationBrowserViewExtension/DocumentationBrowserViewModel.cs index 7bcac36b885..4c8a117c9f3 100644 --- a/src/DocumentationBrowserViewExtension/DocumentationBrowserViewModel.cs +++ b/src/DocumentationBrowserViewExtension/DocumentationBrowserViewModel.cs @@ -482,7 +482,7 @@ internal void CollapseExpandPackage(string section) object[] jsParameters = new object[] { breadBrumbsArray[i], sectionType, "true" }; //Create the array for the paramateres that will be sent to the WebBrowser.InvokeScript Method - object[] parametersInvokeScript = new object[] { "collapseExpandPackage", jsParameters }; + object[] parametersInvokeScript = new object[] { "expandPackageDiv", jsParameters }; ResourceUtilities.ExecuteJSFunction(DynamoView, parametersInvokeScript); diff --git a/src/DynamoCoreWpf/UI/GuidedTour/GuidesValidationMethods.cs b/src/DynamoCoreWpf/UI/GuidedTour/GuidesValidationMethods.cs index 64c4dbc95fd..398b65c4254 100644 --- a/src/DynamoCoreWpf/UI/GuidedTour/GuidesValidationMethods.cs +++ b/src/DynamoCoreWpf/UI/GuidedTour/GuidesValidationMethods.cs @@ -14,6 +14,7 @@ using Dynamo.PackageManager.ViewModels; using Dynamo.Utilities; using Dynamo.ViewModels; +using Dynamo.Wpf.ViewModels.GuidedTour; using Dynamo.Wpf.Views.GuidedTour; using Newtonsoft.Json.Linq; using static Dynamo.PackageManager.PackageManagerSearchViewModel; @@ -495,18 +496,30 @@ internal static void SubscribeNextButtonClickEvent(Step stepInfo, StepUIAutomati /// Event Arguments internal void ExecuteAutomaticPackage_Click(object sender, RoutedEventArgs e) { - CollapseExpandPackage(CurrentExecutingStep); + var nextButton = (sender as Button); + if (nextButton == null) return; + + var popupVM = (nextButton.DataContext as PopupWindowViewModel); + if(popupVM == null) return; + + if (popupVM.Step == null) return; + ExpandPackage(popupVM.Step); } /// - /// This method will call the collapseExpandPackage javascript method with reflection, so the package expander in LibraryView will be clicked + /// This method will call the expandPackageDiv javascript method with reflection, so the package expander in LibraryView will be clicked /// - internal static void CollapseExpandPackage(Step stepInfo) + internal static void ExpandPackage(Step stepInfo) { - CurrentExecutingStep = stepInfo; - var firstUIAutomation = stepInfo.UIAutomation.FirstOrDefault(); - if (firstUIAutomation == null || firstUIAutomation.JSParameters.Count == 0) return; - object[] parametersInvokeScript = new object[] { firstUIAutomation.JSFunctionName, new object[] { firstUIAutomation.JSParameters.FirstOrDefault() } }; + var expandUIAutomation = stepInfo.UIAutomation.Where(automation => automation.JSFunctionName == "expandPackageDiv").FirstOrDefault(); + if (expandUIAutomation == null || expandUIAutomation.JSParameters.Count == 0) return; + + //Expand the Sample Package Div when clicking the next button in Step8 + object[] parametersInvokeScript = new object[] { expandUIAutomation.JSFunctionName, new object[] { expandUIAutomation.JSParameters[0], expandUIAutomation.JSParameters[1] } }; + ResourceUtilities.ExecuteJSFunction(stepInfo.MainWindow, stepInfo.HostPopupInfo, parametersInvokeScript); + + //Expand the Package nodes when clicking the next button in Step8 + parametersInvokeScript = new object[] { expandUIAutomation.JSFunctionName, new object[] { "Examples", "LibraryItemGroupText" } }; ResourceUtilities.ExecuteJSFunction(stepInfo.MainWindow, stepInfo.HostPopupInfo, parametersInvokeScript); } @@ -976,5 +989,24 @@ private static void RunButton_Click(object sender, RoutedEventArgs e) { CurrentExecutingGuide.NextStep(CurrentExecutingStep.Sequence); } + + /// + /// In the the Package is expanded this method will call a js method that will collapse the
+ ///
+ internal static void CollapsePackageDiv(Step stepInfo, StepUIAutomation uiAutomationData, bool enableFunction, GuideFlow currentFlow) + { + CurrentExecutingStep = stepInfo; + if (uiAutomationData == null) return; + string jsFunctionName = uiAutomationData.JSFunctionName; + //Create the array for the paramateres that will be sent to the WebBrowser.InvokeScript Method + object[] parametersInvokeScript = new object[] { jsFunctionName, new object[] { uiAutomationData.JSParameters[0], uiAutomationData.JSParameters[1] } }; + + //Only will be executed when entering to the Step8 (when leaving Step8 the div should be expanded) + if(enableFunction == true) + { + //Execute the JS function with the provided parameters + ResourceUtilities.ExecuteJSFunction(CurrentExecutingStep.MainWindow, CurrentExecutingStep.HostPopupInfo, parametersInvokeScript); + } + } } } diff --git a/src/DynamoCoreWpf/UI/GuidedTour/dynamo_guides.json b/src/DynamoCoreWpf/UI/GuidedTour/dynamo_guides.json index 869720dc659..c3169509f68 100644 --- a/src/DynamoCoreWpf/UI/GuidedTour/dynamo_guides.json +++ b/src/DynamoCoreWpf/UI/GuidedTour/dynamo_guides.json @@ -738,10 +738,18 @@ { "Sequence": 1, "ControlType": "function", + "Name": "CollapsePackageDiv", + "JSFunctionName": "collapsePackageDiv", + "JSParameters": [ "SampleLibraryUI", "LibraryItemText" ], + "Action": "execute" + }, + { + "Sequence": 2, + "ControlType": "function", "WindowName": "PopupWindow", "Name": "SubscribeNextButtonClickEvent", "Action": "execute", - "JSFunctionName": "collapseExpandPackage", + "JSFunctionName": "expandPackageDiv", "JSParameters": [ "SampleLibraryUI", "LibraryItemText" ], "AutomaticHandlers": [ { @@ -752,7 +760,7 @@ ] }, { - "Sequence": 2, + "Sequence": 3, "ControlType": "JSFunction", "Name": "InvokeJSFunction", "JSFunctionName": "setOverlay", @@ -760,7 +768,7 @@ "Action": "execute" }, { - "Sequence": 3, + "Sequence": 4, "ControlType": "JSFunction", "Name": "InvokeJSFunction", "JSFunctionName": "subscribePackageClickedEvent", @@ -768,7 +776,7 @@ "Action": "execute" }, { - "Sequence": 4, + "Sequence": 5, "ControlType": "JSFunction", "Name": "InvokeJSFunction", "JSFunctionName": "getDocumentClientRect", @@ -776,7 +784,7 @@ "Action": "execute" }, { - "Sequence": 5, + "Sequence": 6, "ControlType": "function", "Name": "LibraryScrollToBottom", "JSFunctionName": "scrollToBottom", @@ -784,7 +792,7 @@ "Action": "execute" }, { - "Sequence": 6, + "Sequence": 7, "ControlType": "function", "Name": "CalculateLibraryItemLocation", "JSFunctionName": "getDocumentClientRect", @@ -821,36 +829,28 @@ }, "UIAutomation": [ { - "Sequence": 0, + "Sequence": 1, "ControlType": "JSFunction", "Name": "InvokeJSFunction", "JSFunctionName": "setOverlay", "JSParameters": [], "Action": "execute" }, - { - "Sequence": 1, - "ControlType": "JSFunction", - "Name": "InvokeJSFunction", - "Action": "execute", - "JSFunctionName": "collapseExpandPackage", - "JSParameters": [ "SampleLibraryUI", "LibraryItemText" ] - }, { "Sequence": 2, - "ControlType": "JSFunction", - "Name": "InvokeJSFunction", - "Action": "execute", - "JSFunctionName": "collapseExpandPackage", - "JSParameters": [ "Examples", "LibraryItemGroupText" ] - }, - { - "Sequence": 3, "ControlType": "function", "Name": "LibraryScrollToBottom", "JSFunctionName": "scrollToBottom", "JSParameters": [], "Action": "execute" + }, + { + "Sequence": 3, + "ControlType": "JSFunction", + "Name": "InvokeJSFunction", + "JSFunctionName": "expandPackageDiv", + "JSParameters": [ "Examples", "LibraryItemGroupText" ], + "Action": "execute" } ] }, @@ -998,7 +998,7 @@ "WindowName": "LibraryView", "Name": "InvokeJSFunction", "Action": "execute", - "JSFunctionName": "collapseExpandPackage", + "JSFunctionName": "expandPackageDiv", "JSParameters": [ "Geometry", "LibraryItemText" ] }, { @@ -1007,7 +1007,7 @@ "WindowName": "LibraryView", "Name": "InvokeJSFunction", "Action": "execute", - "JSFunctionName": "collapseExpandPackage", + "JSFunctionName": "expandPackageDiv", "JSParameters": [ "Abstract", "LibraryItemGroupText" ] }, { @@ -1016,7 +1016,7 @@ "WindowName": "LibraryView", "Name": "InvokeJSFunction", "Action": "execute", - "JSFunctionName": "collapseExpandPackage", + "JSFunctionName": "expandPackageDiv", "JSParameters": [ "CoordinateSystem", "LibraryItemGroupText" ] }, { diff --git a/src/LibraryViewExtensionWebView2/web/library/library.html b/src/LibraryViewExtensionWebView2/web/library/library.html index 9ef8ff96b91..df164952b10 100644 --- a/src/LibraryViewExtensionWebView2/web/library/library.html +++ b/src/LibraryViewExtensionWebView2/web/library/library.html @@ -249,7 +249,11 @@ } if (found_div != null) { if (enableHighlight == true) { - glowAnimation(found_div, true); + //Validates that the div is not already highlighted + var currentAttibute = found_div.getAttribute("id"); + if (currentAttibute == null || !currentAttibute.includes("glow_")) { + glowAnimation(found_div, true); + } } else { glowAnimation(found_div, false); @@ -307,7 +311,7 @@ } //This will execute a click over a specific
that contains the package content - function collapseExpandPackage(packageName, libraryClassName) { + function expandPackageDiv(packageName, libraryClassName) { var found_div = findPackageDiv(packageName, libraryClassName); if (found_div == null) { return; @@ -319,6 +323,18 @@ } } + function collapsePackageDiv(packageName, libraryClassName) { + var found_div = findPackageDiv(packageName, libraryClassName); + if (found_div == null) { + return; + } + var containerCatDiv = found_div.parentNode.parentNode; + var itemBodyContainer = containerCatDiv.getElementsByClassName(libraryClassName)[0]; + if (itemBodyContainer.parentElement.parentElement.className.includes('expanded')) { + itemBodyContainer.click(); + } + } + //This will call the NextStep() function located in the LibraryViewController function nextStepInGuide() { window.chrome.webview.postMessage(JSON.stringify({ "func": "NextStep", "data": "" }));