Skip to content

Commit 2beac32

Browse files
authored
Address a few PM publish fixes regarding publish process and groups (#16104)
1 parent b8ffcec commit 2beac32

4 files changed

Lines changed: 44 additions & 18 deletions

File tree

src/DynamoCore/Graph/Workspaces/WorkspaceModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,6 +2703,7 @@ private void LoadAnnotation(ExtraAnnotationViewInfo annotationViewInfo)
27032703
annotationModel.GUID = annotationGuidValue;
27042704
annotationModel.HeightAdjustment = annotationViewInfo.HeightAdjustment;
27052705
annotationModel.WidthAdjustment = annotationViewInfo.WidthAdjustment;
2706+
annotationModel.UpdateGroupFrozenStatus();
27062707

27072708
annotationModel.ModelBaseRequested += annotationModel_GetModelBase;
27082709
annotationModel.Disposed += (_) => annotationModel.ModelBaseRequested -= annotationModel_GetModelBase;

src/DynamoCoreWpf/ViewModels/PackageManager/PublishPackageViewModel.cs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,15 +1580,26 @@ internal static PublishPackageViewModel FromLocalPackage(DynamoViewModel dynamoV
15801580
}
15811581
}
15821582

1583-
// We need to get the compatibility matrix from the cached package list
1584-
// in order to show the correct compatibility matrix in the UI.
1585-
// We are still running the risk of having a higher version of the local package
1586-
// leading to a null result for the compatibility matrix.
1587-
var cachedPackage = dynamoViewModel.PackageManagerClientViewModel.CachedPackageList
1588-
.FirstOrDefault(x => x.Name == pkg.Name);
1589-
var version = cachedPackage?.Header.versions
1590-
.FirstOrDefault(v => v.version.Equals(pkg.VersionName));
1591-
var compatibility_matrix = version?.compatibility_matrix;
1583+
// First check if the local package has the compatibility info
1584+
var compatibility_matrix = pkg.CompatibilityMatrix ?? pkg.Header?.compatibility_matrix;
1585+
//If we do not find compatibility info in the local package, we will check the cached packages
1586+
if (compatibility_matrix == null)
1587+
{
1588+
// We need to get the compatibility matrix from the cached package list
1589+
// in order to show the correct compatibility matrix in the UI.
1590+
// We are still running the risk of having a higher version of the local package
1591+
// leading to a null result for the compatibility matrix, in which case we will not pre-fill the compatibility info..
1592+
var cachedPackage = dynamoViewModel.PackageManagerClientViewModel.CachedPackageList
1593+
.FirstOrDefault(x => x.Name == pkg.Name);
1594+
var version = cachedPackage?.Header.versions
1595+
.FirstOrDefault(v => v.version.Equals(pkg.VersionName));
1596+
compatibility_matrix = version?.compatibility_matrix?
1597+
.Select(entry => new PackageCompatibility(
1598+
entry.name,
1599+
entry.versions != null ? new List<string>(entry.versions) : null,
1600+
entry.min,
1601+
entry.max));
1602+
}
15921603

