Skip to content

Commit fbfe6f9

Browse files
Initial take on fixing sample app source/package links for Labs experimental components
See CommunityToolkit/Windows#587 At least in part, there's many inconsistncies in the Labs packages from changes to templates. Both in inclusion of `.Labs.` in package as well as `.Controls.` or not.
1 parent 58649b8 commit fbfe6f9

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

CommunityToolkit.App.Shared/Renderers/ToolkitDocumentationRenderer.xaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- 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. -->
1+
<!-- 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. -->
22
<Page x:Class="CommunityToolkit.App.Shared.Renderers.ToolkitDocumentationRenderer"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -230,7 +230,7 @@
230230
</StackPanel>
231231
<interactivity:Interaction.Behaviors>
232232
<interactivity:EventTriggerBehavior EventName="Click">
233-
<behaviors:NavigateToUriAction NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToComponentUri(Metadata.ComponentName), Mode=OneWay}" />
233+
<behaviors:NavigateToUriAction NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToComponentUri(Metadata.ComponentName, Metadata.IsExperimental), Mode=OneWay}" />
234234
</interactivity:EventTriggerBehavior>
235235
</interactivity:Interaction.Behaviors>
236236
</Button>
@@ -258,16 +258,16 @@
258258
Text="NuGet package" />
259259
<TextBlock IsTextSelectionEnabled="True">
260260
<Hyperlink FontFamily="Consolas"
261-
NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageUri('Uwp', Metadata.CsProjName), Mode=OneWay}"
261+
NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageUri('Uwp', Metadata.CsProjName, Metadata.IsExperimental), Mode=OneWay}"
262262
TextDecorations="None">
263-
<Run Text="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageName('Uwp', Metadata.CsProjName), Mode=OneWay}" />
263+
<Run Text="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageName('Uwp', Metadata.CsProjName, Metadata.IsExperimental), Mode=OneWay}" />
264264
</Hyperlink>
265265
</TextBlock>
266266
<TextBlock IsTextSelectionEnabled="True">
267267
<Hyperlink FontFamily="Consolas"
268-
NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageUri('WinUI', Metadata.CsProjName), Mode=OneWay}"
268+
NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageUri('WinUI', Metadata.CsProjName, Metadata.IsExperimental), Mode=OneWay}"
269269
TextDecorations="None">
270-
<Run Text="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageName('WinUI', Metadata.CsProjName), Mode=OneWay}" />
270+
<Run Text="{x:Bind renderer:ToolkitDocumentationRenderer.ToPackageName('WinUI', Metadata.CsProjName, Metadata.IsExperimental), Mode=OneWay}" />
271271
</Hyperlink>
272272
</TextBlock>
273273
</StackPanel>

CommunityToolkit.App.Shared/Renderers/ToolkitDocumentationRenderer.xaml.cs

+27-3
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,35 @@ private async void MarkdownTextBlock_LinkClicked(object sender, LinkClickedEvent
216216

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

219-
public static Uri? ToComponentUri(string name) => IsProjectPathValid() ? new Uri($"{ProjectUrl}/tree/main/components/{name}") : null;
219+
public static Uri? ToComponentUri(string name, bool? isExperimental = null)
220+
{
221+
if (IsProjectPathValid() is not true)
222+
{
223+
return null;
224+
}
220225

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

223-
public static string ToPackageName(string platform, string projectFileName) => RemoveFileExtension(projectFileName).Replace("WinUI", platform);
230+
return new Uri($"{url}/tree/main/components/{name}");
231+
}
232+
233+
public static Uri? ToPackageUri(string platform, string projectFileName, bool? isExperimental = null)
234+
{
235+
if (isExperimental is null || isExperimental is false)
236+
{
237+
return new Uri($"https://www.nuget.org/packages/{ToPackageName(platform, projectFileName, isExperimental)}");
238+
}
239+
else
240+
{
241+
// Labs feed for experimental packages (currently)
242+
// See inconsistency for Labs package names/project names https://github.com/CommunityToolkit/Windows/issues/587#issuecomment-2738529086
243+
return new Uri($"https://dev.azure.com/dotnet/CommunityToolkit/_artifacts/feed/CommunityToolkit-Labs/NuGet/{ToPackageName(platform, projectFileName, isExperimental)}");
244+
}
245+
}
246+
247+
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);
224248

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

0 commit comments

Comments
 (0)