Skip to content

Commit

Permalink
DYN-1874: I want to download missing graph package dependencies easily (
Browse files Browse the repository at this point in the history
DynamoDS#9854)

* Add IPackageInfo interface

* Add IPackageInfo interface

* Add PackageManagerClient API to intiate download and install of a package

* Add download button to test package download

* Add IPackageInfo interface

* Use PD state

* Fix comment

* Refactor Dependency Viewer UI

* Rename ExecutePackage -> ExecutePackageDownload

* Add PackageManagerClientViewModel to ViewLoadedParams

* Add IPackageDownloader to LoadedViewParams

* Move messages to resource file

* Add state-based messages

* Font size

* Keep ReferenceType and INodeLibraryDepInfo internal

* IPackageDownloader.cs -> IPackageInstaller.cs

* IPackageInstaller comments

* Move details message to resx

* Fix resource conflict

* Check terms of use acceptance before downloading package

* Embed icons in resources.resx

* Remove raw resources

* Add summary to public class

* Add summaries for PackageDependencyRow members
  • Loading branch information
scottmitchell authored and QilongTang committed Aug 5, 2019
1 parent dab35c2 commit 8ca9d0f
Show file tree
Hide file tree
Showing 16 changed files with 1,086 additions and 396 deletions.
31 changes: 26 additions & 5 deletions src/DynamoCore/Graph/Workspaces/PackageDependencyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Dynamo.Graph.Workspaces
/// <summary>
/// Enum containing the different types of package dependency states.
/// </summary>
internal enum PackageDependencyState
public enum PackageDependencyState
{
Loaded, // Correct package and version loaded.
IncorrectVersion, // Correct package but incorrect version.
Expand All @@ -15,20 +15,36 @@ internal enum PackageDependencyState
RequiresRestart // Restart needed inorder to complete the uninstall of some package.
}

/// <summary>
/// Interface for types containing info about a package
/// </summary>
public interface IPackageInfo
{
/// <summary>
/// Name of the package
/// </summary>
string Name { get; }

/// <summary>
/// Version of the package
/// </summary>
Version Version { get; }
}

/// <summary>
/// Class containing info about a package
/// </summary>
public class PackageInfo
public class PackageInfo : IPackageInfo
{
/// <summary>
/// Name of the package
/// </summary>
internal string Name { get; set; }
public string Name { get; private set; }

/// <summary>
/// Version of the package
/// </summary>
internal Version Version { get; set; }
public Version Version { get; private set; }

/// <summary>
/// Create a package info object from the package name and version
Expand Down Expand Up @@ -133,12 +149,17 @@ interface INodeLibraryDependencyInfo
/// </summary>
[Obsolete("This property is obsolete", false)]
bool IsLoaded { get; set; }

/// <summary>
/// The state of this dependency
/// </summary>
PackageDependencyState State { get; }
}

/// <summary>
/// Class containing info about a workspace package dependency
/// </summary>
internal class PackageDependencyInfo : INodeLibraryDependencyInfo
internal class PackageDependencyInfo : INodeLibraryDependencyInfo, IPackageInfo
{
private PackageDependencyState _state;
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
<Compile Include="ViewModels\Core\GalleryViewModel.cs" />
<Compile Include="ViewModels\Core\HomeWorkspaceViewModel.cs" />
<Compile Include="ViewModels\Core\SerializationExtensions.cs" />
<Compile Include="ViewModels\PackageManager\IPackageInstaller.cs" />
<Compile Include="ViewModels\PackageManager\PackagePathViewModel.cs" />
<Compile Include="ViewModels\Preview\CompactBubbleViewModel.cs" />
<Compile Include="ViewModels\RunSettingsViewModel.cs" />
Expand Down
8 changes: 8 additions & 0 deletions src/DynamoCoreWpf/Extensions/ViewLoadedParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public IRenderPackageFactory RenderPackageFactory
get { return dynamoViewModel.RenderPackageFactoryViewModel.Factory; }
}

/// <summary>
/// A reference to package install operations on the package manager
/// </summary>
public IPackageInstaller PackageInstaller
{
get { return dynamoViewModel.PackageManagerClientViewModel; }
}

/// <summary>
/// A reference to the Dynamo Window object. Useful for correctly setting the parent of a
/// newly created window.
Expand Down
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 @@ -2228,6 +2228,12 @@ Uninstall the following packages: {0}?</value>
<data name="MessageUninstallSamePackage" xml:space="preserve">
<value>"The package {0} is already installed. To reinstall it, you must first uninstall it and restart to complete the uninstall. Would you like to mark {0} for uninstall?"</value>
</data>
<data name="MessagePackageNotFound" xml:space="preserve">
<value>{0} was not found and could not be downloaded.</value>
</data>
<data name="MessagePackageVersionNotFound" xml:space="preserve">
<value>Version {0} of {1} could not be found.</value>
</data>
<data name="PublishPackageViewPackageHostDependency" xml:space="preserve">
<value>Host Dependency (optional)</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 @@ -2231,6 +2231,12 @@ Uninstall the following packages: {0}?</value>
<data name="MessageUninstallSamePackage" xml:space="preserve">
<value>"The package {0} is already installed. To reinstall it, you must first uninstall it and restart to complete the uninstall. Would you like to mark {0} for uninstall?"</value>
</data>
<data name="MessagePackageNotFound" xml:space="preserve">
<value>{0} was not found and could not be downloaded.</value>
</data>
<data name="MessagePackageVersionNotFound" xml:space="preserve">
<value>Version {0} of {1} could not be found.</value>
</data>
<data name="PublishPackageViewPackageHostDependency" xml:space="preserve">
<value>Host Dependency (optional)</value>
</data>
Expand Down
22 changes: 22 additions & 0 deletions src/DynamoCoreWpf/ViewModels/PackageManager/IPackageInstaller.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dynamo.Graph.Workspaces;

namespace Dynamo.ViewModels
{
/// <summary>
/// An interface containing operations for installing Dynamo packages
/// </summary>
public interface IPackageInstaller
{
/// <summary>
/// Initiates download and install of a package
/// </summary>
/// <param name="package">Package Info of the package to be downloaded--includes package name and version</param>
/// <param name="downloadPath">Path to download location of the package</param>
void DownloadAndInstallPackage(IPackageInfo package, string downloadPath = null);
}
}
Loading

0 comments on commit 8ca9d0f

Please sign in to comment.