Skip to content

Commit

Permalink
Update Run Status Message to Run Blocked during File Trust Warning (#…
Browse files Browse the repository at this point in the history
…12953)

* Update Run Status Message to Run Blocked

* Clean up

* Update

* update

* Add null check
  • Loading branch information
QilongTang authored Jun 3, 2022
1 parent 0ac837c commit d1477f3
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/DynamoCore/Graph/Workspaces/HomeWorkspaceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,6 @@ private void PulseMakerRunStarted()
/// <param name="markNodesAsDirty">Set this parameter to true to force
/// reset of the execution substrait. Note that setting this parameter
/// to true will have a negative performance impact.</param>
/// <param name="forceAutomaticWithoutRun">This parameter, if true, will prohibit the graph from executing when RunMode is set to Automatic</param>
internal void ResetEngine(EngineController controller, bool markNodesAsDirty = false)
{
if (EngineController != null)
Expand All @@ -674,7 +673,7 @@ internal void ResetEngine(EngineController controller, bool markNodesAsDirty = f
MarkNodesAsModifiedAndRequestRun(Nodes);
}

if (RunSettings.RunEnabled && RunSettings.RunType == RunType.Automatic && RunSettings.ForceAutomaticWithoutRun == false)
if (RunSettings.RunEnabled && RunSettings.RunType == RunType.Automatic && !RunSettings.ForceAutomaticWithoutRun)
Run();
}

Expand Down
4 changes: 3 additions & 1 deletion src/DynamoCore/Models/RunSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ public class RunSettings : NotificationObject
private RunType runType;
private bool runEnabled;
private bool runTypesEnabled;
private bool runTypesComboBoxToolTipIsEnabled;

/// <summary>
/// Boolean indicates if Dynamo should block run even when mode is Automatic.
/// </summary>
internal bool ForceAutomaticWithoutRun { get; set; } = false;

/// <summary>
Expand Down
9 changes: 9 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

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

4 changes: 4 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3199,4 +3199,8 @@ To install the latest version of a package, click Install. \n
<data name="MessagePackageTargetOtherHosts" xml:space="preserve">
<value>The package or one of its dependencies targets a different environment, such as Revit, Civil 3D, Advance Steel, Alias or FormIt. This can cause instability and unexpected problems. Do you want to continue?</value>
</data>
<data name="RunBlockedMessage" xml:space="preserve">
<value>Run blocked.</value>
<comment>Run status message for case where graph run blocked due to unresolved security warning.</comment>
</data>
</root>
4 changes: 4 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3186,4 +3186,8 @@ To install the latest version of a package, click Install. \n
<data name="MessagePackageTargetOtherHosts" xml:space="preserve">
<value>The package or one of its dependencies targets a different environment, such as Revit, Civil 3D, Advance Steel, Alias or FormIt. This can cause instability and unexpected problems. Do you want to continue?</value>
</data>
<data name="RunBlockedMessage" xml:space="preserve">
<value>Run blocked.</value>
<comment>Run status message for case where graph run blocked due to unresolved security warning.</comment>
</data>
</root>
14 changes: 5 additions & 9 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1605,17 +1605,13 @@ private void Open(object parameters)
}

var directoryName = Path.GetDirectoryName(filePath);
//Checks if the file that is being opened is in the trusted list.
bool bShowFileTrustWarning = false;
if(!PreferenceSettings.TrustedLocations.Contains(directoryName) && DynamoModel.IsTestMode == false)
{
HomeSpace.RunSettings.ForceAutomaticWithoutRun = true;
bShowFileTrustWarning = true;
}
ExecuteCommand(new DynamoModel.OpenFileCommand(filePath, forceManualMode));

if (FileTrustViewModel != null && bShowFileTrustWarning == true)
if (!PreferenceSettings.TrustedLocations.Contains(directoryName)
&& (currentWorkspaceViewModel?.IsHomeSpace ?? false)
&& DynamoModel.IsTestMode == false
&& FileTrustViewModel != null)
{
HomeSpace.RunSettings.ForceAutomaticWithoutRun = true;
FileTrustViewModel.DynFileDirectoryName = directoryName;
FileTrustViewModel.ShowWarningPopup = true;
}
Expand Down
6 changes: 6 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/HomeWorkspaceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ void hwm_EvaluationCompleted(object sender, EvaluationCompletedEventArgs e)
/// </summary>
internal void UpdateRunStatusMsgBasedOnStates()
{
if ((bool)((Model as HomeWorkspaceModel)?.RunSettings.ForceAutomaticWithoutRun))
{
SetCurrentWarning(NotificationLevel.Moderate, Properties.Resources.RunBlockedMessage);
return;
}

if (!HasWarnings && !HasErrors)
{
if (Model.ScaleFactorChanged)
Expand Down

0 comments on commit d1477f3

Please sign in to comment.