Skip to content

Commit

Permalink
7343: DYN-7341: Pm searchresults compatibilityfilter (#15568)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnenov authored Oct 30, 2024
1 parent fa67685 commit 535b00d
Show file tree
Hide file tree
Showing 8 changed files with 337 additions and 10 deletions.
63 changes: 63 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.

21 changes: 21 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4075,4 +4075,25 @@ To make this file into a new template, save it to a different folder, then move
<data name="PackageManagerIncompatibleVersionDownloadTitle" xml:space="preserve">
<value>Incompatible version</value>
</data>
<data name="PackageFilterByCompatibility" xml:space="preserve">
<value>VERSION COMPATIBILITY</value>
</data>
<data name="PackageCompatible" xml:space="preserve">
<value>Compatible</value>
</data>
<data name="PackageCompatibleFilterTooltip" xml:space="preserve">
<value>Versions compatible with the current setup</value>
</data>
<data name="PackageUnknownCompatibility" xml:space="preserve">
<value>Unknown compatibility</value>
</data>
<data name="PackageUnknownCompatibilityFilterTooltip" xml:space="preserve">
<value>Compatibility of package version cannot be verified</value>
</data>
<data name="PackageIncompatible" xml:space="preserve">
<value>Incompatible</value>
</data>
<data name="PackageIncompatibleFilterTooltip" xml:space="preserve">
<value>Versions maybe incompatible with the current setup</value>
</data>
</root>
21 changes: 21 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4062,4 +4062,25 @@ To make this file into a new template, save it to a different folder, then move
<data name="PackageManagerIncompatibleVersionDownloadTitle" xml:space="preserve">
<value>Incompatible version</value>
</data>
<data name="PackageFilterByCompatibility" xml:space="preserve">
<value>VERSION COMPATIBILITY</value>
</data>
<data name="PackageCompatible" xml:space="preserve">
<value>Compatible</value>
</data>
<data name="PackageCompatibleFilterTooltip" xml:space="preserve">
<value>Versions compatible with the current setup</value>
</data>
<data name="PackageUnknownCompatibility" xml:space="preserve">
<value>Unknown compatibility</value>
</data>
<data name="PackageUnknownCompatibilityFilterTooltip" xml:space="preserve">
<value>Compatibility of package version cannot be verified</value>
</data>
<data name="PackageIncompatible" xml:space="preserve">
<value>Incompatible</value>
</data>
<data name="PackageIncompatibleFilterTooltip" xml:space="preserve">
<value>Versions maybe incompatible with the current setup</value>
</data>
</root>
9 changes: 9 additions & 0 deletions src/DynamoCoreWpf/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,8 @@ Dynamo.PackageManager.PackageManagerSearchViewModel.ClearSearchTextBoxCommand.se
Dynamo.PackageManager.PackageManagerSearchViewModel.ClearToastNotification(object obj) -> void
Dynamo.PackageManager.PackageManagerSearchViewModel.ClearToastNotificationCommand.get -> Prism.Commands.DelegateCommand<object>
Dynamo.PackageManager.PackageManagerSearchViewModel.ClearToastNotificationCommand.set -> void
Dynamo.PackageManager.PackageManagerSearchViewModel.CompatibilityFilter.get -> System.Collections.Generic.List<Dynamo.PackageManager.PackageManagerSearchViewModel.FilterEntry>
Dynamo.PackageManager.PackageManagerSearchViewModel.CompatibilityFilter.set -> void
Dynamo.PackageManager.PackageManagerSearchViewModel.DisableSearchTextBox() -> void
Dynamo.PackageManager.PackageManagerSearchViewModel.Downloads.get -> System.Collections.ObjectModel.ObservableCollection<Dynamo.PackageManager.PackageDownloadHandle>
Dynamo.PackageManager.PackageManagerSearchViewModel.ExecuteSelected() -> void
Expand Down Expand Up @@ -4989,6 +4991,8 @@ static Dynamo.Wpf.Properties.Resources.OnboardingWorkspaceTitle.get -> string
static Dynamo.Wpf.Properties.Resources.OneAssemblyWasLoadedSeveralTimesErrorMessage.get -> string
static Dynamo.Wpf.Properties.Resources.OnlyTitle.get -> string
static Dynamo.Wpf.Properties.Resources.OpenDynamoDefinitionDialogTitle.get -> string
static Dynamo.Wpf.Properties.Resources.PackageCompatible.get -> string
static Dynamo.Wpf.Properties.Resources.PackageCompatibleFilterTooltip.get -> string
static Dynamo.Wpf.Properties.Resources.PackageContextMenuDeletePackageCustomNodesInUseTooltip.get -> string
static Dynamo.Wpf.Properties.Resources.PackageContextMenuDeletePackageText.get -> string
static Dynamo.Wpf.Properties.Resources.PackageContextMenuDeletePackageTooltip.get -> string
Expand Down Expand Up @@ -5030,6 +5034,7 @@ static Dynamo.Wpf.Properties.Resources.PackageDownloadStateInstalling.get -> str
static Dynamo.Wpf.Properties.Resources.PackageDownloadStateStarting.get -> string
static Dynamo.Wpf.Properties.Resources.PackageDuplicateAssemblyWarning.get -> string
static Dynamo.Wpf.Properties.Resources.PackageDuplicateAssemblyWarningTitle.get -> string
static Dynamo.Wpf.Properties.Resources.PackageFilterByCompatibility.get -> string
static Dynamo.Wpf.Properties.Resources.PackageFilterByDependency.get -> string
static Dynamo.Wpf.Properties.Resources.PackageFilterByHost.get -> string
static Dynamo.Wpf.Properties.Resources.PackageFilterByStatus.get -> string
Expand All @@ -5043,6 +5048,8 @@ static Dynamo.Wpf.Properties.Resources.PackageFolderNotAccessible.get -> string
static Dynamo.Wpf.Properties.Resources.PackageHostDependencyFilter.get -> string
static Dynamo.Wpf.Properties.Resources.PackageHostDependencyFilterContextItem.get -> string
static Dynamo.Wpf.Properties.Resources.PackageHostDependencyTooltip.get -> string
static Dynamo.Wpf.Properties.Resources.PackageIncompatible.get -> string
static Dynamo.Wpf.Properties.Resources.PackageIncompatibleFilterTooltip.get -> string
static Dynamo.Wpf.Properties.Resources.PackageManagerClearAllButtonText.get -> string
static Dynamo.Wpf.Properties.Resources.PackageManagerFinishedPackageFilesPublishedMessage.get -> string
static Dynamo.Wpf.Properties.Resources.PackageManagerFinishedPackageFilesUploadedMessage.get -> string
Expand Down Expand Up @@ -5182,6 +5189,8 @@ static Dynamo.Wpf.Properties.Resources.PackageStateUnknown.get -> string
static Dynamo.Wpf.Properties.Resources.PackageStateUnloaded.get -> string
static Dynamo.Wpf.Properties.Resources.PackageStateUnloadedTooltip.get -> string
static Dynamo.Wpf.Properties.Resources.PackageTypeShortString.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUnknownCompatibility.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUnknownCompatibilityFilterTooltip.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUploadNoDependency.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUploadStateCompressing.get -> string
static Dynamo.Wpf.Properties.Resources.PackageUploadStateCopying.get -> string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public PackageSortingKey SortingKey
set
{
_sortingKey = value;
RaisePropertyChanged("SortingKey");
RaisePropertyChanged(nameof(SortingKey));
}
}

