Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into definedata-view
Browse files Browse the repository at this point in the history
  • Loading branch information
dnenov committed Mar 15, 2024
2 parents 0dd95d3 + 1c6a6ea commit 9e01e51
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/Utilities/CompactBubbleHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static CompactBubbleViewModel Process(MirrorData value)
{
items = 0;
var viewModel = ProcessThing(value, true);
viewModel.SetObjectType(value.Data);
viewModel.SetObjectType(value?.Data);
viewModel.NumberOfItems = items;

return viewModel;
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/ViewModels/Core/AnnotationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ public AnnotationViewModel(WorkspaceViewModel workspaceViewModel, AnnotationMode

ViewModelBases = this.WorkspaceViewModel.GetViewModelsInternal(annotationModel.Nodes.Select(x => x.GUID));

// Add all grouped AnnotaionModels to the CutGeometryDictionary.
// Add all grouped AnnotationModels to the CutGeometryDictionary.
// And raise ZIndex changed to make sure nested groups have
// a higher zIndex than the parent.
using (NestedGroupsGeometries.DeferCollectionReset())
Expand Down
2 changes: 2 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,8 @@ private void Open(object parameters)
commandString,
MessageBoxButton.OK,
MessageBoxImage.Error);

this.ShowStartPage = true; // Triggers start page change to notify the frontend
}
else
{
Expand Down
6 changes: 4 additions & 2 deletions src/DynamoCoreWpf/ViewModels/Core/StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ internal bool HandleMouseRelease(object sender, MouseButtonEventArgs e)
.ToList();

// AddModelsToGroupModelCommand adds models to the selected group
// therefor we add the dropGroup to the selection before calling
// therefore we add the dropGroup to the selection before calling
// the command.
DynamoSelection.Instance.Selection.AddUnique(dropGroup.AnnotationModel);

Expand Down Expand Up @@ -794,7 +794,9 @@ internal bool HandleMouseRelease(object sender, MouseButtonEventArgs e)
owningWorkspace.DynamoViewModel.AddModelsToGroupModelCommand.Execute(null);
}
dropGroup.NodeHoveringState = false;
dropGroup.SelectAll();
//select only those models which were added to the group
DynamoSelection.Instance.ClearSelection();
DynamoSelection.Instance.Selection.AddRange(modelsToAdd);
}

SetCurrentState(State.None); // Dragging operation ended.
Expand Down
17 changes: 4 additions & 13 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1791,24 +1791,15 @@
</ItemsControl.Visibility>
</ItemsControl>
</Grid>
<!--Do not delete newHomePageContainer grid as it is hosting the HomePage-->
<Grid x:Name="newHomePageContainer"
Visibility="{Binding IsNewAppHomeEnabled,
Converter={StaticResource BooleanToVisibilityConverter},
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
Converter={StaticResource BooleanToVisibilityConverter},
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
Grid.Row="2"
Grid.RowSpan="4"
Grid.Column="0"
Grid.ColumnSpan="5">
<uiviews:HomePage x:Name="homePage">
<uiviews:HomePage.Visibility>
<Binding Path="DataContext.ShowStartPage"
Mode="OneWay"
RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type controls:DynamoView}}"
Converter="{StaticResource BooleanToVisibilityConverter}"
UpdateSourceTrigger="Explicit" />
</uiviews:HomePage.Visibility>
</uiviews:HomePage>
</Grid>
Grid.ColumnSpan="5"/>

<Grid Name="FocusableGrid" Width="0" Height="0" Focusable="True"/>
</Grid>
Expand Down
42 changes: 40 additions & 2 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ internal PreferencesView PreferencesWindow {
get { return preferencesWindow; }
}

internal Dynamo.UI.Views.HomePage homePage;

/// <summary>
/// Keeps the default value of the Window's MinWidth to calculate it again later
/// </summary>
Expand Down Expand Up @@ -1208,7 +1210,6 @@ private void InitializeStartPage(bool isFirstRun)

startPage = new StartPageViewModel(dynamoViewModel, isFirstRun);
startPageItemsControl.Items.Add(startPage);
homePage.DataContext = startPage;
}
}

Expand Down Expand Up @@ -1383,9 +1384,36 @@ private void DynamoView_Loaded(object sender, EventArgs e)
{
this.Deactivated += (s, args) => { HidePopupWhenWindowDeactivated(null); };
}

