Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cross-platform UI based on Avalonia #336

Merged
merged 17 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions Git-Credential-Manager.sln
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Packaging.Linux", "src\linu
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "linux", "linux", "{8F9D7E67-7DD7-4E32-9134-423281AF00E9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.UI", "src\shared\GitHub.UI\GitHub.UI.csproj", "{B5F00B46-FE93-45F2-B283-52B74B3E13B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Atlassian.Bitbucket.UI", "src\shared\Atlassian.Bitbucket.UI\Atlassian.Bitbucket.UI.csproj", "{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Git.CredentialManager.UI", "src\shared\Microsoft.Git.CredentialManager.UI\Microsoft.Git.CredentialManager.UI.csproj", "{001846B0-462B-4A27-90CD-2435D4C0F680}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -315,6 +321,54 @@ Global
{AD2A935F-3720-4802-8119-6A9B35B254DF}.WindowsDebug|Any CPU.ActiveCfg = Debug|Any CPU
{AD2A935F-3720-4802-8119-6A9B35B254DF}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
{AD2A935F-3720-4802-8119-6A9B35B254DF}.LinuxRelease|Any CPU.Build.0 = Release|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.MacDebug|Any CPU.ActiveCfg = Debug|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.MacDebug|Any CPU.Build.0 = Debug|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.MacRelease|Any CPU.ActiveCfg = Release|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.MacRelease|Any CPU.Build.0 = Release|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.Release|Any CPU.Build.0 = Release|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.WindowsDebug|Any CPU.ActiveCfg = Debug|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.WindowsDebug|Any CPU.Build.0 = Debug|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.LinuxDebug|Any CPU.ActiveCfg = Debug|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.LinuxDebug|Any CPU.Build.0 = Debug|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.LinuxRelease|Any CPU.ActiveCfg = Release|Any CPU
{B5F00B46-FE93-45F2-B283-52B74B3E13B9}.LinuxRelease|Any CPU.Build.0 = Release|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.MacDebug|Any CPU.ActiveCfg = Debug|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.MacDebug|Any CPU.Build.0 = Debug|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.MacRelease|Any CPU.ActiveCfg = Release|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.MacRelease|Any CPU.Build.0 = Release|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.Release|Any CPU.Build.0 = Release|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.WindowsDebug|Any CPU.ActiveCfg = Debug|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.WindowsDebug|Any CPU.Build.0 = Debug|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.LinuxDebug|Any CPU.ActiveCfg = Debug|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.LinuxDebug|Any CPU.Build.0 = Debug|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.LinuxRelease|Any CPU.ActiveCfg = Release|Any CPU
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA}.LinuxRelease|Any CPU.Build.0 = Release|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.Debug|Any CPU.Build.0 = Debug|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.MacDebug|Any CPU.ActiveCfg = Debug|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.MacDebug|Any CPU.Build.0 = Debug|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.MacRelease|Any CPU.ActiveCfg = Release|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.MacRelease|Any CPU.Build.0 = Release|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.Release|Any CPU.ActiveCfg = Release|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.Release|Any CPU.Build.0 = Release|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.WindowsDebug|Any CPU.ActiveCfg = Debug|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.WindowsDebug|Any CPU.Build.0 = Debug|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.LinuxDebug|Any CPU.ActiveCfg = Debug|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.LinuxDebug|Any CPU.Build.0 = Debug|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.LinuxRelease|Any CPU.ActiveCfg = Release|Any CPU
{001846B0-462B-4A27-90CD-2435D4C0F680}.LinuxRelease|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -341,6 +395,9 @@ Global
{D34D31DF-B44A-45D3-9B39-73573077BAE0} = {66722747-1B61-40E4-A89B-1AC8E6D62EA9}
{8F9D7E67-7DD7-4E32-9134-423281AF00E9} = {A7FC1234-95E3-4496-B5F7-4306F41E6A0E}
{AD2A935F-3720-4802-8119-6A9B35B254DF} = {8F9D7E67-7DD7-4E32-9134-423281AF00E9}
{B5F00B46-FE93-45F2-B283-52B74B3E13B9} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
{EB1AA840-6FFF-4464-A9B2-0AEA36F615EA} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
{001846B0-462B-4A27-90CD-2435D4C0F680} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0EF9FC65-E6BA-45D4-A455-262A9EA4366B}
Expand Down
19 changes: 19 additions & 0 deletions assets/gcm.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Stretch="Uniform">
<Canvas Name="svg815" Width="256" Height="256">
<Canvas.RenderTransform>
<TranslateTransform X="0" Y="0"/>
</Canvas.RenderTransform>
<Canvas.Resources/>
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path8" Fill="#FFF05033" StrokeThickness="2.24708056">
<Path.Data>
<PathGeometry Figures="m 127.74219 0 c -4.21881 0 -8.43843 1.6093415 -11.65821 4.828125 L 92.875 28.041016 122.31445 57.482422 c 6.84425 -2.310946 14.68947 -0.761046 20.14258 4.693359 5.48141 5.488392 7.0192 13.400136 4.65039 20.267578 l 28.37696 28.376951 c 6.86492 -2.36579 14.78398 -0.83727 20.26562 4.6543 7.66374 7.66179 7.66374 20.07642 0 27.74023 -7.66486 7.66631 -20.07893 7.66631 -27.74805 0 -5.76254 -5.76724 -7.18821 -14.23373 -4.26953 -21.33398 l -26.46289 -26.464844 -0.002 69.640624 c 1.8684 0.92496 3.63248 2.16064 5.18945 3.71094 7.66148 7.6609 7.66148 20.07236 0 27.74609 -7.66374 7.66066 -20.08459 7.66066 -27.74023 0 -7.66262 -7.67305 -7.66262 -20.08452 0 -27.74609 1.89369 -1.89039 4.08382 -3.32218 6.42187 -4.28125 V 94.199219 c -2.33912 -0.955028 -4.52734 -2.375687 -6.42383 -4.28125 -5.80409 -5.799832 -7.20125 -14.319608 -4.22461 -21.447266 L 81.466797 39.443359 4.8300781 116.08203 c -6.4393305 6.44252 -6.4393305 16.88229 0 23.32031 L 42.5 177.07227 V 162.70508 C 35.078345 157.16403 29.678851 149.02425 27.328125 140.07617 19.76286 115.647 40.902921 87.908596 66.359375 88.345703 76.747705 88.003924 87.132367 91.94485 94.875 98.837891 c 18.78493 15.372969 17.87151 47.496839 -0.888672 62.484379 l -2.566406 1.3457 0.222656 12.46503 -8.160156 8.24395 v 34.67578 l 33.119138 33.11915 c 6.43505 6.43757 16.87041 6.43757 23.31446 0 L 251.17188 139.92969 c 6.43732 -6.4407 6.43732 -16.88336 0 -23.32227 l 0.002 -0.01 L 139.39453 4.828125 C 136.1788 1.6093415 131.96099 0 127.74219 0 Z" FillRule="NonZero"/>
</Path.Data>
</Path>
<Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path831" Fill="#FF4D4D4D" StrokeThickness="4.12109041">
<Path.Data>
<PathGeometry Figures="M 67.333984 94.333984 A 35.333332 35.333332 0 0 0 32 129.66602 A 35.333332 35.333332 0 0 0 48.5 159.54688 L 48.5 234.5 L 54.5 240 L 67 240 L 79 228 L 79 216.5 L 73 210 L 79 203.5 L 73 197 L 79 191 L 73 185.5 L 85.5 173 L 85.5 159.92188 A 35.333332 35.333332 0 0 0 102.66602 129.66602 A 35.333332 35.333332 0 0 0 67.333984 94.333984 z M 66.777344 109 A 9 9 0 0 1 75.777344 118 A 9 9 0 0 1 66.777344 127 A 9 9 0 0 1 57.777344 118 A 9 9 0 0 1 66.777344 109 z M 54.5 168 L 60.5 173 L 60.5 234.5 L 54.5 228 L 54.5 168 z " FillRule="NonZero"/>
</Path.Data>
</Path>
</Canvas>
</Viewbox>
24 changes: 22 additions & 2 deletions src/linux/Packaging.Linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ ROOT="$( cd "$THISDIR"/../../.. ; pwd -P )"
SRC="$ROOT/src"
OUT="$ROOT/out"
GCM_SRC="$SRC/shared/Git-Credential-Manager"
BITBUCKET_UI_SRC="$SRC/shared/Atlassian.Bitbucket.UI"
GITHUB_UI_SRC="$SRC/shared/GitHub.UI"
PROJ_OUT="$OUT/linux/Packaging.Linux"

