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-6524 Packages Tour Regression #14721

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
46 changes: 39 additions & 7 deletions src/DynamoCoreWpf/UI/GuidedTour/GuidesValidationMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -495,18 +496,30 @@ internal static void SubscribeNextButtonClickEvent(Step stepInfo, StepUIAutomati
/// <param name="e">Event Arguments</param>
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);
}

/// <summary>
/// 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
/// </summary>
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);
}

Expand Down Expand Up @@ -976,5 +989,24 @@ private static void RunButton_Click(object sender, RoutedEventArgs e)
{
CurrentExecutingGuide.NextStep(CurrentExecutingStep.Sequence);
}

/// <summary>
/// In the the Package is expanded this method will call a js method that will collapse the <div></div>
/// </summary>
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);
}
}
}
}
52 changes: 26 additions & 26 deletions src/DynamoCoreWpf/UI/GuidedTour/dynamo_guides.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand All @@ -752,39 +760,39 @@
]
},
{
"Sequence": 2,
"Sequence": 3,
"ControlType": "JSFunction",
"Name": "InvokeJSFunction",
"JSFunctionName": "setOverlay",
"JSParameters": [],
"Action": "execute"
},
{
"Sequence": 3,
"Sequence": 4,
"ControlType": "JSFunction",
"Name": "InvokeJSFunction",
"JSFunctionName": "subscribePackageClickedEvent",
"JSParameters": [ "SampleLibraryUI" ],
"Action": "execute"
},
{
"Sequence": 4,
"Sequence": 5,
"ControlType": "JSFunction",
"Name": "InvokeJSFunction",
"JSFunctionName": "getDocumentClientRect",
"JSParameters": [ "SampleLibraryUI" ],
"Action": "execute"
},
{
"Sequence": 5,
"Sequence": 6,
"ControlType": "function",
"Name": "LibraryScrollToBottom",
"JSFunctionName": "scrollToBottom",
"JSParameters": [],
"Action": "execute"
},
{
"Sequence": 6,
"Sequence": 7,
"ControlType": "function",
"Name": "CalculateLibraryItemLocation",
"JSFunctionName": "getDocumentClientRect",
Expand Down Expand Up @@ -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"
}
]
},
Expand Down Expand Up @@ -998,7 +998,7 @@
"WindowName": "LibraryView",
"Name": "InvokeJSFunction",
"Action": "execute",
"JSFunctionName": "collapseExpandPackage",
"JSFunctionName": "expandPackageDiv",
"JSParameters": [ "Geometry", "LibraryItemText" ]
},
{
Expand All @@ -1007,7 +1007,7 @@
"WindowName": "LibraryView",
"Name": "InvokeJSFunction",
"Action": "execute",
"JSFunctionName": "collapseExpandPackage",
"JSFunctionName": "expandPackageDiv",
"JSParameters": [ "Abstract", "LibraryItemGroupText" ]
},
{
Expand All @@ -1016,7 +1016,7 @@
"WindowName": "LibraryView",
"Name": "InvokeJSFunction",
"Action": "execute",
"JSFunctionName": "collapseExpandPackage",
"JSFunctionName": "expandPackageDiv",
"JSParameters": [ "CoordinateSystem", "LibraryItemGroupText" ]
},
{
Expand Down
20 changes: 18 additions & 2 deletions src/LibraryViewExtensionWebView2/web/library/library.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -307,7 +311,7 @@
}

//This will execute a click over a specific <div> that contains the package content
function collapseExpandPackage(packageName, libraryClassName) {
function expandPackageDiv(packageName, libraryClassName) {
var found_div = findPackageDiv(packageName, libraryClassName);
if (found_div == null) {
return;
Expand All @@ -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": "" }));
Expand Down
Loading