Skip to content

Commit

Permalink
DYN-7704 Single dialog for download consent across different compatib…
Browse files Browse the repository at this point in the history
…ility cases (#15754)

Co-authored-by: pinzart90 <[email protected]>
  • Loading branch information
QilongTang and pinzart90 authored Jan 17, 2025
1 parent 0b11829 commit 91399ef
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 27 deletions.
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.

12 changes: 6 additions & 6 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ You can always redownload the package.</value>
<data name="MessageFailedToFindNodeById" xml:space="preserve">
<value>No node could be found with that Id.</value>
</data>
<data name="MessageFailedToFindGroupById" xml:space="preserve">
<data name="MessageFailedToFindGroupById" xml:space="preserve">
<value>No group could be found with that Id.</value>
</data>
<data name="MessageFailedToOpenCorruptedFile" xml:space="preserve">
Expand Down Expand Up @@ -4057,15 +4057,12 @@ To make this file into a new template, save it to a different folder, then move
<data name="PackageDetailsCompatibilityWithSetup" xml:space="preserve">
<value>Compatible with your current setup</value>
</data>
<data name="PackageDetailsIncompatibilityWithSetup" xml:space="preserve">
<data name="PackageDetailsIncompatibilityWithSetup" xml:space="preserve">
<value>Incompatible with your current setup</value>
</data>
<data name="PackageDetailsXCompatibilityWithSetup" xml:space="preserve">
<value>Unknown compatibility with your current setup</value>
</data>
<data name="PackageDetailsSize" xml:space="preserve">
<value>Size</value>
</data>
<data name="PackageDetailsCompatibleVersionTooltip" xml:space="preserve">
<value>This version should be compatible with your current setup</value>
</data>
Expand Down Expand Up @@ -4105,4 +4102,7 @@ To make this file into a new template, save it to a different folder, then move
<data name="PackageVersionTooltip" xml:space="preserve">
<value>Versions marked with .x include all versions in the specified major or minor release</value>
</data>
</root>
<data name="PackageUnknownCompatibilityVersionDownloadMsg" xml:space="preserve">
<value>The compatibility of this version with your setup has not been verified. It may or may not work as expected.</value>
</data>
</root>
12 changes: 6 additions & 6 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,7 @@ Do you want to install the latest Dynamo update?</value>
<data name="MessageFailedToFindNodeById" xml:space="preserve">
<value>No node could be found with that Id.</value>
</data>
<data name="MessageFailedToFindGroupById" xml:space="preserve">
<data name="MessageFailedToFindGroupById" xml:space="preserve">
<value>No group could be found with that Id.</value>
</data>
<data name="MessageFailedToOpenCorruptedFile" xml:space="preserve">
Expand Down Expand Up @@ -4044,15 +4044,12 @@ To make this file into a new template, save it to a different folder, then move
<data name="PackageDetailsCompatibilityWithSetup" xml:space="preserve">
<value>Compatible with your current setup</value>
</data>
<data name="PackageDetailsIncompatibilityWithSetup" xml:space="preserve">
<data name="PackageDetailsIncompatibilityWithSetup" xml:space="preserve">
<value>Incompatible with your current setup</value>
</data>
<data name="PackageDetailsXCompatibilityWithSetup" xml:space="preserve">
<value>Unknown compatibility with your current setup</value>
</data>
<data name="PackageDetailsSize" xml:space="preserve">
<value>Size</value>
</data>
<data name="PackageDetailsCompatibleVersionTooltip" xml:space="preserve">
<value>This version should be compatible with your current setup</value>
</data>
Expand Down Expand Up @@ -4092,4 +4089,7 @@ To make this file into a new template, save it to a different folder, then move
<data name="PackageVersionTooltip" xml:space="preserve">
<value>Versions marked with .x include all versions in the specified major or minor release</value>
</data>
</root>
<data name="PackageUnknownCompatibilityVersionDownloadMsg" xml:space="preserve">
<value>The compatibility of this version with your setup has not been verified. It may or may not work as expected. </value>
</data>
</root>
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5224,6 +5224,7 @@ static Dynamo.Wpf.Properties.Resources.PackageUploadStateError.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUploadStateReady.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUploadStateUploaded.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUploadStateUploading.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUnknownCompatibilityVersionDownloadMsg.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUseNewerDynamoMessageBoxTitle.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUseOlderDynamoMessageBoxTitle.get -> string
static Dynamo.Wpf.Properties.Resources.PackageViewContextMenuLoadText.get -> string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,31 @@ internal async void ExecutePackageDownload(string name, PackageVersion package,
string msg;
MessageBoxResult result;

var compatible = PackageManagerSearchElement.CalculateCompatibility(package.compatibility_matrix);
if (compatible == false && !DynamoModel.IsTestMode)
// initialize default download consent message
msg = String.IsNullOrEmpty(installPath) ?
String.Format(Resources.MessageConfirmToInstallPackage, name, package.version) :
String.Format(Resources.MessageConfirmToInstallPackageToFolder, name, package.version, installPath);

// Calculate compatibility and display a single download consent across cases
var compatible = PackageManagerSearchElement.CalculateCompatibility(package.compatibility_matrix);

// Unknown package compatibility with current Dynamo env, this is expected to be the most popular case for now
if (compatible == null && !DynamoModel.IsTestMode)
{
msg = Resources.PackageManagerIncompatibleVersionDownloadMsg;
msg = msg + "\n\n" + Resources.PackageUnknownCompatibilityVersionDownloadMsg;
result = MessageBoxService.Show(ViewModelOwner, msg,
Resources.PackageDownloadConfirmMessageBoxTitle,
MessageBoxButton.OKCancel, MessageBoxImage.Question);

if (result != MessageBoxResult.OK)
{
return;
}
}
// Package incompatible with current Dynamo env
else if (compatible == false && !DynamoModel.IsTestMode)
{
msg = msg + "\n\n" + Resources.PackageManagerIncompatibleVersionDownloadMsg;
result = MessageBoxService.Show(ViewModelOwner, msg,
Resources.PackageManagerIncompatibleVersionDownloadTitle,
MessageBoxButton.OKCancel, MessageBoxImage.Warning);
Expand All @@ -764,14 +785,13 @@ internal async void ExecutePackageDownload(string name, PackageVersion package,
return;
}
}

msg = String.IsNullOrEmpty(installPath) ?
String.Format(Resources.MessageConfirmToInstallPackage, name, package.version) :
String.Format(Resources.MessageConfirmToInstallPackageToFolder, name, package.version, installPath);

result = MessageBoxService.Show(ViewModelOwner, msg,
Resources.PackageDownloadConfirmMessageBoxTitle,
MessageBoxButton.OKCancel, MessageBoxImage.Question);
// Package compatible with current Dynamo env
else
{
result = MessageBoxService.Show(ViewModelOwner, msg,
Resources.PackageDownloadConfirmMessageBoxTitle,
MessageBoxButton.OKCancel, MessageBoxImage.Question);
}

var pmExt = DynamoViewModel.Model.GetPackageManagerExtension();
if (result == MessageBoxResult.OK)
Expand Down Expand Up @@ -898,8 +918,8 @@ internal async void ExecutePackageDownload(string name, PackageVersion package,

var containsPackagesThatTargetOtherHosts = PackageManagerExtension.CheckIfPackagesTargetOtherHosts(newPackageHeaders);

// if any do, notify user and allow cancellation
if (containsPackagesThatTargetOtherHosts)
// if unknown compatibility, and package target other hosts, notify user and allow cancellation
if (compatible == null && containsPackagesThatTargetOtherHosts)
{
var res = MessageBoxService.Show(ViewModelOwner,
Resources.MessagePackageTargetOtherHosts,
Expand Down Expand Up @@ -957,11 +977,11 @@ internal async void ExecutePackageDownload(string name, PackageVersion package,
}
}
}
catch(ArgumentException ex)
catch (ArgumentException ex)
{
DynamoConsoleLogger.OnLogMessageToDynamoConsole($"exception while trying to compare version info between package and dynamo {ex}");
}
catch(FormatException ex)
catch (FormatException ex)
{
DynamoConsoleLogger.OnLogMessageToDynamoConsole($"exception while trying to compare version info between package and dynamo {ex}");
}
Expand Down

0 comments on commit 91399ef

Please sign in to comment.