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-6511 Pm publish version from mypackages #14723

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ public PackageManagerSearchElementViewModel(PackageManagerSearchElement element,
public PackageManagerSearchElementViewModel(PackageManagerSearchElement element, bool canLogin) : this(element, canLogin, true)
{}

/// <summary>
/// A property showing if the currently logged-in user owns the package
/// </summary>
private bool isOwner = false;
public bool IsOnwer
{
get
{
return isOwner;
}

internal set
{
isOwner = value;
RaisePropertyChanged(nameof(IsOnwer));
}
}

private bool canInstall;
/// <summary>
/// A Boolean flag reporting whether or not the user can install this SearchElement's package.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,12 @@ private void PopulateMyPackages()
var pkgs = PackageManagerClientViewModel.CachedPackageList.Where(x => x.Maintainers != null && x.Maintainers.Contains(name)).ToList();
foreach(var pkg in pkgs)
{
var p = new PackageManagerSearchElementViewModel(pkg, false);
var p = new PackageManagerSearchElementViewModel(pkg,
PackageManagerClientViewModel.AuthenticationManager.HasAuthProvider,
CanInstallPackage(pkg.Name));
p.RequestDownload += this.PackageOnExecuted;
p.RequestShowFileDialog += this.OnRequestShowFileDialog;
p.IsOnwer = true;

myPackages.Add(p);
}
Expand All @@ -666,6 +670,7 @@ private void ClearMySearchResults()
foreach (var ele in this.SearchMyResults)
{
ele.RequestDownload -= PackageOnExecuted;
ele.RequestShowFileDialog -= OnRequestShowFileDialog;
}

this.SearchMyResults = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
using Dynamo.PackageManager.ViewModels;
using Dynamo.UI.Commands;
using Dynamo.ViewModels;
using NotificationObject = Dynamo.Core.NotificationObject;

Expand All @@ -25,7 +28,20 @@ public class PackageManagerViewModel : NotificationObject, IDisposable
/// <summary>
/// PublishPackageViewModel containing information about all the published packages
/// </summary>
public PublishPackageViewModel PublishPackageViewModel { get; set; }
///
private PublishPackageViewModel publishPackageViewModel;
public PublishPackageViewModel PublishPackageViewModel
{
get { return publishPackageViewModel; }
set
{
if (publishPackageViewModel != value)
{
publishPackageViewModel = value;
RaisePropertyChanged(nameof(PublishPackageViewModel));
}
}
}

/// <summary>
/// Returns all installed packages
Expand All @@ -37,6 +53,7 @@ public class PackageManagerViewModel : NotificationObject, IDisposable
/// </summary>
public ObservableCollection<PackageFilter> Filters => installedPackagesViewModel.Filters;

public DelegateCommand PublishNewVersionCommand { get; set; }

//Width of the PackageManagerView the default value is 1076
public double Width
Expand Down Expand Up @@ -90,6 +107,21 @@ public PackageManagerViewModel(DynamoViewModel dynamoViewModel, PackageManagerSe
{
PreferencesViewModel.SelectedPackagePathForInstall = dynamoViewModel.PreferenceSettings.SelectedPackagePathForInstall;
}

PublishNewVersionCommand = new DelegateCommand(PublishNewPackageVersionRelayCommand);
}


private void PublishNewPackageVersionRelayCommand(object obj)
{
var searchElement = obj as PackageManagerSearchElementViewModel;
if(searchElement != null)
{
var localPackage = LocalPackages.First(x => x.Model.Name.Equals(searchElement.Name));

if (localPackage == null) { return; }
localPackage.PublishNewPackageVersionCommand.Execute();
}
}

private void LocalPackages_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
Expand Down
4 changes: 4 additions & 0 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,10 @@ private void DynamoViewModelRequestPackageManager(PublishPackageViewModel model)

if (packageManagerWindow.IsLoaded && IsLoaded) packageManagerWindow.Owner = this;
}
if (_pkgVM != null)
{
_pkgVM.PublishPackageViewModel = model;
}

packageManagerWindow.Focus();
packageManagerWindow.Navigate(Wpf.Properties.Resources.PackageManagerPublishTab);
Expand Down
24 changes: 0 additions & 24 deletions test/DynamoCoreWpfTests/PackageManager/PackageManagerUITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1944,8 +1944,6 @@ public void GetAllFilesReturnsEqualsPackageContents()
var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList();
var vm = new PublishPackageViewModel(this.ViewModel);

