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-4794 Run status msg update based on warnings dismiss states #12882

Merged
merged 5 commits into from
May 23, 2022
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
20 changes: 19 additions & 1 deletion src/DynamoCoreWpf/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/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3144,6 +3144,12 @@ To install the latest version of a package, click Install. \n
<data name="OnboardingGuideRunGraphTitle" xml:space="preserve">
<value>Run the graph</value>
</data>
<data name="BubbleDismissAllButtonTooltip" xml:space="preserve">
<value>Temporarily dismiss all warnings of this node.</value>
</data>
<data name="RunCompletedWithWarningsDismissedMessage" xml:space="preserve">
<value>Run completed with dismissed warnings.</value>
</data>
<data name="PackageRepositoryLabel" xml:space="preserve">
<value>Repository</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3131,6 +3131,12 @@ To install the latest version of a package, click Install. \n
<data name="OnboardingGuideRunGraphTitle" xml:space="preserve">
<value>Run the graph</value>
</data>
<data name="BubbleDismissAllButtonTooltip" xml:space="preserve">
<value>Temporarily dismiss all warnings of this node.</value>
</data>
<data name="RunCompletedWithWarningsDismissedMessage" xml:space="preserve">
<value>Run completed with dismissed warnings.</value>
</data>
<data name="PackageRepositoryLabel" xml:space="preserve">
<value>Repository</value>
</data>
Expand Down
57 changes: 48 additions & 9 deletions src/DynamoCoreWpf/ViewModels/Core/HomeWorkspaceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class HomeWorkspaceViewModel : WorkspaceViewModel

#endregion

#region public members
[JsonIgnore]
public NotificationLevel CurrentNotificationLevel
{
Expand All @@ -66,6 +67,30 @@ public string CurrentNotificationMessage
}
}

/// <summary>
/// Boolean indicates if home workspace run with errors
/// </summary>
public bool HasErrors
{
get { return Model.Nodes.Any(n => n.State == ElementState.Error); }
}

/// <summary>
/// Boolean indicates if home workspace is displayed with infos
/// </summary>
public bool HasInfos
{
get { return Model.Nodes.Any(n => n.State == ElementState.Info); }
}

/// <summary>
/// Boolean indicates if home workspace run with warnings
/// </summary>
public bool HasWarnings
{
get { return Model.Nodes.Any(n => n.State == ElementState.Warning || n.State == ElementState.PersistentWarning); }
}

/// <summary>
/// Contains all footer notification item bindings
/// </summary>
Expand All @@ -80,6 +105,8 @@ public ObservableCollection<FooterNotificationItem> FooterNotificationItems
}
}

#endregion

public HomeWorkspaceViewModel(HomeWorkspaceModel model, DynamoViewModel dynamoViewModel)
: base(model, dynamoViewModel)
{
Expand Down Expand Up @@ -225,12 +252,18 @@ void hwm_EvaluationCompleted(object sender, EvaluationCompletedEventArgs e)
//just call it directly
UpdateNodeInfoBubbleContent(e);
}

bool hasInfo = Model.Nodes.Any(n => n.State == ElementState.Info);
bool hasWarnings = Model.Nodes.Any(n => n.State == ElementState.Warning || n.State == ElementState.PersistentWarning);
bool hasErrors = Model.Nodes.Any(n => n.State == ElementState.Error);

if (!hasWarnings && !hasErrors)
UpdateRunStatusMsgBasedOnStates();
UpdateFooterItems(HasInfos, HasWarnings, HasErrors);
}