Expand All @@ -218,11 +218,10 @@ public List<FilterEntry> HostFilter
set
{
hostFilter = value;
RaisePropertyChanged("HostFilter");
RaisePropertyChanged(nameof(HostFilter));
}
}


private List<FilterEntry> nonHostFilter;

/// <summary>
Expand All @@ -235,7 +234,22 @@ public List<FilterEntry> NonHostFilter
set
{
nonHostFilter = value;
RaisePropertyChanged("NonHostFilter");
RaisePropertyChanged(nameof(NonHostFilter));
}
}

private List<FilterEntry> compatibilityFilter;

/// <summary>
/// Compatibility filters (Compatible, Non-compatible, Unknown)
/// </summary>
public List<FilterEntry> CompatibilityFilter
{
get { return compatibilityFilter; }
set
{
compatibilityFilter = value;
RaisePropertyChanged(nameof(CompatibilityFilter));
}
}

Expand All @@ -252,7 +266,7 @@ public PackageSortingDirection SortingDirection
set
{
_sortingDirection = value;
RaisePropertyChanged("SortingDirection");
RaisePropertyChanged(nameof(SortingDirection));
}
}

Expand Down Expand Up @@ -308,7 +322,7 @@ public string SearchText
{
_SearchText = value;
SearchAndUpdateResults();
RaisePropertyChanged("SearchText");
RaisePropertyChanged(nameof(SearchText));
}
}
}
Expand All @@ -329,7 +343,7 @@ public int SelectedIndex
if (_selectedIndex != value)
{
_selectedIndex = value;
RaisePropertyChanged("SelectedIndex");
RaisePropertyChanged(nameof(SelectedIndex));
}
}
}
Expand Down Expand Up @@ -395,7 +409,7 @@ public bool IsAnyFilterOn

private void SetFilterChange()
{
IsAnyFilterOn = HostFilter.Any(f => f.OnChecked) || NonHostFilter.Any(f => f.OnChecked);
IsAnyFilterOn = HostFilter.Any(f => f.OnChecked) || NonHostFilter.Any(f => f.OnChecked) || CompatibilityFilter.Any(f => f.OnChecked);
}

/// <summary>
Expand Down Expand Up @@ -579,9 +593,12 @@ internal PackageManagerSearchViewModel()
SortingDirection = PackageSortingDirection.Descending;
HostFilter = new List<FilterEntry>();
NonHostFilter = new List<FilterEntry>();
CompatibilityFilter = new List<FilterEntry>();
SelectedHosts = new List<string>();
}



