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

Initial take on fixing sample app source/package links for Labs experimental components #275

Merged
merged 1 commit into from
Apr 3, 2025
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
@@ -1,4 +1,4 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Page x:Class="CommunityToolkit.App.Shared.Renderers.ToolkitDocumentationRenderer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand Down Expand Up @@ -230,7 +230,7 @@
</StackPanel>
<interactivity:Interaction.Behaviors>
<interactivity:EventTriggerBehavior EventName="Click">
<behaviors:NavigateToUriAction NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToComponentUri(Metadata.ComponentName), Mode=OneWay}" />
<behaviors:NavigateToUriAction NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToComponentUri(Metadata.ComponentName, Metadata.IsExperimental), Mode=OneWay}" />
</interactivity:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Button>
Expand Down Expand Up @@ -258,16 +258,16 @@
Text="NuGet package" />
<TextBlock IsTextSelectionEnabled="True">
<Hyperlink FontFamily="Consolas"
NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageUri('Uwp', Metadata.CsProjName), Mode=OneWay}"
NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageUri('Uwp', Metadata.CsProjName, Metadata.IsExperimental), Mode=OneWay}"
TextDecorations="None">
<Run Text="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageName('Uwp', Metadata.CsProjName), Mode=OneWay}" />
<Run Text="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageName('Uwp', Metadata.CsProjName, Metadata.IsExperimental), Mode=OneWay}" />
</Hyperlink>
</TextBlock>
<TextBlock IsTextSelectionEnabled="True">
<Hyperlink FontFamily="Consolas"
NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageUri('WinUI', Metadata.CsProjName), Mode=OneWay}"
NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageUri('WinUI', Metadata.CsProjName, Metadata.IsExperimental), Mode=OneWay}"
TextDecorations="None">
<Run Text="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageName('WinUI', Metadata.CsProjName), Mode=OneWay}" />
<Run Text="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageName('WinUI', Metadata.CsProjName, Metadata.IsExperimental), Mode=OneWay}" />
</Hyperlink>
</TextBlock>
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,35 @@ private async void MarkdownTextBlock_LinkClicked(object sender, LinkClickedEvent

public static Uri? ToGitHubUri(string path, int id) => IsProjectPathValid() ? new Uri($"{ProjectUrl}/{path}/{id}") : null;

public static Uri? ToComponentUri(string name) => IsProjectPathValid() ? new Uri($"{ProjectUrl}/tree/main/components/{name}") : null;
public static Uri? ToComponentUri(string name, bool? isExperimental = null)
{
if (IsProjectPathValid() is not true)
{
return null;
}

public static Uri? ToPackageUri(string platform, string projectFileName) => new Uri($"https://www.nuget.org/packages/{RemoveFileExtension(projectFileName).Replace("WinUI", platform)}");
string? url = (isExperimental is null || isExperimental is false)
? ProjectUrl
: ProjectUrl?.Replace("Windows", "Labs-Windows");

public static string ToPackageName(string platform, string projectFileName) => RemoveFileExtension(projectFileName).Replace("WinUI", platform);
return new Uri($"{url}/tree/main/components/{name}");
}

public static Uri? ToPackageUri(string platform, string projectFileName, bool? isExperimental = null)
{
if (isExperimental is null || isExperimental is false)
{
return new Uri($"https://www.nuget.org/packages/{ToPackageName(platform, projectFileName, isExperimental)}");
}
else
{
// Labs feed for experimental packages (currently)
// See inconsistency for Labs package names/project names https://github.com/CommunityToolkit/Windows/issues/587#issuecomment-2738529086
return new Uri($"https://dev.azure.com/dotnet/CommunityToolkit/_artifacts/feed/CommunityToolkit-Labs/NuGet/{ToPackageName(platform, projectFileName, isExperimental)}");
}
}

public static string ToPackageName(string platform, string projectFileName, bool? isExperimental) => RemoveFileExtension(projectFileName).Replace("CommunityToolkit.WinUI", isExperimental == true ? "CommunityToolkit.Labs.WinUI" : "CommunityToolkit.WinUI").Replace("WinUI", platform);

// TODO: Think this is most of the special cases with Controls and the Extensions/Triggers using the base namespace
// See: https://github.com/CommunityToolkit/Tooling-Windows-Submodule/issues/105#issuecomment-1698306420
Expand Down
Loading