Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
Browse files Browse the repository at this point in the history
  • Loading branch information
zeusongit committed Nov 12, 2024
2 parents f8f337c + 7403341 commit 06409fb
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 68 deletions.
2 changes: 2 additions & 0 deletions src/DynamoCoreWpf/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,8 @@ Dynamo.PackageManager.PackageManagerSearchViewModel.FilterEntry.FilterName.get -
Dynamo.PackageManager.PackageManagerSearchViewModel.FilterEntry.FilterName.set -> void
Dynamo.PackageManager.PackageManagerSearchViewModel.FilterEntry.GroupName.get -> string
Dynamo.PackageManager.PackageManagerSearchViewModel.FilterEntry.GroupName.set -> void
Dynamo.PackageManager.PackageManagerSearchViewModel.FilterEntry.IsEnabled.get -> bool
Dynamo.PackageManager.PackageManagerSearchViewModel.FilterEntry.IsEnabled.set -> void
Dynamo.PackageManager.PackageManagerSearchViewModel.FilterEntry.OnChecked.get -> bool
Dynamo.PackageManager.PackageManagerSearchViewModel.FilterEntry.OnChecked.set -> void
Dynamo.PackageManager.PackageManagerSearchViewModel.FilterEntry.Tooltip.get -> string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ public class FilterEntry : NotificationObject
/// </summary>
public string Tooltip { get; set; }

/// <summary>
/// Controls the IsEnabled status of the filter
/// </summary>
private bool isEnabled = true;

public bool IsEnabled
{
get { return isEnabled; }
set
{
isEnabled = value;
RaisePropertyChanged(nameof(IsEnabled));
}
}


/// <summary>
/// Filter entry click command, notice this is a dynamic command
/// with command param set to FilterName so that the code is robust
Expand Down Expand Up @@ -410,6 +426,33 @@ public bool IsAnyFilterOn
private void SetFilterChange()
{
IsAnyFilterOn = HostFilter.Any(f => f.OnChecked) || NonHostFilter.Any(f => f.OnChecked) || CompatibilityFilter.Any(f => f.OnChecked);
ApplyFilterRules();
}

/// <summary>
/// Executes any additional logic on the filters
/// </summary>
internal void ApplyFilterRules()
{
// Enable/disable Compatibility filters if any HostFilter is on
if (CompatibilityFilter.Any(f => f.OnChecked))
{
HostFilter.ForEach(x => x.IsEnabled = false);
}
else
{
HostFilter.ForEach(x => x.IsEnabled = true);
}

// Enable/disable Host filters if any CompatibilityFilter is on
if (HostFilter.Any(f => f.OnChecked))
{
CompatibilityFilter.ForEach(x => x.IsEnabled = false);
}
else
{
CompatibilityFilter.ForEach(x => x.IsEnabled = true);
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@
<Setter Property="Command" Value="{Binding FilterCommand}" />
<Setter Property="CommandParameter" Value="{Binding FilterName}" />
<Setter Property="IsChecked" Value="{Binding OnChecked, UpdateSourceTrigger=PropertyChanged}" />
<Setter Property="IsEnabled" Value="{Binding IsEnabled, UpdateSourceTrigger=PropertyChanged}" />
<Setter Property="ToolTip">
<Setter.Value>
<ToolTip Content="{Binding Tooltip}" Style="{StaticResource GenericToolTipLight}" />
Expand Down
1 change: 0 additions & 1 deletion src/DynamoUtilities/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ static DynamoUtilities.PathHelper.IsValidPath(string filePath) -> bool
static DynamoUtilities.PathHelper.isValidXML(string path, out System.Xml.XmlDocument xmlDoc, out System.Exception ex) -> bool
static DynamoUtilities.PathHelper.LoadEmbeddedResourceAsString(string resourcePath, System.Reflection.Assembly assembly) -> string
static DynamoUtilities.StringUtilities.CapitalizeFirstLetter(string word) -> string
static DynamoUtilities.StringUtilities.SimplifyFileSizeUnit(string size) -> string
static DynamoUtilities.TypeSwitch.Case<T>(System.Action action) -> DynamoUtilities.TypeSwitch.CaseInfo
static DynamoUtilities.TypeSwitch.Case<T>(System.Action<T> action) -> DynamoUtilities.TypeSwitch.CaseInfo
static DynamoUtilities.TypeSwitch.Default(System.Action action) -> DynamoUtilities.TypeSwitch.CaseInfo
Expand Down
21 changes: 6 additions & 15 deletions src/DynamoUtilities/StringUtilities.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DynamoUtilities
{
/// <summary>
Expand All @@ -17,20 +23,5 @@ public static string CapitalizeFirstLetter(string word)

return char.ToUpper(word[0]) + word.Substring(1);
}

/// <summary>
/// Replaces 'i' in a file size string
/// </summary>
/// <param name="size">The file size string</param>
/// <returns></returns>
public static string SimplifyFileSizeUnit(string size)
{
if (string.IsNullOrEmpty(size))
{
return size;
}

return size.Replace("i", "");
}
}
}
5 changes: 2 additions & 3 deletions src/PackageDetailsViewExtension/PackageDetailItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Dynamo.Core;
using Dynamo.PackageManager;
using Dynamo.PythonServices;
using DynamoUtilities;
using Greg.Responses;

