Skip to content

Commit bda6030

Browse files
committed
bitbucket-ui: add stub UI project
1 parent a9072d6 commit bda6030

File tree

9 files changed

+189
-2
lines changed

9 files changed

+189
-2
lines changed

Git-Credential-Manager.sln

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atlassian.Bitbucket.Tests",
6666
EndProject
6767
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.UI.Windows", "src\windows\Shared.UI.Windows\Shared.UI.Windows.csproj", "{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7}"
6868
EndProject
69+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atlassian.Bitbucket.UI.Windows", "src\windows\Atlassian.Bitbucket.UI.Windows\Atlassian.Bitbucket.UI.Windows.csproj", "{D34D31DF-B44A-45D3-9B39-73573077BAE0}"
70+
EndProject
6971
Global
7072
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7173
Debug|Any CPU = Debug|Any CPU
@@ -244,6 +246,14 @@ Global
244246
{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7}.MacRelease|Any CPU.ActiveCfg = Release|Any CPU
245247
{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
246248
{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
249+
{D34D31DF-B44A-45D3-9B39-73573077BAE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
250+
{D34D31DF-B44A-45D3-9B39-73573077BAE0}.MacDebug|Any CPU.ActiveCfg = Debug|Any CPU
251+
{D34D31DF-B44A-45D3-9B39-73573077BAE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
252+
{D34D31DF-B44A-45D3-9B39-73573077BAE0}.WindowsDebug|Any CPU.ActiveCfg = Debug|Any CPU
253+
{D34D31DF-B44A-45D3-9B39-73573077BAE0}.WindowsDebug|Any CPU.Build.0 = Debug|Any CPU
254+
{D34D31DF-B44A-45D3-9B39-73573077BAE0}.MacRelease|Any CPU.ActiveCfg = Release|Any CPU
255+
{D34D31DF-B44A-45D3-9B39-73573077BAE0}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
256+
{D34D31DF-B44A-45D3-9B39-73573077BAE0}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
247257
EndGlobalSection
248258
GlobalSection(SolutionProperties) = preSolution
249259
HideSolutionNode = FALSE
@@ -268,6 +278,7 @@ Global
268278
{B49881A6-E734-490E-8EA7-FB0D9E296CFB} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
269279
{025E5329-A0B1-4BA9-9203-B70B44A5F9E0} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
270280
{2B3CD8FF-84A6-4B53-A28B-D7A75B0AB4D7} = {66722747-1B61-40E4-A89B-1AC8E6D62EA9}
281+
{D34D31DF-B44A-45D3-9B39-73573077BAE0} = {66722747-1B61-40E4-A89B-1AC8E6D62EA9}
271282
EndGlobalSection
272283
GlobalSection(ExtensibilityGlobals) = postSolution
273284
SolutionGuid = {0EF9FC65-E6BA-45D4-A455-262A9EA4366B}

src/shared/Atlassian.Bitbucket/BitbucketAuthentication.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public async Task<ICredential> GetBasicCredentialsAsync(Uri targetUri, string us
4747
// Shell out to the UI helper and show the Bitbucket u/p prompt
4848
if (Context.SessionManager.IsDesktopSession && TryFindHelperExecutablePath(out string helperPath))
4949
{
50-
var cmdArgs = new StringBuilder("--prompt userpass");
50+
var cmdArgs = new StringBuilder("userpass");
5151
if (!string.IsNullOrWhiteSpace(userName))
5252
{
5353
cmdArgs.AppendFormat(" --username {0}", userName);
@@ -98,7 +98,7 @@ public async Task<bool> ShowOAuthRequiredPromptAsync()
9898
// Shell out to the UI helper and show the Bitbucket prompt
9999
if (Context.SessionManager.IsDesktopSession && TryFindHelperExecutablePath(out string helperPath))
100100
{
101-
IDictionary<string, string> output = await InvokeHelperAsync(helperPath, "--prompt oauth");
101+
IDictionary<string, string> output = await InvokeHelperAsync(helperPath, "oauth");
102102

103103
if (output.TryGetValue("continue", out string continueStr) && continueStr.IsTruthy())
104104
{
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net461</TargetFramework>
6+
<UseWPF>true</UseWPF>
7+
<RootNamespace>Atlassian.Bitbucket.UI</RootNamespace>
8+
<AssemblyName>Atlassian.Bitbucket.UI</AssemblyName>
9+
<StartupObject>Atlassian.Bitbucket.UI.Program</StartupObject>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\..\shared\Microsoft.Git.CredentialManager\Microsoft.Git.CredentialManager.csproj" />
14+
<ProjectReference Include="..\Shared.UI.Windows\Shared.UI.Windows.csproj" />
15+
</ItemGroup>
16+
17+
<ItemGroup Condition="'$(OSPlatform)' != 'windows'">
18+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
19+
</ItemGroup>
20+
21+
</Project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
using Microsoft.Git.CredentialManager.UI;
4+
5+
namespace Atlassian.Bitbucket.UI
6+
{
7+
public class AuthenticationPrompts
8+
{
9+
public AuthenticationPrompts(IGui gui)
10+
{
11+
_gui = gui;
12+
}
13+
14+
private readonly IGui _gui;
15+
16+
public bool ShowCredentialsPrompt(ref string username, out string password)
17+
{
18+
password = null;
19+
return false;
20+
}
21+
22+
public bool ShowOAuthPrompt()
23+
{
24+
return false;
25+
}
26+
}
27+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Windows.Controls;
7+
using Microsoft.Git.CredentialManager;
8+
using Microsoft.Git.CredentialManager.UI;
9+
10+
namespace Atlassian.Bitbucket.UI
11+
{
12+
public static class Program
13+
{
14+
public static void Main(string[] args)
15+
{
16+
IGui gui = new Gui();
17+
18+
try
19+
{
20+
// Show test UI when given no arguments
21+
if (args.Length == 0)
22+
{
23+
gui.ShowDialogWindow(() => new Tester());
24+
}
25+
else
26+
{
27+
var prompts = new AuthenticationPrompts(gui);
28+
var resultDict = new Dictionary<string, string>();
29+
30+
if (StringComparer.OrdinalIgnoreCase.Equals(args[0], "userpass"))
31+
{
32+
string username = CommandLineUtils.GetParameter(args, "--username");
33+
if (prompts.ShowCredentialsPrompt(ref username, out string password))
34+
{
35+
resultDict["username"] = username;
36+
resultDict["password"] = password;
37+
}
38+
else
39+
{
40+
throw new OperationCanceledException("authentication prompt was canceled");
41+
}
42+
}
43+
else if (StringComparer.OrdinalIgnoreCase.Equals(args[0], "oauth"))
44+
{
45+
if (!prompts.ShowOAuthPrompt())
46+
{
47+
throw new OperationCanceledException("authentication prompt was canceled");
48+
}
49+
50+
resultDict["continue"] = "1";
51+
}
52+
else
53+
{
54+
throw new Exception($"unknown argument '{args[0]}'");
55+
}
56+
57+
Console.Out.WriteDictionary(resultDict);
58+
}
59+
}
60+
catch (Exception e)
61+
{
62+
Console.Out.WriteDictionary(new Dictionary<string, string>
63+
{
64+
["error"] = e.Message
65+
});
66+
Environment.Exit(-1);
67+
}
68+
}
69+
}
70+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Window x:Class="Atlassian.Bitbucket.UI.Tester"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
mc:Ignorable="d"
7+
Background="White"
8+
SnapsToDevicePixels="True"
9+
UseLayoutRounding="True"
10+
ResizeMode="NoResize"
11+
Title="Bitbucket Authentication Dialog Tester"
12+
Height="420"
13+
Width="420">
14+
<DockPanel>
15+
<Button Content="Show Credentials Dialog" Padding="10" Click="ShowCredentials" />
16+
<Button Content="Show OAuth Dialog" Padding="10" Click="ShowOAuth" />
17+
</DockPanel>
18+
</Window>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
using System;
4+
using System.Windows;
5+
using System.Windows.Interop;
6+
using Microsoft.Git.CredentialManager.UI;
7+
8+
namespace Atlassian.Bitbucket.UI
9+
{
10+
/// <summary>
11+
/// Interaction logic for Tester.xaml
12+
/// </summary>
13+
public partial class Tester : Window
14+
{
15+
public Tester()
16+
{
17+
InitializeComponent();
18+
}
19+
20+
private IntPtr Handle => new WindowInteropHelper(this).Handle;
21+
22+
private void ShowCredentials(object sender, RoutedEventArgs e)
23+
{
24+
// TODO
25+
var window = new Window();
26+
Gui.ShowDialog(window, Handle);
27+
}
28+
29+
private void ShowOAuth(object sender, RoutedEventArgs e)
30+
{
31+
// TODO
32+
var window = new Window();
33+
Gui.ShowDialog(window, Handle);
34+
}
35+
}
36+
}

src/windows/Installer.Windows/Setup.iss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ Filename: "{app}\git-credential-manager-core.exe"; Parameters: "unconfigure"; Fl
8080

8181
[Files]
8282
Source: "{#PayloadDir}\Atlassian.Bitbucket.dll"; DestDir: "{app}"; Flags: ignoreversion
83+
Source: "{#PayloadDir}\Atlassian.Bitbucket.UI.exe"; DestDir: "{app}"; Flags: ignoreversion
84+
Source: "{#PayloadDir}\Atlassian.Bitbucket.UI.exe.config"; DestDir: "{app}"; Flags: ignoreversion
8385
Source: "{#PayloadDir}\git-credential-manager-core.exe"; DestDir: "{app}"; Flags: ignoreversion
8486
Source: "{#PayloadDir}\git-credential-manager-core.exe.config"; DestDir: "{app}"; Flags: ignoreversion
8587
Source: "{#PayloadDir}\git2-572e4d8.dll"; DestDir: "{app}"; Flags: ignoreversion

src/windows/Payload.Windows/Payload.Windows.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
<ItemGroup>
1212
<ProjectReference Include="..\..\shared\Git-Credential-Manager\Git-Credential-Manager.csproj" />
13+
<ProjectReference Include="..\Atlassian.Bitbucket.UI.Windows\Atlassian.Bitbucket.UI.Windows.csproj" />
1314
<ProjectReference Include="..\GitHub.UI.Windows\GitHub.UI.Windows.csproj" />
1415
</ItemGroup>
1516

@@ -22,6 +23,7 @@
2223
<ItemGroup>
2324
<FilesToSign Include="
2425
$(OutDir)Atlassian.Bitbucket.dll;
26+
$(OutDir)Atlassian.Bitbucket.UI.exe;
2527
$(OutDir)git-credential-manager-core.exe;
2628
$(OutDir)GitHub.dll;
2729
$(OutDir)GitHub.UI.exe;

0 commit comments

Comments
 (0)