Skip to content

Commit e4d3ac6

Browse files
authored
Merge pull request #116 from mjcheetham/bbui
Add Bitbucket Windows UI project
2 parents 8e95c36 + 935766c commit e4d3ac6

33 files changed

+2134
-5
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
{

src/shared/Microsoft.Git.CredentialManager/EnsureArgument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Microsoft.Git.CredentialManager
66
{
77
public static class EnsureArgument
88
{
9-
public static void NotNull<T>(T arg, string name) where T : class
9+
public static void NotNull<T>(T arg, string name)
1010
{
1111
if (arg is null)
1212
{
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
<ItemGroup>
22+
<None Remove="Images\[email protected]" />
23+
<None Remove="Images\Bitbucket-16x16.ico" />
24+
<None Remove="Images\error.png" />
25+
<Resource Include="Images\[email protected]" />
26+
<Resource Include="Images\Bitbucket-16x16.ico" />
27+
<Resource Include="Images\error.png" />
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<Compile Update="BitbucketResources.Designer.cs">
32+
<DesignTime>True</DesignTime>
33+
<AutoGen>True</AutoGen>
34+
<DependentUpon>BitbucketResources.resx</DependentUpon>
35+
</Compile>
36+
</ItemGroup>
37+
38+
<ItemGroup>
39+
<EmbeddedResource Update="BitbucketResources.resx">
40+
<Generator>PublicResXFileCodeGenerator</Generator>
41+
<LastGenOutput>BitbucketResources.Designer.cs</LastGenOutput>
42+
</EmbeddedResource>
43+
</ItemGroup>
44+
45+
<ItemGroup>
46+
<Page Update="Styles.xaml">
47+
<Generator>MSBuild:Compile</Generator>
48+
</Page>
49+
</ItemGroup>
50+
51+
</Project>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
using Atlassian.Bitbucket.UI.Controls;
4+
using Atlassian.Bitbucket.UI.ViewModels;
5+
using Microsoft.Git.CredentialManager.UI;
6+
7+
namespace Atlassian.Bitbucket.UI
8+
{
9+
public class AuthenticationPrompts
10+
{
11+
public AuthenticationPrompts(IGui gui)
12+
{
13+
_gui = gui;
14+
}
15+
16+
private readonly IGui _gui;
17+
18+
public bool ShowCredentialsPrompt(ref string username, out string password)
19+
{
20+
// If there is a user in the remote URL then populate the UI with it.
21+
var credentialViewModel = new CredentialsViewModel(username);
22+
23+
bool credentialValid = _gui.ShowDialogWindow(credentialViewModel, () => new CredentialsControl());
24+
25+
username = credentialViewModel.Login;
26+
password = credentialViewModel.Password.ToUnsecureString();
27+
28+
return credentialValid;
29+
}
30+
31+
public bool ShowOAuthPrompt()
32+
{
33+
var oauthViewModel = new OAuthViewModel();
34+
35+
bool useOAuth = _gui.ShowDialogWindow(oauthViewModel, () => new OAuthControl());
36+
37+
return useOAuth;
38+
}
39+
}
40+
}

src/windows/Atlassian.Bitbucket.UI.Windows/BitbucketResources.Designer.cs

Lines changed: 234 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)