/// <summary>
/// Add package information to Lucene index
/// </summary>
Expand Down Expand Up @@ -616,6 +633,7 @@ public PackageManagerSearchViewModel(PackageManagerClientViewModel client) : thi
PackageManagerClientViewModel = client;
HostFilter = InitializeHostFilter();
NonHostFilter = InitializeNonHostFilter();
CompatibilityFilter = InitializeCompatibilityFilter();
InitializeLuceneForPackageManager();
}

Expand Down Expand Up @@ -765,7 +783,18 @@ private List<FilterEntry> InitializeNonHostFilter()
nonHostFilter.ForEach(f => f.PropertyChanged += filter_PropertyChanged);

return nonHostFilter;
}

private List<FilterEntry> InitializeCompatibilityFilter()
{
var compatibilityFilter = new List<FilterEntry>() { new FilterEntry(Resources.PackageCompatible, Resources.PackageFilterByCompatibility, Resources.PackageCompatibleFilterTooltip, this),
new FilterEntry(Resources.PackageUnknownCompatibility, Resources.PackageFilterByCompatibility, Resources.PackageUnknownCompatibilityFilterTooltip, this),
new FilterEntry(Resources.PackageIncompatible, Resources.PackageFilterByCompatibility, Resources.PackageIncompatibleFilterTooltip, this)
};

compatibilityFilter.ForEach(f => f.PropertyChanged += filter_PropertyChanged);

return compatibilityFilter;
}

/// <summary>
Expand Down Expand Up @@ -932,6 +961,15 @@ private void ClearAllFilters(object obj)
}
}

foreach (var filter in CompatibilityFilter)
{
if (filter.OnChecked)
{
filter.OnChecked = false;
filter.FilterCommand.Execute(filter.FilterName);
}
}

RaisePropertyChanged(nameof(IsAnyFilterOn));
}

Expand Down Expand Up @@ -1266,6 +1304,7 @@ internal void SearchAndUpdateResults(string query)
results = Search(query, true);
results = ApplyNonHostFilters(results);
results = ApplyHostFilters(results);
results = ApplyCompatibilityFilters(results);
}

this.ClearSearchResults();
Expand Down Expand Up @@ -1362,6 +1401,7 @@ internal IEnumerable<PackageManagerSearchElementViewModel> GetAllPackages()
var initialResults = LastSync?.Select(x => GetSearchElementViewModel(x));
list = ApplyNonHostFilters(initialResults);
list = ApplyHostFilters(list).ToList();
list = ApplyCompatibilityFilters(list).ToList();

Sort(list, this.SortingKey);

Expand Down Expand Up @@ -1391,6 +1431,34 @@ private List<PackageManagerSearchElementViewModel> ApplyNonHostFilters(IEnumerab
.ToList();
}

/// <summary>
/// Applies the compatibility filters - works on the package versions rather than the packages themselves
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
internal IEnumerable<PackageManagerSearchElementViewModel> ApplyCompatibilityFilters(IEnumerable<PackageManagerSearchElementViewModel> list)
{
// No need to filter by host if nothing selected
if (!CompatibilityFilter.Any(f => f.OnChecked))
{
return list;
}

// Filter the list by checking if the selected version's compatibility matches the filters
IEnumerable<PackageManagerSearchElementViewModel> filteredList = list.Where(x =>
// Apply filter for Compatible (IsSelectedVersionCompatible == true)
CompatibilityFilter.FirstOrDefault(f => f.FilterName.Equals(Wpf.Properties.Resources.PackageCompatible))?.OnChecked == true && x.IsSelectedVersionCompatible == true ||

// Apply filter for Incompatible (IsSelectedVersionCompatible == false)
CompatibilityFilter.FirstOrDefault(f => f.FilterName.Equals(Wpf.Properties.Resources.PackageIncompatible))?.OnChecked == true && x.IsSelectedVersionCompatible == false ||

// Apply filter for Unknown compatibility (IsSelectedVersionCompatible == null)
CompatibilityFilter.FirstOrDefault(f => f.FilterName.Equals(Wpf.Properties.Resources.PackageUnknownCompatibility))?.OnChecked == true && x.IsSelectedVersionCompatible == null
).ToList();

return filteredList;
}

/// <summary>
/// Checks if a package has any dependencies (will always have at least itself as 1 dependency)
/// </summary>
Expand Down Expand Up @@ -1640,6 +1708,9 @@ internal void Dispose()
nonHostFilter?.ForEach(f => f.PropertyChanged -= filter_PropertyChanged);
nonHostFilter.Clear();

compatibilityFilter?.ForEach(f => f.PropertyChanged -= filter_PropertyChanged);
compatibilityFilter.Clear();

if (aTimer != null)
{
aTimer.Stop();
Expand Down
Loading

0 comments on commit 535b00d

Please sign in to comment.