# Build parameters
Expand Down Expand Up @@ -94,8 +96,26 @@ dotnet publish "$GCM_SRC" \
--configuration="$CONFIGURATION" \
--framework="$FRAMEWORK" \
--runtime="$RUNTIME" \
--self-contained=true \
"/p:PublishSingleFile=True" \
--self-contained=true \
-p:PublishSingleFile=true \
--output="$(make_absolute "$PAYLOAD")" || exit 1

echo "Publishing Bitbucket UI helper..."
dotnet publish "$BITBUCKET_UI_SRC" \
--configuration="$CONFIGURATION" \
--framework="$FRAMEWORK" \
--runtime="$RUNTIME" \
--self-contained=true \
-p:PublishSingleFile=true \
--output="$(make_absolute "$PAYLOAD")" || exit 1

echo "Publishing GitHub UI helper..."
dotnet publish "$GITHUB_UI_SRC" \
--configuration="$CONFIGURATION" \
--framework="$FRAMEWORK" \
--runtime="$RUNTIME" \
--self-contained=true \
-p:PublishSingleFile=true \
--output="$(make_absolute "$PAYLOAD")" || exit 1

# Collect symbols
Expand Down
2 changes: 2 additions & 0 deletions src/osx/Installer.Mac/Installer.Mac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