// Load the new HomePage
if (IsNewAppHomeEnabled) LoadHomePage();

loaded = true;
}

// Add the HomePage to the DynamoView once its loaded
private void LoadHomePage()
{
if (homePage == null && startPage != null)
{
homePage = new UI.Views.HomePage();
homePage.DataContext = startPage;

var visibilityBinding = new System.Windows.Data.Binding
{
RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(DynamoView), 1),
Path = new PropertyPath("DataContext.ShowStartPage"),
Mode = BindingMode.OneWay,
Converter = new BooleanToVisibilityConverter(),
UpdateSourceTrigger = UpdateSourceTrigger.Explicit
};

BindingOperations.SetBinding(homePage, UIElement.VisibilityProperty, visibilityBinding);

this.newHomePageContainer.Children.Add(homePage);
}
}

/// <summary>
/// Assign the value to the toolBarRightMenuWidth when the ShortcutToolbar is loaded
/// </summary>
Expand Down Expand Up @@ -2021,14 +2049,24 @@ private void WindowClosed(object sender, EventArgs e)
this.dynamoViewModel.RequestExportWorkSpaceAsImage -= OnRequestExportWorkSpaceAsImage;
this.dynamoViewModel.RequestShorcutToolbarLoaded -= onRequestShorcutToolbarLoaded;

this.homePage.Dispose();
if (homePage != null)
{
RemoveHomePage();
}

this.Dispose();
sharedViewExtensionLoadedParams?.Dispose();
this._pkgSearchVM?.Dispose();
this._pkgVM?.Dispose();
}

// Remove the HomePage from the visual tree and dispose of its resources
private void RemoveHomePage()
{
this.newHomePageContainer.Children.Remove(homePage);
this.homePage.Dispose();
}

// the key press event is being intercepted before it can get to
// the active workspace. This code simply grabs the key presses and
// passes it to thecurrent workspace
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/Views/Core/NoteView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ private string BulletDashHandler( string text, int caretIndex)
// dont convert it to bullet
bool lineContainsBullet = BULLETS_CHARS.Where(b => line.Contains(b)).Any();
var textBeforeCaret = line.Substring(0, caretAtLine);
if (!StringUtils.IsStringSpacesWithTabs(textBeforeCaret)&& !lineContainsBullet)
if (!StringUtils.IsStringSpacesWithTabs(textBeforeCaret) || lineContainsBullet)
{
line = line.Insert(caretAtLine, "-");
return StringUtils.ReplaceLineOfText(text, lineNumber, line);
Expand Down
1 change: 1 addition & 0 deletions src/LibraryViewExtensionWebView2/LibraryViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ internal void RefreshLibraryView(WebView2 browser)
/// <param name="text">text to be added to clipboard</param>
internal void OnCopyToClipboard(string text)
{
dynamoViewModel.Model.ClipBoard.Clear();
Clipboard.SetText(text);
}

Expand Down
3 changes: 3 additions & 0 deletions src/Notifications/NotificationCenterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ private void WebView_NavigationCompleted(object sender, Microsoft.Web.WebView2.C

string setBottomButtonText = String.Format("window.setBottomButtonText('{0}');", Properties.Resources.NotificationsCenterBottomButtonText);
InvokeJS(setBottomButtonText);

string setNoNotificationsTexts = String.Format("window.setNoNotificationsTexts('{{\"title\":\"{0}\", \"msg\":\"{1}\"}}');", Properties.Resources.NoNotificationsTitle, Properties.Resources.NoNotificationsMsg);
InvokeJS(setNoNotificationsTexts);
}

private void AddNotifications(List<NotificationItemModel> notifications)
Expand Down
20 changes: 19 additions & 1 deletion src/Notifications/Properties/Resources.Designer.cs

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

6 changes: 6 additions & 0 deletions src/Notifications/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@
<data name="ExtensionName" xml:space="preserve">
<value>Notifications</value>
</data>
<data name="NoNotificationsMsg" xml:space="preserve">
<value>You currently have no notifications. New notifications will appear above</value>
</data>
<data name="NoNotificationsTitle" xml:space="preserve">
<value>No notifications</value>
</data>
<data name="NotificationCenterDisabledMsg" xml:space="preserve">
<value>Notification Center feature is disabled. Enable it in preference panel to see latest news.</value>
</data>
Expand Down
14 changes: 14 additions & 0 deletions test/DynamoCoreWpfTests/HomePageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ internal static string CONTAINER_ITEM_CLICK_SCRIPT(string elementId)
}})();";
}