namespace Dynamo.PackageDetails
Expand Down Expand Up @@ -284,7 +283,7 @@ public PackageDetailItem(string packageName, PackageVersion packageVersion, bool
this.CopyRightYear = PackageVersion.copyright_year;
this.CanInstall = canInstall;
this.IsEnabledForInstall = isEnabledForInstall && canInstall;
this.PackageSize = string.IsNullOrEmpty(PackageVersion.size) ? "--" : StringUtilities.SimplifyFileSizeUnit (PackageVersion.size);
this.PackageSize = string.IsNullOrEmpty(PackageVersion.size) ? "--" : PackageVersion.size;
this.Created = GetFormattedDate(PackageVersion.created);
this.VersionInformation = GetFlattenedCompatibilityInformation(packageVersion.compatibility_matrix);
this.ReleaseNotes = PackageVersion.release_notes_url;
Expand Down Expand Up @@ -316,7 +315,7 @@ public PackageDetailItem(List<VersionInformation> versionDetails, string package
this.CopyRightYear = PackageVersion.copyright_year;
this.CanInstall = canInstall;
this.IsEnabledForInstall = isEnabledForInstall && canInstall;
this.PackageSize = string.IsNullOrEmpty(PackageVersion.size) ? "--" : StringUtilities.SimplifyFileSizeUnit (PackageVersion.size);
this.PackageSize = string.IsNullOrEmpty(PackageVersion.size) ? "--" : PackageVersion.size;
this.Created = GetFormattedDate(PackageVersion.created);
this.VersionInformation = GetFlattenedCompatibilityInformation(packageVersion.compatibility_matrix);
this.IsCompatible = PackageManager.VersionInformation.GetVersionCompatibility(versionDetails, PackageVersionNumber);
Expand Down
10 changes: 10 additions & 0 deletions src/PackageDetailsViewExtension/PackageDetailsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,16 @@
Margin="10,0"
VerticalAlignment="Center">
<Path Data="M3.57581 8C3.57581 7.17172 3.77783 6.41667 4.18186 5.73485C4.5859 5.05303 5.12882 4.5101 5.81063 4.10606C6.49244 3.70202 7.24748 3.5 8.07576 3.5C8.79292 3.5 9.45453 3.65404 10.0606 3.96212C10.6717 4.2702 11.1767 4.69192 11.5757 5.22727C11.9747 5.75758 12.2222 6.35859 12.3181 7.0303H10.4848C10.3838 6.5101 10.1035 6.08586 9.64392 5.75758C9.18433 5.42424 8.66161 5.25758 8.07576 5.25758C7.57071 5.25758 7.11112 5.38131 6.69699 5.62879C6.28285 5.87626 5.95204 6.20707 5.70457 6.62121C5.4571 7.03535 5.33336 7.49495 5.33336 8C5.33336 8.50505 5.4571 8.96465 5.70457 9.37879C5.95204 9.79293 6.28285 10.1237 6.69699 10.3712C7.11112 10.6187 7.57071 10.7424 8.07576 10.7424C8.66161 10.7424 9.15655 10.5783 9.56059 10.25C9.96968 9.91667 10.2272 9.4899 10.3333 8.9697H12.1666C12.0707 9.64141 11.8358 10.2449 11.4621 10.7803C11.0883 11.3106 10.6086 11.7298 10.0227 12.0379C9.4419 12.346 8.79292 12.5 8.07576 12.5C7.24748 12.5 6.49244 12.298 5.81063 11.8939C5.12882 11.4899 4.5859 10.947 4.18186 10.2652C3.77783 9.58333 3.57581 8.82828 3.57581 8ZM8 16C6.899 16 5.86366 15.7929 4.89398 15.3788C3.92934 14.9646 3.07834 14.3914 2.34097 13.6591C1.60866 12.9217 1.03291 12.0707 0.613721 11.1061C0.199584 10.1414 -0.00495922 9.10606 9.12749e-05 8C0.00514167 6.89394 0.214735 5.85859 0.628872 4.89394C1.04806 3.92929 1.62381 3.08081 2.35612 2.34848C3.08844 1.61111 3.93692 1.03535 4.90155 0.621212C5.86619 0.20707 6.899 0 8 0C9.10605 0 10.1414 0.20707 11.106 0.621212C12.0757 1.03535 12.9242 1.61111 13.6515 2.34848C14.3838 3.08081 14.957 3.92929 15.3711 4.89394C15.7853 5.85859 15.9949 6.89394 15.9999 8C16.005 9.10606 15.8004 10.1414 15.3863 11.1061C14.9721 12.0707 14.3989 12.9217 13.6666 13.6591C12.9343 14.3914 12.0833 14.9646 11.1136 15.3788C10.1439 15.7929 9.10605 16 8 16ZM8 14.2424C8.86363 14.2424 9.67422 14.0808 10.4318 13.7576C11.1894 13.4343 11.8535 12.9874 12.4242 12.4167C12.9949 11.846 13.4419 11.1843 13.7651 10.4318C14.0883 9.67424 14.2474 8.86616 14.2424 8.00758C14.2373 7.14394 14.0732 6.33333 13.7499 5.57576C13.4267 4.81818 12.9797 4.15404 12.409 3.58333C11.8383 3.01263 11.1767 2.56566 10.4242 2.24242C9.6717 1.91919 8.86363 1.75758 8 1.75758C7.14142 1.75758 6.33588 1.91919 5.58336 2.24242C4.83084 2.56566 4.16924 3.01515 3.59854 3.59091C3.02783 4.16162 2.57834 4.82576 2.25007 5.58333C1.92684 6.33586 1.7627 7.14394 1.75765 8.00758C1.7526 8.86111 1.91169 9.66667 2.23491 10.4242C2.55814 11.1768 3.00511 11.8384 3.57581 12.4091C4.15156 12.9798 4.81569 13.4293 5.56821 13.7576C6.32578 14.0808 7.13637 14.2424 8 14.2424Z" Fill="#999999" />
<Viewbox.ToolTip>
<ToolTip>
<ToolTip.Content>
<MultiBinding Converter="{StaticResource CopyrightInfoTooltipConverter}">
<Binding Path="CopyRightHolder" />
<Binding Path="CopyRightYear" />
</MultiBinding>
</ToolTip.Content>
</ToolTip>
</Viewbox.ToolTip>
</Viewbox>
<TextBlock VerticalAlignment="Center"
Foreground="#c7c7c7"
Expand Down
49 changes: 0 additions & 49 deletions test/DynamoCoreTests/StringUtilitiesTest.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,57 @@ public void TestComputeVersionNoDynamoCompatibility()
Assert.IsTrue(resultFallbackToDynamo, "Expected compatibility to be true when under host but only Dynamo compatibility is provided.");
}

[Test]
public void HostCompatibilityFiltersExclusivity()
{
var mockGreg = new Mock<IGregClient>();

var clientMock = new Mock<PackageManagerClient>(mockGreg.Object, MockMaker.Empty<IPackageUploadBuilder>(), string.Empty);
var pmCVM = new Mock<PackageManagerClientViewModel>(ViewModel, clientMock.Object) { CallBase = true };
var pmSVM = new PackageManagerSearchViewModel(pmCVM.Object);
pmSVM.RegisterTransientHandlers();

pmSVM.HostFilter = new List<FilterEntry>
{
new FilterEntry("host", "group", "tooltip", pmSVM) { OnChecked = false },
};

pmSVM.CompatibilityFilter = new List<FilterEntry>
{
new FilterEntry("compatibility", "group", "tooltip", pmSVM) { OnChecked = false },
};

pmSVM.HostFilter.ForEach(f => f.PropertyChanged += pmSVM.filter_PropertyChanged);
pmSVM.CompatibilityFilter.ForEach(f => f.PropertyChanged += pmSVM.filter_PropertyChanged);

Assert.IsTrue(pmSVM.HostFilter.All(x => x.IsEnabled), "Expect starting filter state to be enabled");
Assert.IsTrue(pmSVM.CompatibilityFilter.All(x => x.IsEnabled), "Expect starting filter state to be enabled");

// Act/Assert Host -> Compatibility
pmSVM.HostFilter.First().OnChecked = true;
pmSVM.ApplyFilterRules();

Assert.IsFalse(pmSVM.CompatibilityFilter.All(x => x.IsEnabled), "Filter groups should be mutually exclusive");

pmSVM.HostFilter.First().OnChecked = false;
pmSVM.ApplyFilterRules();

Assert.IsTrue(pmSVM.CompatibilityFilter.All(x => x.IsEnabled), "Filter groups should be mutually exclusive");

// Act/Assert Compatibility -> Host
pmSVM.CompatibilityFilter.First().OnChecked = true;
pmSVM.ApplyFilterRules();

Assert.IsFalse(pmSVM.HostFilter.All(x => x.IsEnabled), "Filter groups should be mutually exclusive");

pmSVM.CompatibilityFilter.First().OnChecked = false;
pmSVM.ApplyFilterRules();

Assert.IsTrue(pmSVM.HostFilter.All(x => x.IsEnabled), "Filter groups should be mutually exclusive");
}

#region Compatibility Tests

[Test]
public void TestReverseDynamoCompatibilityFromHost()
{
Expand Down Expand Up @@ -1329,5 +1380,7 @@ public void IsVersionCompatible_InValidMaxRange_ReturnsTrueForVersionInsideOfMaj
"Expected compatibility to be true when major version is greater than Max major version and there is an invalid max range.");
}

#endregion

}
}

0 comments on commit 06409fb

Please sign in to comment.