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

Add package links to Package details view #12877

Merged
merged 6 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,7 @@
<Resource Include="UI\Images\folder-hover-16px.png" />
<Resource Include="UI\Images\up_16_16.png" />
<Resource Include="UI\Images\up-hover-16px.png" />
<Resource Include="UI\Images\link-16px.png" />
<EmbeddedResource Include="Controls\Docs\NodeAutocompleteDocumentation.html" />
<Content Include="sharpdx_direct3d11_effects_x64.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
18 changes: 18 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.

6 changes: 6 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3144,4 +3144,10 @@ To install the latest version of a package, click Install. \n
<data name="OnboardingGuideRunGraphTitle" xml:space="preserve">
<value>Run the graph</value>
</data>
<data name="PackageRepositoryLabel" xml:space="preserve">
<value>Repository</value>
</data>
<data name="PackageWebsiteLabel" xml:space="preserve">
<value>Website</value>
</data>
</root>
6 changes: 6 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3131,4 +3131,10 @@ To install the latest version of a package, click Install. \n
<data name="OnboardingGuideRunGraphTitle" xml:space="preserve">
<value>Run the graph</value>
</data>
<data name="PackageRepositoryLabel" xml:space="preserve">
<value>Repository</value>
</data>
<data name="PackageWebsiteLabel" xml:space="preserve">
<value>Website</value>
</data>
</root>
26 changes: 26 additions & 0 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ public object ConvertBack(object value, Type targetType, object parameter,
}
}

/// <summary>
/// If the given string is empty, collapsed visibility enum is returned, otherwise visible enum is returned.
/// </summary>
public class EmptyStringToCollapsedConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
Expand All @@ -378,6 +381,29 @@ public object ConvertBack(object value, Type targetType, object parameter,
}
}

/// <summary>
/// If the given string is empty, hidden visibility enum is returned, otherwise visible enum is returned.
/// </summary>
public class EmptyStringToHiddenConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
CultureInfo culture)
{
if (value is string && !string.IsNullOrEmpty(value as string))
{
return Visibility.Visible;
}

return Visibility.Hidden;
}

public object ConvertBack(object value, Type targetType, object parameter,
CultureInfo culture)
{
return null;
}
}

/// <summary>
/// Converts any numbers below 0 to 0, otherwise returns the original number.
/// For example, used to display the number of votes each package has received in the package manager.
Expand Down
Binary file added src/DynamoCoreWpf/UI/Images/link-16px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions src/PackageDetailsViewExtension/PackageDetailsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<controls:NegativeIntToZeroConverter x:Key="NegativeIntToZeroConverter" />
<controls:InverseBooleanConverter x:Key="InverseBooleanConverter" />
<controls:PrettyDateConverter x:Key="PrettyDateConverter" />
<controls:EmptyStringToHiddenConverter x:Key="EmptyStringToHiddenConverter" />
<Style x:Key="LabelStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="{StaticResource ArtifaktElementBold}" />
<Setter Property="FontWeight" Value="Bold" />
Expand All @@ -39,6 +40,16 @@
<Setter Property="Margin" Value="0,0,0,5" />
<Setter Property="TextWrapping" Value="Wrap" />
</Style>
<Style x:Key="BodyLinkStyle" TargetType="Hyperlink">
<Setter Property="FontFamily" Value="{StaticResource ArtifaktElementRegular}" />
<Setter Property="FontSize" Value="14px" />
<Setter Property="Foreground" Value="{StaticResource Blue300Brush}" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{StaticResource Blue400Brush}" />
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="BorderStyle" TargetType="Border">
<Setter Property="CornerRadius" Value="3" />
<Setter Property="Margin" Value="0,0,11,0" />
Expand Down Expand Up @@ -434,6 +445,50 @@
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
<!-- Links -->
<StackPanel MinWidth="200"
Margin="0,10,0,10"
Orientation="Horizontal"
Visibility="{Binding PackageSiteURL, Converter={StaticResource EmptyStringToHiddenConverter}}">
<Rectangle Name="PackageLinkIcon"
Width="16px"
Height="16px">
<Rectangle.Fill>
<ImageBrush ImageSource="/DynamoCoreWpf;component/UI/Images/link-16px.png" />
</Rectangle.Fill>
</Rectangle>
<TextBlock Name="PackageWebsiteLink"
Margin="8,0,0,0">
<Hyperlink NavigateUri="{Binding PackageSiteURL}"
RequestNavigate="Hyperlink_RequestNavigate"
TextDecorations="None"
Style="{StaticResource BodyLinkStyle}">
<TextBlock Name="PackageWebsiteLinkText" Text="{x:Static p:Resources.PackageWebsiteLabel}" />
</Hyperlink>
</TextBlock>

</StackPanel>
<StackPanel MinWidth="200"
Margin="0,0,0,10"
Orientation="Horizontal"
Visibility="{Binding PackageRepositoryURL, Converter={StaticResource EmptyStringToHiddenConverter}}">
<Rectangle Name="RepositoryLinkIcon"
Width="16px"
Height="16px">
<Rectangle.Fill>
<ImageBrush ImageSource="/DynamoCoreWpf;component/UI/Images/link-16px.png" />
</Rectangle.Fill>
</Rectangle>
<TextBlock Name="PackageRepositoryLink"
Margin="8,0,0,0">
<Hyperlink NavigateUri="{Binding PackageRepositoryURL}"
RequestNavigate="Hyperlink_RequestNavigate"
TextDecorations="None"
Style="{StaticResource BodyLinkStyle}">
<TextBlock Name="PackageRepositoryLinkText" Text="{x:Static p:Resources.PackageRepositoryLabel}" />
</Hyperlink>
</TextBlock>
</StackPanel>
</StackPanel>
</ScrollViewer>
</Grid>
Expand Down
7 changes: 7 additions & 0 deletions src/PackageDetailsViewExtension/PackageDetailsView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Navigation;

namespace Dynamo.PackageDetails
{
Expand Down Expand Up @@ -34,5 +35,11 @@ private void FrameworkElement_OnDataContextChanged(object sender, DependencyProp
{
MainScrollViewer.ScrollToTop();
}

private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
System.Diagnostics.Process.Start(e.Uri.ToString());
e.Handled = true;
}
}
}
14 changes: 13 additions & 1 deletion src/PackageDetailsViewExtension/PackageDetailsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ public string License
/// </summary>
public bool IsPackageDeprecated { get; }

/// <summary>
/// The site URL of the package whose details are being inspected.
/// </summary>
public string PackageSiteURL { get; }

/// <summary>
/// The repository URL of the package whose details are being inspected.
/// </summary>
public string PackageRepositoryURL { get; }

/// <summary>
/// A reference to the ViewExtension.
/// </summary>
Expand Down Expand Up @@ -199,8 +209,10 @@ PackageManagerSearchElement packageManagerSearchElement
IsPackageDeprecated = packageManagerSearchElement.IsDeprecated;
PackageDetailsViewExtension = packageDetailsViewExtension;
License = packageManagerSearchElement.Header.license;
PackageSiteURL = packageManagerSearchElement.SiteUrl;
PackageRepositoryURL = packageManagerSearchElement.RepositoryUrl;

if(!Models.DynamoModel.IsTestMode)
if (!Models.DynamoModel.IsTestMode)
{
packageLoader.PackageAdded += PackageLoaderOnPackageAdded;
}
Expand Down