<ItemGroup>
<ProjectReference Include="../../shared/Git-Credential-Manager/Git-Credential-Manager.csproj" ReferenceOutputAssembly="false" />
<ProjectReference Include="../../shared/Atlassian.Bitbucket.UI/Atlassian.Bitbucket.UI.csproj" ReferenceOutputAssembly="false" />
<ProjectReference Include="../../shared/GitHub.UI/GitHub.UI.csproj" ReferenceOutputAssembly="false" />
</ItemGroup>

<!-- Implicit SDK targets import (so we can override the default targets below) -->
Expand Down
16 changes: 16 additions & 0 deletions src/osx/Installer.Mac/layout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ SRC="$ROOT/src"
OUT="$ROOT/out"
INSTALLER_SRC="$SRC/osx/Installer.Mac"
GCM_SRC="$SRC/shared/Git-Credential-Manager"
BITBUCKET_UI_SRC="$SRC/shared/Atlassian.Bitbucket.UI"
GITHUB_UI_SRC="$SRC/shared/GitHub.UI"

# Build parameters
FRAMEWORK=net5.0
Expand Down Expand Up @@ -77,6 +79,20 @@ dotnet publish "$GCM_SRC" \
--runtime="$RUNTIME" \
--output="$(make_absolute "$PAYLOAD")" || exit 1

echo "Publishing Bitbucket UI helper..."
dotnet publish "$BITBUCKET_UI_SRC" \
--configuration="$CONFIGURATION" \
--framework="$FRAMEWORK" \
--runtime="$RUNTIME" \
--output="$(make_absolute "$PAYLOAD")" || exit 1

echo "Publishing GitHub UI helper..."
dotnet publish "$GITHUB_UI_SRC" \
--configuration="$CONFIGURATION" \
--framework="$FRAMEWORK" \
--runtime="$RUNTIME" \
--output="$(make_absolute "$PAYLOAD")" || exit 1

