Skip to content

Commit

Permalink
reset selected known hosts (#14722)
Browse files Browse the repository at this point in the history
- now resets selected known hosts between publish package usages/resets
  • Loading branch information
dnenov authored Dec 12, 2023
1 parent 88cb39f commit f5fddc3
Showing 1 changed file with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
Expand Down Expand Up @@ -92,7 +93,7 @@ public DynamoViewModel DynamoViewModel
/// <summary>
/// Package Publish entry, binded to the host multi-selection option
/// </summary>
public class HostComboboxEntry
public class HostComboboxEntry : NotificationObject
{
/// <summary>
/// Name of the host
Expand All @@ -102,7 +103,16 @@ public class HostComboboxEntry
/// <summary>
/// Boolean indicates if the host entry is selected
/// </summary>
public bool IsSelected { get; set; }
private bool _isSelected;
public bool IsSelected
{
get { return _isSelected; }
set
{
_isSelected = value;
RaisePropertyChanged(nameof(IsSelected));
}
}

/// <summary>
/// Constructor
Expand All @@ -113,6 +123,14 @@ public HostComboboxEntry(string hostName)
HostName = hostName;
IsSelected = false;
}

/// <summary>
/// Reset the state of the `IsSelected` property without raising update
/// </summary>
internal void ResetState()
{
this._isSelected = false;
}
}

public Window Owner { get; set; }
Expand Down Expand Up @@ -190,6 +208,7 @@ public bool IsNewVersion
{
_isNewVersion = value;
RaisePropertyChanged("IsNewVersion");
RaisePropertyChanged("CanEditName");
}
}
}
Expand Down Expand Up @@ -1105,6 +1124,14 @@ public PublishPackageViewModel( DynamoViewModel dynamoViewModel ) : this()
private void ClearAllEntries()
{
if (DynamoModel.IsTestMode) return;

try
{
this.KnownHosts.ForEach(host => host.ResetState());
this.KnownHosts.ForEach(host => host.IsSelected = false);
}
catch { Exception ex; }

// this function clears all the entries of the publish package dialog
this.Name = string.Empty;
this.RepositoryUrl = string.Empty;
Expand Down Expand Up @@ -1134,8 +1161,8 @@ private void ClearAllEntries()
this.AdditionalFiles = new ObservableCollection<string>();
this.Dependencies = new ObservableCollection<PackageDependency>();
this.Assemblies = new List<PackageAssembly>();
this.SelectedHostsString = string.Empty;
this.SelectedHosts = new List<String>();
this.SelectedHostsString = string.Empty;
this.copyrightHolder = string.Empty;
this.copyrightYear = string.Empty;
this.RootFolder = string.Empty;
Expand Down Expand Up @@ -1470,12 +1497,13 @@ internal IEnumerable<string> GetAllFiles()
private void UpdateDependencies()
{
Dependencies.Clear();
GetAllDependencies().ToList().ForEach(Dependencies.Add);
GetAllDependencies()?.ToList().ForEach(Dependencies.Add);
}

private IEnumerable<PackageDependency> GetAllDependencies()
{
var pmExtension = dynamoViewModel.Model.GetPackageManagerExtension();
if (pmExtension == null) return null;
var pkgLoader = pmExtension.PackageLoader;

// all workspaces
Expand Down Expand Up @@ -2160,7 +2188,7 @@ private IEnumerable<string> BuildPackage()
AppendPackageContents();

Package.Dependencies.Clear();
GetAllDependencies().ToList().ForEach(Package.Dependencies.Add);
GetAllDependencies()?.ToList().ForEach(Package.Dependencies.Add);

Package.HostDependencies = Enumerable.Empty<string>();
Package.HostDependencies = SelectedHosts;
Expand Down

0 comments on commit f5fddc3

Please sign in to comment.