ViewModel.OnRequestPackagePublishDialog(vm);

vm.AddAllFilesAfterSelection(allFiles);

int packageContentsCount = 0;
Expand All @@ -1969,8 +1967,6 @@ public void AssertGetPreBuildRootItemViewModelReturnsCorrectItem()
var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList();
var vm = new PublishPackageViewModel(this.ViewModel);

ViewModel.OnRequestPackagePublishDialog(vm);

vm.AddAllFilesAfterSelection(allFiles);

var testPath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder\\", "TestPath");
Expand All @@ -1994,8 +1990,6 @@ public void AssertGetExistingRootItemViewModelReturnsCorrectItem()
var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList();
var vm = new PublishPackageViewModel(this.ViewModel);

ViewModel.OnRequestPackagePublishDialog(vm);

vm.AddAllFilesAfterSelection(allFiles);

var testPath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder\\", "TestPath");
Expand Down Expand Up @@ -2031,8 +2025,6 @@ public void RemoveFilesUpdatesPerviewContentItem()
var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList();
var vm = new PublishPackageViewModel(this.ViewModel);

ViewModel.OnRequestPackagePublishDialog(vm);

vm.AddAllFilesAfterSelection(allFiles);

// Act
Expand All @@ -2056,8 +2048,6 @@ public void RemoveAllChildrenFilesUpdatesContentItem()
var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList();
var vm = new PublishPackageViewModel(this.ViewModel);

ViewModel.OnRequestPackagePublishDialog(vm);

vm.AddAllFilesAfterSelection(allFiles);

// Act
Expand Down Expand Up @@ -2085,8 +2075,6 @@ public void CanRemoveCustomDefinitionDependencyTypes()
var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList();
var vm = new PublishPackageViewModel(this.ViewModel);

ViewModel.OnRequestPackagePublishDialog(vm);

vm.AddAllFilesAfterSelection(allFiles);

// Act
Expand Down Expand Up @@ -2141,8 +2129,6 @@ public void CanRemoveAllDependencyTypes()
var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList();
var vm = new PublishPackageViewModel(this.ViewModel);

ViewModel.OnRequestPackagePublishDialog(vm);

vm.AddAllFilesAfterSelection(allFiles);

// Act
Expand Down Expand Up @@ -2189,8 +2175,6 @@ public void CancelCommandClearsAllData()
Assert.AreEqual(0, vm.PackageContents.Count);
Assert.AreEqual(0, vm.PreviewPackageContents.Count);

ViewModel.OnRequestPackagePublishDialog(vm);

vm.AddAllFilesAfterSelection(allFiles);

// Act
Expand All @@ -2217,8 +2201,6 @@ public void AssertPreviewPackageDefaultFolderStructureEqualsPublishLocalPackageR
//now lets publish this package.
var newPkgVm = new PublishPackageViewModel(this.ViewModel);

ViewModel.OnRequestPackagePublishDialog(newPkgVm);

newPkgVm.AddAllFilesAfterSelection(allFiles);

var previewFilesAndFolders = PackageItemRootViewModel.GetFiles(newPkgVm.PreviewPackageContents.ToList());
Expand Down Expand Up @@ -2258,9 +2240,6 @@ public void AssertPreviewPackageRetainFolderStructureEqualsPublishLocalPackageRe
//now lets publish this package.
var newPkgVm = new PublishPackageViewModel(this.ViewModel);
newPkgVm.RetainFolderStructureOverride = true;

ViewModel.OnRequestPackagePublishDialog(newPkgVm);

newPkgVm.AddAllFilesAfterSelection(allFiles);

var previewFilesAndFolders = PackageItemRootViewModel.GetFiles(newPkgVm.PreviewPackageContents.ToList());
Expand Down Expand Up @@ -2300,9 +2279,6 @@ public void AssertPublishLocalHandleType()
//now lets publish this package.
var newPkgVm = new PublishPackageViewModel(this.ViewModel);
newPkgVm.RetainFolderStructureOverride = true;

ViewModel.OnRequestPackagePublishDialog(newPkgVm);

newPkgVm.AddAllFilesAfterSelection(allFiles);

var previewFilesAndFolders = PackageItemRootViewModel.GetFiles(newPkgVm.PreviewPackageContents.ToList());
Expand Down
Loading