Skip to content

Commit 4cb34e9

Browse files
committed
github: add stub WPF-based UI helper for GitHub
1 parent f3d0cf0 commit 4cb34e9

11 files changed

+269
-0
lines changed

Git-Credential-Manager.sln

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.UI.Avalonia", "src\s
5555
EndProject
5656
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atlassian.Bitbucket.UI.Avalonia", "src\shared\Atlassian.Bitbucket.UI.Avalonia\Atlassian.Bitbucket.UI.Avalonia.csproj", "{714ACBE7-0C69-4D8A-9224-22792CAA8264}"
5757
EndProject
58+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.UI.Windows", "src\windows\GitHub.UI.Windows\GitHub.UI.Windows.csproj", "{0A86ED89-1FC5-42AA-925C-4578FA30607A}"
59+
EndProject
5860
Global
5961
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6062
Debug|Any CPU = Debug|Any CPU
@@ -373,6 +375,16 @@ Global
373375
{714ACBE7-0C69-4D8A-9224-22792CAA8264}.MacRelease|Any CPU.Build.0 = Release|Any CPU
374376
{714ACBE7-0C69-4D8A-9224-22792CAA8264}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
375377
{714ACBE7-0C69-4D8A-9224-22792CAA8264}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
378+
{0A86ED89-1FC5-42AA-925C-4578FA30607A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
379+
{0A86ED89-1FC5-42AA-925C-4578FA30607A}.MacDebug|Any CPU.ActiveCfg = Debug|Any CPU
380+
{0A86ED89-1FC5-42AA-925C-4578FA30607A}.Release|Any CPU.ActiveCfg = Release|Any CPU
381+
{0A86ED89-1FC5-42AA-925C-4578FA30607A}.WindowsDebug|Any CPU.ActiveCfg = Debug|Any CPU
382+
{0A86ED89-1FC5-42AA-925C-4578FA30607A}.WindowsDebug|Any CPU.Build.0 = Debug|Any CPU
383+
{0A86ED89-1FC5-42AA-925C-4578FA30607A}.LinuxDebug|Any CPU.ActiveCfg = Debug|Any CPU
384+
{0A86ED89-1FC5-42AA-925C-4578FA30607A}.LinuxRelease|Any CPU.ActiveCfg = Release|Any CPU
385+
{0A86ED89-1FC5-42AA-925C-4578FA30607A}.MacRelease|Any CPU.ActiveCfg = Release|Any CPU
386+
{0A86ED89-1FC5-42AA-925C-4578FA30607A}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
387+
{0A86ED89-1FC5-42AA-925C-4578FA30607A}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
376388
EndGlobalSection
377389
GlobalSection(SolutionProperties) = preSolution
378390
HideSolutionNode = FALSE
@@ -403,6 +415,7 @@ Global
403415
{DE620324-250C-4262-BA13-198FA6FDB82A} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
404416
{459501A8-31E6-41CB-BE54-D31FFF4B2007} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
405417
{714ACBE7-0C69-4D8A-9224-22792CAA8264} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
418+
{0A86ED89-1FC5-42AA-925C-4578FA30607A} = {66722747-1B61-40E4-A89B-1AC8E6D62EA9}
406419
EndGlobalSection
407420
GlobalSection(ExtensibilityGlobals) = postSolution
408421
SolutionGuid = {0EF9FC65-E6BA-45D4-A455-262A9EA4366B}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
using GitHub.UI.ViewModels;
4+
using GitHub.UI.Views;
5+
using Microsoft.Git.CredentialManager;
6+
using Microsoft.Git.CredentialManager.UI;
7+
8+
namespace GitHub.UI.Commands
9+
{
10+
public class CredentialsCommandImpl : CredentialsCommand
11+
{
12+
public CredentialsCommandImpl(ICommandContext context) : base(context) { }
13+
14+
protected override Task ShowAsync(CredentialsViewModel viewModel, CancellationToken ct)
15+
{
16+
return Gui.ShowDialogWindow(viewModel, () => new CredentialsView(), GetParentHandle());
17+
}
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
using GitHub.UI.ViewModels;
4+
using GitHub.UI.Views;
5+
using Microsoft.Git.CredentialManager;
6+
using Microsoft.Git.CredentialManager.UI;
7+
8+
namespace GitHub.UI.Commands
9+
{
10+
public class TwoFactorCommandImpl : TwoFactorCommand
11+
{
12+
public TwoFactorCommandImpl(ICommandContext context) : base(context) { }
13+
14+
protected override Task ShowAsync(TwoFactorViewModel viewModel, CancellationToken ct)
15+
{
16+
return Gui.ShowDialogWindow(viewModel, () => new TwoFactorView(), GetParentHandle());
17+
}
18+
}
19+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<Window x:Class="GitHub.UI.Controls.TesterWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
mc:Ignorable="d"
7+
ResizeMode="NoResize" Width="550" SizeToContent="Height"
8+
Title="GitHub Authentication Dialog Tester">
9+
<TabControl Margin="5,10">
10+
<TabItem Header="Credentials">
11+
<StackPanel>
12+
<Grid>
13+
<Grid.RowDefinitions>
14+
<RowDefinition Height="Auto"/>
15+
<RowDefinition Height="Auto"/>
16+
<RowDefinition Height="Auto"/>
17+
</Grid.RowDefinitions>
18+
<Grid.ColumnDefinitions>
19+
<ColumnDefinition Width="Auto"/>
20+
<ColumnDefinition Width="*"/>
21+
</Grid.ColumnDefinitions>
22+
<Label Grid.Row="0" Grid.Column="0"
23+
Content="Auth Modes" />
24+
<StackPanel Grid.Row="0" Grid.Column="1"
25+
Orientation="Horizontal" VerticalAlignment="Center">
26+
<CheckBox Content="Browser" x:Name="useBrowser" MinWidth="90" IsChecked="True" />
27+
<CheckBox Content="Device" x:Name="useDevice" MinWidth="80" IsChecked="True" />
28+
<CheckBox Content="PAT" x:Name="usePat" MinWidth="80" IsChecked="True" />
29+
<CheckBox Content="Basic" x:Name="useBasic" MinWidth="80" />
30+
</StackPanel>
31+
<Label Grid.Row="1" Grid.Column="0"
32+
Content="Enterprise URL" />
33+
<TextBox Grid.Row="1" Grid.Column="1"
34+
x:Name="enterpriseUrl" />
35+
<Label Grid.Row="2" Grid.Column="0"
36+
Content="Username" />
37+
<TextBox Grid.Row="2" Grid.Column="1"
38+
x:Name="username" />
39+
</Grid>
40+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"
41+
Margin="0,10">
42+
<Button Content="Show" Click="ShowCredentials"
43+
Padding="8,4"/>
44+
</StackPanel>
45+
</StackPanel>
46+
</TabItem>
47+
48+
<TabItem Header="Two-factor">
49+
<StackPanel>
50+
<Grid>
51+
<Grid.RowDefinitions>
52+
<RowDefinition Height="Auto"/>
53+
</Grid.RowDefinitions>
54+
<Grid.ColumnDefinitions>
55+
<ColumnDefinition Width="Auto"/>
56+
<ColumnDefinition Width="*"/>
57+
</Grid.ColumnDefinitions>
58+
<Label Grid.Row="0" Grid.Column="0"
59+
Content="Options" />
60+
<StackPanel Grid.Row="0" Grid.Column="1"
61+
Orientation="Horizontal" VerticalAlignment="Center">
62+
<CheckBox Content="SMS" x:Name="twoFaSms" MinWidth="80" />
63+
</StackPanel>
64+
</Grid>
65+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"
66+
Margin="0,10">
67+
<Button Content="Show" Click="ShowTwoFactorCode"
68+
Padding="8,4"/>
69+
</StackPanel>
70+
</StackPanel>
71+
</TabItem>
72+
</TabControl>
73+
</Window>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System.Windows;
2+
using GitHub.UI.ViewModels;
3+
using GitHub.UI.Views;
4+
using Microsoft.Git.CredentialManager.Interop.Windows;
5+
using Microsoft.Git.CredentialManager.UI.Controls;
6+
7+
namespace GitHub.UI.Controls
8+
{
9+
public partial class TesterWindow : Window
10+
{
11+
private readonly WindowsEnvironment _environment = new WindowsEnvironment(new WindowsFileSystem());
12+
13+
public TesterWindow()
14+
{
15+
InitializeComponent();
16+
}
17+
18+
private void ShowCredentials(object sender, RoutedEventArgs e)
19+
{
20+
var vm = new CredentialsViewModel(_environment)
21+
{
22+
ShowBrowserLogin = useBrowser.IsChecked ?? false,
23+
ShowTokenLogin = usePat.IsChecked ?? false,
24+
ShowBasicLogin = useBasic.IsChecked ?? false,
25+
EnterpriseUrl = enterpriseUrl.Text,
26+
UserName = username.Text
27+
};
28+
var view = new CredentialsView();
29+
var window = new DialogWindow(view) { DataContext = vm };
30+
window.ShowDialog();
31+
}
32+
33+
private void ShowTwoFactorCode(object sender, RoutedEventArgs e)
34+
{
35+
var vm = new TwoFactorViewModel(_environment)
36+
{
37+
IsSms = twoFaSms.IsChecked ?? false,
38+
};
39+
var view = new TwoFactorView();
40+
var window = new DialogWindow(view) { DataContext = vm };
41+
window.ShowDialog();
42+
}
43+
}
44+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net472</TargetFramework>
6+
<UseWPF>true</UseWPF>
7+
<RootNamespace>GitHub.UI</RootNamespace>
8+
<AssemblyName>GitHub.UI</AssemblyName>
9+
<StartupObject>GitHub.UI.Program</StartupObject>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\..\shared\GitHub.UI\GitHub.UI.csproj" />
14+
<ProjectReference Include="..\..\shared\Microsoft.Git.CredentialManager.UI\Microsoft.Git.CredentialManager.UI.csproj" />
15+
<ProjectReference Include="..\Shared.UI.Windows\Shared.UI.Windows.csproj" />
16+
</ItemGroup>
17+
18+
<ItemGroup Condition="'$(OSPlatform)' != 'windows'">
19+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using GitHub.UI.Commands;
4+
using GitHub.UI.Controls;
5+
using Microsoft.Git.CredentialManager;
6+
using Microsoft.Git.CredentialManager.UI;
7+
8+
namespace GitHub.UI
9+
{
10+
public static class Program
11+
{
12+
public static async Task Main(string[] args)
13+
{
14+
string appPath = ApplicationBase.GetEntryApplicationPath();
15+
using (var context = new CommandContext(appPath))
16+
using (var app = new HelperApplication(context))
17+
{
18+
if (args.Length == 0)
19+
{
20+
await Gui.ShowWindow(() => new TesterWindow(), IntPtr.Zero);
21+
return;
22+
}
23+
24+
app.RegisterCommand(new CredentialsCommandImpl(context));
25+
app.RegisterCommand(new TwoFactorCommandImpl(context));
26+
27+
int exitCode = app.RunAsync(args)
28+
.ConfigureAwait(false)
29+
.GetAwaiter()
30+
.GetResult();
31+
32+
Environment.Exit(exitCode);
33+
}
34+
}
35+
}
36+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<UserControl x:Class="GitHub.UI.Views.CredentialsView"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
mc:Ignorable="d">
7+
</UserControl>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Windows.Controls;
3+
using System.Windows.Input;
4+
using System.Windows.Threading;
5+
using GitHub.UI.ViewModels;
6+
7+
namespace GitHub.UI.Views
8+
{
9+
public partial class CredentialsView : UserControl
10+
{
11+
public CredentialsView()
12+
{
13+
InitializeComponent();
14+
}
15+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<UserControl x:Class="GitHub.UI.Views.TwoFactorView"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
mc:Ignorable="d">
7+
</UserControl>

0 commit comments

Comments
 (0)