Skip to content

Commit

Permalink
✨ Add open in Codespaces button
Browse files Browse the repository at this point in the history
Implements #188 (comment)
  • Loading branch information
Lamparter committed Aug 29, 2024
1 parent b4b36b4 commit eac8597
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/FluentHub.App/UserControls/GitCloneFlyout.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@
</StackPanel>
</Button>

<Button
HorizontalAlignment="Stretch"
Click="OpenCodespaceButton_Click"
IsEnabled="True">
<StackPanel Orientation="Horizontal" Spacing="8">
<FontIcon
FontFamily="{StaticResource Octicons}"
FontSize="14"
Glyph="&#xE954;" />
<TextBlock Text="Open in Codespaces" />
</StackPanel>
</Button>

<Button
HorizontalAlignment="Stretch"
Click="DownloadZipButton_Click"
Expand Down
16 changes: 16 additions & 0 deletions src/FluentHub.App/UserControls/GitCloneFlyout.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,23 @@ private async void OpenVSCodeButton_Click(object sender, RoutedEventArgs e)
Log.Error(openCodeUrl, "Something went wrong. Code is not installed or there was another unspecified error.");
}
}
private async void OpenCodespaceButton_Click(object sender, RoutedEventArgs e)
{
string openCodespaceUrl = $"https://github.com/codespaces/new?hide_repo_select=true&repo={ViewModel.Repository.Owner.Login}/{ViewModel.Repository.Name}";

var uri = new Uri(openCodespaceUrl);

var success = await Windows.System.Launcher.LaunchUriAsync(uri);

if (success)
{
Log.Write(Serilog.Events.LogEventLevel.Information, "Opened the repository in Codespaces in the user's local browser.");
}
else
{
Log.Error(openCodespaceUrl, "Something went wrong opening GitHub Codespaces in the user's browser.");
}
}
private async void DownloadZipButton_Click(object sender, RoutedEventArgs e)
{
string downloadZipUrl = _repoUrl + $"/archive/refs/heads/{ViewModel.BranchName}.zip"; // Just made it with the main branch
Expand Down

0 comments on commit eac8597

Please sign in to comment.