15931604
var pkgViewModel = new PublishPackageViewModel(dynamoViewModel)
15941605
{
@@ -1609,13 +1620,7 @@ internal static PublishPackageViewModel FromLocalPackage(DynamoViewModel dynamoV
16091620
CurrentPackageRootDirectories = new List<string> { pkg.RootDirectory },
16101621
//default retain folder structure to true when publishing a new version from local.
16111622
RetainFolderStructureOverride = retainFolderStructure,
1612-
CompatibilityMatrix = compatibility_matrix?
1613-
.Select(entry => new PackageCompatibility(
1614-
entry.name,
1615-
entry.versions != null ? new List<string>(entry.versions) : null,
1616-
entry.min,
1617-
entry.max))
1618-
.ToList()
1623+
CompatibilityMatrix = compatibility_matrix?.ToList(),
16191624
};
16201625

16211626
// add additional files
@@ -2570,7 +2575,7 @@ internal IEnumerable<string> BuildPackage()
25702575
Package.RepositoryUrl = RepositoryUrl;
25712576
Package.CopyrightHolder = string.IsNullOrEmpty(CopyrightHolder) ? dynamoViewModel.Model.AuthenticationManager?.Username : CopyrightHolder;
25722577
Package.CopyrightYear = string.IsNullOrEmpty(CopyrightYear) ? DateTime.Now.Year.ToString() : copyrightYear;
2573-
Package.Header.compatibility_matrix = CompatibilityMatrix; // New - CompatibilityMatrix, Dynamo 3.5
2578+
Package.SetCompatibility(CompatibilityMatrix); // New - CompatibilityMatrix, Dynamo 3.5
25742579
Package.Header.release_notes_url = ReleaseNotesUrl; // New - ReleaseNotesUrl, Dynamo 3.5
25752580

25762581
AppendPackageContents();

src/DynamoPackages/Package.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ internal IEnumerable<Assembly> NodeLibraries
216216
public ObservableCollection<CustomNodeInfo> LoadedCustomNodes { get; private set; }
217217
public ObservableCollection<PackageDependency> Dependencies { get; private set; }
218218
public ObservableCollection<PackageFileInfo> AdditionalFiles { get; private set; }
219+
public ObservableCollection<PackageCompatibility> CompatibilityMatrix { get; private set; }
219220

220221
/// <summary>
221222
/// A header used to create the package, this data does not reflect runtime
@@ -241,6 +242,7 @@ public Package(string directory, string name, string versionName, string license
241242
Dependencies = new ObservableCollection<PackageDependency>();
242243
LoadedCustomNodes = new ObservableCollection<CustomNodeInfo>();
243244
AdditionalFiles = new ObservableCollection<PackageFileInfo>();
245+
CompatibilityMatrix = new ObservableCollection<PackageCompatibility>();
244246
Header = PackageUploadBuilder.NewRequestBody(this);
245247
}
246248

@@ -278,6 +280,8 @@ public static Package FromJson(string headerPath, ILogger logger)
278280
CopyrightYear = body.copyright_year,
279281
Header = body
280282
};
283+
284+
pkg.SetCompatibility(body.compatibility_matrix);
281285

282286
foreach (var dep in body.dependencies)
283287
pkg.Dependencies.Add(dep);
@@ -345,6 +349,22 @@ internal void AddAssemblies(IEnumerable<PackageAssembly> assems)
345349
}
346350
}
347351

352+
/// <summary>
353+
/// Set the compatibility matrix for the package.
354+
/// </summary>
355+
/// <param name="cmpList">Package compatibility info</param>
356+
internal void SetCompatibility(IEnumerable<PackageCompatibility> cmpList)
357+
{
358+
// Clear the old compatibility matrix, not checking for an empty list here
359+
// as user should be able to remove compatibility as well
360+
if (cmpList != null)
361+
{
362+
CompatibilityMatrix.Clear();
363+
CompatibilityMatrix.AddRange(cmpList);
364+
Header.compatibility_matrix = cmpList;
365+
}
366+
}
367+
348368
/// <summary>
349369
/// Enumerates all assemblies in the package. This method currently has the side effect that it will
350370
/// load all binaries in the package bin folder unless the package is loaded from a special package path

src/DynamoPackages/PackageManagerClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ internal PackageHeader GetPackageMaintainers(IPackageInfo packageInfo)
150150
{
151151
var nv = new GetMaintainers("dynamo", packageInfo.Name);
152152
var pkgResponse = this.client.ExecuteAndDeserializeWithContent<PackageHeader>(nv);
153-
return pkgResponse.content;
153+
return pkgResponse?.content;
154154
}, null);
155155

156156
return header;

0 commit comments

Comments
 (0)