# Collect symbols
echo "Collecting managed symbols..."
mv "$PAYLOAD"/*.pdb "$SYMBOLOUT" || exit 1
Expand Down
7 changes: 6 additions & 1 deletion src/osx/SignFiles.Mac/SignFiles.Mac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@

<ItemGroup>
<FilesToSign Include="
$(OutDir)\Atlassian.Bitbucket.dll;
$(OutDir)\Atlassian.Bitbucket.UI.dll;
$(OutDir)\git-credential-manager-core.dll;
$(OutDir)\GitHub.dll;
$(OutDir)\GitHub.UI.dll;
$(OutDir)\Microsoft.AzureRepos.dll;
$(OutDir)\Microsoft.Git.CredentialManager.dll;">
<Authenticode>Microsoft400</Authenticode>
<InProject>false</InProject>
</FilesToSign>
<MacFilesToSign Include="
$(OutDir)\git-credential-manager-core;">
$(OutDir)\git-credential-manager-core;
$(OutDir)\GitHub.UI;
$(OutDir)\Atlassian.Bitbucket.UI;">
<InProject>false</InProject>
</MacFilesToSign>
</ItemGroup>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/shared/Atlassian.Bitbucket.UI/Atlassian.Bitbucket.UI.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RuntimeIdentifiers>osx-x64;linux-x64</RuntimeIdentifiers>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Atlassian.Bitbucket\Atlassian.Bitbucket.csproj" />
<ProjectReference Include="..\Microsoft.Git.CredentialManager.UI\Microsoft.Git.CredentialManager.UI.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="Controls\TesterWindow.axaml.cs">
<DependentUpon>TesterWindow.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<AvaloniaResource Include="Assets\**" />
</ItemGroup>

</Project>
49 changes: 49 additions & 0 deletions src/shared/Atlassian.Bitbucket.UI/Commands/CredentialsCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Threading;
using System.Threading.Tasks;
using Atlassian.Bitbucket.UI.ViewModels;
using Atlassian.Bitbucket.UI.Views;
using Microsoft.Git.CredentialManager;
using Microsoft.Git.CredentialManager.UI;

namespace Atlassian.Bitbucket.UI.Commands
{
internal class CredentialsCommand : HelperCommand
{
public CredentialsCommand(CommandContext context)
: base(context, "userpass", "Show authentication prompt.")
{
AddOption(
new Option<string>("--username", "Username or email.")
);

Handler = CommandHandler.Create<string>(ExecuteAsync);
}

private async Task<int> ExecuteAsync(string userName)
{
var viewModel = new CredentialsViewModel(Context.Environment)
{
UserName = userName
};

await AvaloniaUi.ShowViewAsync<CredentialsView>(viewModel, GetParentHandle(), CancellationToken.None);

if (!viewModel.WindowResult)
{
throw new Exception("User cancelled dialog.");
}

WriteResult(new Dictionary<string, string>
{
["username"] = viewModel.UserName,
["password"] = viewModel.Password,
});

return 0;
}
}
}
40 changes: 40 additions & 0 deletions src/shared/Atlassian.Bitbucket.UI/Commands/OAuthCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Threading;
using System.Threading.Tasks;
using Atlassian.Bitbucket.UI.ViewModels;
using Atlassian.Bitbucket.UI.Views;
using Microsoft.Git.CredentialManager;
using Microsoft.Git.CredentialManager.UI;

namespace Atlassian.Bitbucket.UI.Commands
{
internal class OAuthCommand : HelperCommand
{
public OAuthCommand(CommandContext context)
: base(context, "oauth", "Show OAuth required prompt.")
{
Handler = CommandHandler.Create(ExecuteAsync);
}

private async Task<int> ExecuteAsync()
{
var viewModel = new OAuthViewModel(Context.Environment);
await AvaloniaUi.ShowViewAsync<OAuthView>(viewModel, GetParentHandle(), CancellationToken.None);

if (!viewModel.WindowResult)
{
throw new Exception("User cancelled dialog.");
}

WriteResult(new Dictionary<string, string>
{
["continue"] = "true"
});

return 0;
}
}
}
13 changes: 13 additions & 0 deletions src/shared/Atlassian.Bitbucket.UI/Controls/TesterWindow.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Atlassian.Bitbucket.UI.Controls.TesterWindow"
Title="Bitbucket Authentication Dialog Tester"
Height="240" Width="420" CanResize="False">
<DockPanel>
<Button Content="Show Credentials Dialog" Padding="10" Click="ShowCredentials" />
<Button Content="Show OAuth Dialog" Padding="10" Click="ShowOAuth" />
</DockPanel>
</Window>
68 changes: 68 additions & 0 deletions src/shared/Atlassian.Bitbucket.UI/Controls/TesterWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using Atlassian.Bitbucket.UI.ViewModels;
using Atlassian.Bitbucket.UI.Views;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Microsoft.Git.CredentialManager;
using Microsoft.Git.CredentialManager.Interop.Linux;
using Microsoft.Git.CredentialManager.Interop.MacOS;
using Microsoft.Git.CredentialManager.Interop.Posix;
using Microsoft.Git.CredentialManager.Interop.Windows;
using Microsoft.Git.CredentialManager.UI.Controls;

namespace Atlassian.Bitbucket.UI.Controls
{
public class TesterWindow : Window
{
private readonly IEnvironment _environment;

public TesterWindow()
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif

if (PlatformUtils.IsWindows())
{
_environment = new WindowsEnvironment(new WindowsFileSystem());
}
else
{
IFileSystem fs;
if (PlatformUtils.IsMacOS())
{
fs = new MacOSFileSystem();
}
else
{
fs = new LinuxFileSystem();
}

_environment = new PosixEnvironment(fs);
}
mjcheetham marked this conversation as resolved.
Show resolved Hide resolved
}

private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}

private void ShowCredentials(object sender, RoutedEventArgs e)
{
var vm = new CredentialsViewModel(_environment);
var view = new CredentialsView();
var window = new DialogWindow(view) {DataContext = vm};
window.ShowDialog(this);
}

private void ShowOAuth(object sender, RoutedEventArgs e)
{
var vm = new OAuthViewModel(_environment);
var view = new OAuthView();
var window = new DialogWindow(view) {DataContext = vm};
window.ShowDialog(this);
}
}
}
Loading