[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void CanClickRecentGraph()
{
// Arrange
Expand Down Expand Up @@ -155,6 +157,7 @@ public void CanClickRecentGraph()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void CanClickSampleGraph()
{
// Arrange
Expand Down Expand Up @@ -200,6 +203,7 @@ public void CanClickSampleGraph()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void CanClickTourGuide()
{
// Arrange
Expand Down Expand Up @@ -234,6 +238,7 @@ public void CanClickTourGuide()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void ReceiveCorrectNumberOfRecentGrphs()
{
// Arrange
Expand Down Expand Up @@ -263,6 +268,7 @@ public void ReceiveCorrectNumberOfRecentGrphs()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void ReceiveCorrectNumberOfSamples()
{
// Arrange
Expand Down Expand Up @@ -299,6 +305,7 @@ public void ReceiveCorrectNumberOfSamples()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void ReceiveCorrectNumberOfTourGuides()
{
// Arrange
Expand All @@ -319,6 +326,7 @@ public void ReceiveCorrectNumberOfTourGuides()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void ReceiveCorrectNumberOfCarouselVideos()
{
// Arrange
Expand All @@ -339,6 +347,7 @@ public void ReceiveCorrectNumberOfCarouselVideos()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void CanRunNewHomeWorkspaceCommandFromHomePage()
{
// Arrange
Expand Down Expand Up @@ -376,6 +385,7 @@ void Model_WorkspaceCleared(WorkspaceModel model)
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void CanRunNewCustomNodeCommandFromHomePage()
{
// Arrange
Expand Down Expand Up @@ -408,6 +418,7 @@ public void CanRunNewCustomNodeCommandFromHomePage()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void CanOpenWorkspaceCommandFromHomePage()
{
// Arrange
Expand Down Expand Up @@ -440,6 +451,7 @@ public void CanOpenWorkspaceCommandFromHomePage()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void ShowTemplateCommandFromHomePage()
{
// Arrange
Expand Down Expand Up @@ -473,6 +485,7 @@ public void ShowTemplateCommandFromHomePage()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void ShowBackupFolderCommandFromHomePage()
{
// Arrange
Expand Down Expand Up @@ -505,6 +518,7 @@ public void ShowBackupFolderCommandFromHomePage()
}

[Test]
[Ignore("IsNewAppHomeEnabled flag is set to false")]
public void ShowSampleFilesFolderCommandFromHomePage()
{
// Arrange
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
using Dynamo.Utilities;
using Dynamo.Notifications.View;
using NUnit.Framework;
using System;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using Dynamo.Notifications;
using Dynamo.DocumentationBrowser;
using Dynamo.Notifications.View;
using Dynamo.Utilities;
using DynamoCoreWpfTests.Utility;
using NUnit.Framework;

namespace DynamoCoreWpfTests.ViewExtensions
{
Expand All @@ -28,6 +27,7 @@ public void PressNotificationButtonAndShowPopup()
{
return notificationExtension.notificationCenterController.initState == DynamoUtilities.AsyncMethodState.Done;
});

Assert.AreEqual(DynamoUtilities.AsyncMethodState.Done, notificationExtension.notificationCenterController.initState);

NotificationUI notificationUI = PresentationSource.CurrentSources.OfType<System.Windows.Interop.HwndSource>()
Expand All @@ -37,9 +37,9 @@ public void PressNotificationButtonAndShowPopup()
.OfType<NotificationUI>()
.FirstOrDefault(p => p.IsOpen);

Assert.NotNull(notificationUI);
var webView = notificationUI.FindName("dynWebView");
Assert.NotNull(webView);
Assert.NotNull(notificationUI, "Notification popup not part of the dynamo visual tree");
var webView = notificationUI.FindName("webView");
Assert.NotNull(webView, "WebView framework element not found.");
}

[Test]
Expand Down

0 comments on commit 9e01e51

Please sign in to comment.