/// <summary>
/// Update run status message based on error/warning/info states
/// </summary>
internal void UpdateRunStatusMsgBasedOnStates()
{
if (!HasWarnings && !HasErrors)
{
if (Model.ScaleFactorChanged)
{
Expand All @@ -241,15 +274,23 @@ void hwm_EvaluationCompleted(object sender, EvaluationCompletedEventArgs e)
SetCurrentWarning(NotificationLevel.Mild, Properties.Resources.RunCompletedMessage);
}
}
else if(hasWarnings && !hasErrors)
else if (HasWarnings && !HasErrors)
{
if (Model.ScaleFactorChanged)
{
SetCurrentWarning(NotificationLevel.Moderate, Properties.Resources.RunCompletedWithScaleChangeAndWarningsMessage);
}
// If all nodes with warnings dismissed and graph has no errors, update the run status msg
else
{
SetCurrentWarning(NotificationLevel.Moderate, Properties.Resources.RunCompletedWithWarningsMessage);
if (Nodes.All(x => x.ErrorBubble?.DismissedMessages.Count() == x.ErrorBubble?.NodeMessages.Count()))
{
SetCurrentWarning(NotificationLevel.Moderate, Properties.Resources.RunCompletedWithWarningsDismissedMessage);
}
else
{
SetCurrentWarning(NotificationLevel.Moderate, Properties.Resources.RunCompletedWithWarningsMessage);
}
}
}
else
Expand All @@ -263,8 +304,6 @@ void hwm_EvaluationCompleted(object sender, EvaluationCompletedEventArgs e)
SetCurrentWarning(NotificationLevel.Error, Properties.Resources.RunCompletedWithErrorsMessage);
}
}

UpdateFooterItems(hasInfo, hasWarnings, hasErrors);
}

/// <summary>
Expand Down
14 changes: 14 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Preview/InfoBubbleViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using Dynamo.Wpf.ViewModels.Core;

namespace Dynamo.ViewModels
{
Expand Down Expand Up @@ -623,6 +624,7 @@ private void UndismissMessage(object parameter)
DismissedMessages.Remove(DismissedMessages[i]);
}
RefreshNodeInformationalStateDisplay();
ValidateWorkspaceRunStatusMsg();
}


Expand Down Expand Up @@ -985,6 +987,18 @@ private void SetDisplayMessages(List<InfoBubbleDataPacket> infoBubbleDataPackets
for (int i = 0; i < displayMessages.Count; i++) targetCollection.Add(displayMessages[i]);
}

/// <summary>
/// Validate and update workspace run status message
/// </summary>
internal void ValidateWorkspaceRunStatusMsg()
{
// if current workspace is not a home workspace, skip this step
if(DynamoViewModel.CurrentSpaceViewModel.IsHomeSpace)
{
(DynamoViewModel.CurrentSpaceViewModel as HomeWorkspaceViewModel).UpdateRunStatusMsgBasedOnStates();
}
}

/// <summary>
/// Unsubscribes from any events this class is subscribed to.
/// </summary>
Expand Down
6 changes: 5 additions & 1 deletion src/DynamoCoreWpf/Views/Preview/InfoBubbleView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,11 @@
Click="DismissAllWarningsButton_Click"
Content="{x:Static p:Resources.NodeInformationalStateDismissAll}"
Foreground="#0696D7"
Visibility="{Binding ElementName=InfoBubbleWindowUserControl, Path=DataContext.NodeWarningsSectionExpanded, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}" />
Visibility="{Binding ElementName=InfoBubbleWindowUserControl, Path=DataContext.NodeWarningsSectionExpanded, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}" >
<Button.ToolTip>
<ToolTip Content="{x:Static p:Resources.BubbleDismissAllButtonTooltip}" Style="{StaticResource GenericToolTipLight}" />
</Button.ToolTip>
</Button>
<Button Name="ShowAllWarningsButton"
Margin="0,0,10,0"
HorizontalAlignment="Right"
Expand Down
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/Views/Preview/InfoBubbleView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@ private void DismissAllWarningsButton_Click(object sender, RoutedEventArgs e)
// Track dismiss warning event and how many warnings dismissed
Analytics.TrackEvent(Actions.Dismiss, Categories.NodeOperations, "Warning", ViewModel.DismissedMessages.Count);
ViewModel.RefreshNodeInformationalStateDisplay();
viewModel.ValidateWorkspaceRunStatusMsg();
}


Expand Down