Skip to content

Commit 1a50e2c

Browse files
authored
Merge pull request #621 from mjcheetham/gitlab-ui
Add GUI prompts for GitLab authentication
2 parents 2a077a8 + abed4b2 commit 1a50e2c

28 files changed

+1650
-86
lines changed

Git-Credential-Manager.sln

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitLab", "src\shared\GitLab
6363
EndProject
6464
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitLab.Tests", "src\shared\GitLab.Tests\GitLab.Tests.csproj", "{1AF9F7C5-FA2E-48F1-B216-4D5E9A27F393}"
6565
EndProject
66+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitLab.UI", "src\shared\GitLab.UI\GitLab.UI.csproj", "{9AFD88E2-7E2C-46DA-9D38-4342086426D3}"
67+
EndProject
68+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitLab.UI.Avalonia", "src\shared\GitLab.UI.Avalonia\GitLab.UI.Avalonia.csproj", "{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}"
69+
EndProject
70+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitLab.UI.Windows", "src\windows\GitLab.UI.Windows\GitLab.UI.Windows.csproj", "{83EAC1F9-8E1F-41FC-8FC9-2C452452D64E}"
71+
EndProject
6672
Global
6773
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6874
Debug|Any CPU = Debug|Any CPU
@@ -433,6 +439,48 @@ Global
433439
{1AF9F7C5-FA2E-48F1-B216-4D5E9A27F393}.MacRelease|Any CPU.Build.0 = Release|Any CPU
434440
{1AF9F7C5-FA2E-48F1-B216-4D5E9A27F393}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
435441
{1AF9F7C5-FA2E-48F1-B216-4D5E9A27F393}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
442+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
443+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
444+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.MacDebug|Any CPU.ActiveCfg = Debug|Any CPU
445+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.MacDebug|Any CPU.Build.0 = Debug|Any CPU
446+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
447+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.Release|Any CPU.Build.0 = Release|Any CPU
448+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.WindowsDebug|Any CPU.ActiveCfg = Debug|Any CPU
449+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.WindowsDebug|Any CPU.Build.0 = Debug|Any CPU
450+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.LinuxDebug|Any CPU.ActiveCfg = Debug|Any CPU
451+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.LinuxDebug|Any CPU.Build.0 = Debug|Any CPU
452+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.LinuxRelease|Any CPU.ActiveCfg = Release|Any CPU
453+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.LinuxRelease|Any CPU.Build.0 = Release|Any CPU
454+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.MacRelease|Any CPU.ActiveCfg = Release|Any CPU
455+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.MacRelease|Any CPU.Build.0 = Release|Any CPU
456+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
457+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
458+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
459+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
460+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.MacDebug|Any CPU.ActiveCfg = Debug|Any CPU
461+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.MacDebug|Any CPU.Build.0 = Debug|Any CPU
462+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
463+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.Release|Any CPU.Build.0 = Release|Any CPU
464+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.WindowsDebug|Any CPU.ActiveCfg = Debug|Any CPU
465+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.WindowsDebug|Any CPU.Build.0 = Debug|Any CPU
466+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.LinuxDebug|Any CPU.ActiveCfg = Debug|Any CPU
467+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.LinuxDebug|Any CPU.Build.0 = Debug|Any CPU
468+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.LinuxRelease|Any CPU.ActiveCfg = Release|Any CPU
469+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.LinuxRelease|Any CPU.Build.0 = Release|Any CPU
470+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.MacRelease|Any CPU.ActiveCfg = Release|Any CPU
471+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.MacRelease|Any CPU.Build.0 = Release|Any CPU
472+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
473+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
474+
{83EAC1F9-8E1F-41FC-8FC9-2C452452D64E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
475+
{83EAC1F9-8E1F-41FC-8FC9-2C452452D64E}.MacDebug|Any CPU.ActiveCfg = Debug|Any CPU
476+
{83EAC1F9-8E1F-41FC-8FC9-2C452452D64E}.Release|Any CPU.ActiveCfg = Release|Any CPU
477+
{83EAC1F9-8E1F-41FC-8FC9-2C452452D64E}.WindowsDebug|Any CPU.ActiveCfg = Debug|Any CPU
478+
{83EAC1F9-8E1F-41FC-8FC9-2C452452D64E}.WindowsDebug|Any CPU.Build.0 = Debug|Any CPU
479+
{83EAC1F9-8E1F-41FC-8FC9-2C452452D64E}.LinuxDebug|Any CPU.ActiveCfg = Debug|Any CPU
480+
{83EAC1F9-8E1F-41FC-8FC9-2C452452D64E}.LinuxRelease|Any CPU.ActiveCfg = Release|Any CPU
481+
{83EAC1F9-8E1F-41FC-8FC9-2C452452D64E}.MacRelease|Any CPU.ActiveCfg = Release|Any CPU
482+
{83EAC1F9-8E1F-41FC-8FC9-2C452452D64E}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
483+
{83EAC1F9-8E1F-41FC-8FC9-2C452452D64E}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
436484
EndGlobalSection
437485
GlobalSection(SolutionProperties) = preSolution
438486
HideSolutionNode = FALSE
@@ -467,6 +515,9 @@ Global
467515
{3F015046-DAF2-4D2A-96EC-F9782F169E45} = {66722747-1B61-40E4-A89B-1AC8E6D62EA9}
468516
{570897DC-A85C-4598-B793-9A00CF710119} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
469517
{1AF9F7C5-FA2E-48F1-B216-4D5E9A27F393} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
518+
{9AFD88E2-7E2C-46DA-9D38-4342086426D3} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
519+
{47186A50-8889-4FC7-8A05-F9FCE7F8F4AE} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
520+
{83EAC1F9-8E1F-41FC-8FC9-2C452452D64E} = {66722747-1B61-40E4-A89B-1AC8E6D62EA9}
470521
EndGlobalSection
471522
GlobalSection(ExtensibilityGlobals) = postSolution
472523
SolutionGuid = {0EF9FC65-E6BA-45D4-A455-262A9EA4366B}

src/linux/Packaging.Linux/build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ OUT="$ROOT/out"
4646
GCM_SRC="$SRC/shared/Git-Credential-Manager"
4747
BITBUCKET_UI_SRC="$SRC/shared/Atlassian.Bitbucket.UI.Avalonia"
4848
GITHUB_UI_SRC="$SRC/shared/GitHub.UI.Avalonia"
49+
GITLAB_UI_SRC="$SRC/shared/GitLab.UI.Avalonia"
4950
PROJ_OUT="$OUT/linux/Packaging.Linux"
5051

5152
# Build parameters
@@ -118,6 +119,15 @@ dotnet publish "$GITHUB_UI_SRC" \
118119
-p:PublishSingleFile=true \
119120
--output="$(make_absolute "$PAYLOAD")" || exit 1
120121

122+
echo "Publishing GitLab UI helper..."
123+
dotnet publish "$GITLAB_UI_SRC" \
124+
--configuration="$CONFIGURATION" \
125+
--framework="$FRAMEWORK" \
126+
--runtime="$RUNTIME" \
127+
--self-contained=true \
128+
-p:PublishSingleFile=true \
129+
--output="$(make_absolute "$PAYLOAD")" || exit 1
130+
121131
# Collect symbols
122132
echo "Collecting managed symbols..."
123133
mv "$PAYLOAD"/*.pdb "$SYMBOLOUT" || exit 1

src/osx/Installer.Mac/layout.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ INSTALLER_SRC="$SRC/osx/Installer.Mac"
2323
GCM_SRC="$SRC/shared/Git-Credential-Manager"
2424
BITBUCKET_UI_SRC="$SRC/shared/Atlassian.Bitbucket.UI.Avalonia"
2525
GITHUB_UI_SRC="$SRC/shared/GitHub.UI.Avalonia"
26+
GITLAB_UI_SRC="$SRC/shared/GitLab.UI.Avalonia"
2627

2728
# Build parameters
2829
FRAMEWORK=net5.0
@@ -99,6 +100,15 @@ dotnet publish "$GITHUB_UI_SRC" \
99100
--runtime="$RUNTIME" \
100101
--output="$(make_absolute "$PAYLOAD")" || exit 1
101102

103+
echo "Publishing GitLab UI helper..."
104+
dotnet publish "$GITLAB_UI_SRC" \
105+
--no-restore \
106+
-m:1 \
107+
--configuration="$CONFIGURATION" \
108+
--framework="$FRAMEWORK" \
109+
--runtime="$RUNTIME" \
110+
--output="$(make_absolute "$PAYLOAD")" || exit 1
111+
102112
# Collect symbols
103113
echo "Collecting managed symbols..."
104114
mv "$PAYLOAD"/*.pdb "$SYMBOLOUT" || exit 1

src/osx/SignFiles.Mac/SignFiles.Mac.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
$(OutDir)\GitHub.UI.dll;
2929
$(OutDir)\GitHub.UI.Shared.dll;
3030
$(OutDir)\GitLab.dll;
31+
$(OutDir)\GitLab.UI.dll;
32+
$(OutDir)\GitLab.UI.Shared.dll;
3133
$(OutDir)\Microsoft.AzureRepos.dll;
3234
$(OutDir)\gcmcore.dll;">
3335
<Authenticode>Microsoft400</Authenticode>
@@ -36,6 +38,7 @@
3638
<MacFilesToSign Include="
3739
$(OutDir)\git-credential-manager-core;
3840
$(OutDir)\GitHub.UI;
41+
$(OutDir)\GitLab.UI;
3942
$(OutDir)\Atlassian.Bitbucket.UI;">
4043
<InProject>false</InProject>
4144
</MacFilesToSign>

src/shared/GitLab.Tests/GitLabAuthenticationTests.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,89 +8,89 @@ namespace GitLab.Tests
88
public class GitLabAuthenticationTests
99
{
1010
[Fact]
11-
public void GitLabAuthentication_GetAuthenticationAsync_AuthenticationModesNone_ThrowsException()
11+
public async Task GitLabAuthentication_GetAuthenticationAsync_AuthenticationModesNone_ThrowsException()
1212
{
1313
var context = new TestCommandContext();
1414
var auth = new GitLabAuthentication(context);
15-
Assert.Throws<ArgumentException>("modes",
16-
() => auth.GetAuthentication(null, null, AuthenticationModes.None)
15+
await Assert.ThrowsAsync<ArgumentException>("modes",
16+
() => auth.GetAuthenticationAsync(null, null, AuthenticationModes.None)
1717
);
1818
}
1919

2020
[Theory]
2121
[InlineData(AuthenticationModes.Browser)]
22-
public void GitLabAuthentication_GetAuthenticationAsync_SingleChoice_TerminalAndInteractionNotRequired(GitLab.AuthenticationModes modes)
22+
public async Task GitLabAuthentication_GetAuthenticationAsync_SingleChoice_TerminalAndInteractionNotRequired(GitLab.AuthenticationModes modes)
2323
{
2424
var context = new TestCommandContext();
2525
context.Settings.IsTerminalPromptsEnabled = false;
2626
context.Settings.IsInteractionAllowed = false;
2727
context.SessionManager.IsDesktopSession = true; // necessary for browser
2828
var auth = new GitLabAuthentication(context);
29-
var result = auth.GetAuthentication(null, null, modes);
29+
var result = await auth.GetAuthenticationAsync(null, null, modes);
3030
Assert.Equal(modes, result.AuthenticationMode);
3131
}
3232

3333
[Fact]
34-
public void GitLabAuthentication_GetAuthenticationAsync_TerminalPromptsDisabled_Throws()
34+
public async Task GitLabAuthentication_GetAuthenticationAsync_TerminalPromptsDisabled_Throws()
3535
{
3636
var context = new TestCommandContext();
3737
context.Settings.IsTerminalPromptsEnabled = false;
3838
var auth = new GitLabAuthentication(context);
39-
var exception = Assert.Throws<InvalidOperationException>(
40-
() => auth.GetAuthentication(null, null, AuthenticationModes.All)
39+
var exception = await Assert.ThrowsAsync<InvalidOperationException>(
40+
() => auth.GetAuthenticationAsync(null, null, AuthenticationModes.All)
4141
);
4242
Assert.Equal("Cannot prompt because terminal prompts have been disabled.", exception.Message);
4343
}
4444

4545
[Fact]
46-
public void GitLabAuthentication_GetAuthenticationAsync_Terminal()
46+
public async Task GitLabAuthentication_GetAuthenticationAsync_Terminal()
4747
{
4848
var context = new TestCommandContext();
4949
var auth = new GitLabAuthentication(context);
5050
context.SessionManager.IsDesktopSession = true;
5151
context.Terminal.Prompts["option (enter for default)"] = "";
52-
var result = auth.GetAuthentication(null, null, AuthenticationModes.All);
52+
var result = await auth.GetAuthenticationAsync(null, null, AuthenticationModes.All);
5353
Assert.Equal(AuthenticationModes.Browser, result.AuthenticationMode);
5454
}
5555

5656
[Fact]
57-
public void GitLabAuthentication_GetAuthenticationAsync_ChoosePat()
57+
public async Task GitLabAuthentication_GetAuthenticationAsync_ChoosePat()
5858
{
5959
var context = new TestCommandContext();
6060
var auth = new GitLabAuthentication(context);
6161
context.Terminal.Prompts["option (enter for default)"] = "";
6262
context.Terminal.Prompts["Username"] = "username";
6363
context.Terminal.SecretPrompts["Personal access token"] = "token";
64-
var result = auth.GetAuthentication(null, null, AuthenticationModes.All);
64+
var result = await auth.GetAuthenticationAsync(null, null, AuthenticationModes.All);
6565
Assert.Equal(AuthenticationModes.Pat, result.AuthenticationMode);
6666
Assert.Equal("username", result.Credential.Account);
6767
Assert.Equal("token", result.Credential.Password);
6868
}
6969

7070
[Fact]
71-
public void GitLabAuthentication_GetAuthenticationAsync_ChooseBasic()
71+
public async Task GitLabAuthentication_GetAuthenticationAsync_ChooseBasic()
7272
{
7373
var context = new TestCommandContext();
7474
var auth = new GitLabAuthentication(context);
7575
context.Terminal.Prompts["option (enter for default)"] = "2";
7676
context.Terminal.Prompts["Username"] = "username";
7777
context.Terminal.SecretPrompts["Password"] = "password";
78-
var result = auth.GetAuthentication(null, null, AuthenticationModes.All);
78+
var result = await auth.GetAuthenticationAsync(null, null, AuthenticationModes.All);
7979
Assert.Equal(AuthenticationModes.Basic, result.AuthenticationMode);
8080
Assert.Equal("username", result.Credential.Account);
8181
Assert.Equal("password", result.Credential.Password);
8282
}
8383

8484
[Fact]
85-
public void GitLabAuthentication_GetAuthenticationAsync_AuthenticationModesAll_RequiresInteraction()
85+
public async Task GitLabAuthentication_GetAuthenticationAsync_AuthenticationModesAll_RequiresInteraction()
8686
{
8787
var context = new TestCommandContext();
8888
context.Settings.IsInteractionAllowed = false;
8989
var auth = new GitLabAuthentication(context);
90-
var exception = Assert.Throws<InvalidOperationException>(
91-
() => auth.GetAuthentication(new Uri("https://GitLab.com"), null, AuthenticationModes.All)
90+
var exception = await Assert.ThrowsAsync<InvalidOperationException>(
91+
() => auth.GetAuthenticationAsync(new Uri("https://GitLab.com"), null, AuthenticationModes.All)
9292
);
9393
Assert.Equal("Cannot prompt because user interactivity has been disabled.", exception.Message);
9494
}
9595
}
96-
}
96+
}
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 GitLab.UI.ViewModels;
4+
using GitLab.UI.Views;
5+
using GitCredentialManager;
6+
using GitCredentialManager.UI;
7+
8+
namespace GitLab.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 AvaloniaUi.ShowViewAsync<CredentialsView>(viewModel, GetParentHandle(), ct);
17+
}
18+
}
19+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<Window xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
x:Class="GitLab.UI.Controls.TesterWindow"
4+
CanResize="False" Width="550" SizeToContent="Height"
5+
Title="GitLab Authentication Dialog Tester">
6+
<TabControl Margin="5,10">
7+
<TabControl.Styles>
8+
<Style Selector="TabItem">
9+
<Setter Property="MinHeight" Value="30" />
10+
<Setter Property="FontSize" Value="12"/>
11+
</Style>
12+
<Style Selector="TabItem > StackPanel">
13+
<Setter Property="Margin" Value="0,10,0,0"/>
14+
</Style>
15+
<Style Selector="TabItem > StackPanel > Grid > Label">
16+
<Setter Property="VerticalAlignment" Value="Center" />
17+
<Setter Property="Margin" Value="0,0,10,0"/>
18+
</Style>
19+
<Style Selector="TabItem > StackPanel > Button">
20+
<Setter Property="Margin" Value="0,10,0,0" />
21+
<Setter Property="Padding" Value="14,10" />
22+
<Setter Property="HorizontalAlignment" Value="Right" />
23+
</Style>
24+
</TabControl.Styles>
25+
<TabItem Header="Credentials">
26+
<StackPanel>
27+
<Grid RowDefinitions="Auto,Auto,Auto" ColumnDefinitions="Auto,*">
28+
<Label Grid.Row="0" Grid.Column="0"
29+
Content="Auth Modes" />
30+
<StackPanel Grid.Row="0" Grid.Column="1"
31+
Orientation="Horizontal" VerticalAlignment="Center">
32+
<CheckBox Content="Browser" x:Name="useBrowser" MinWidth="90" IsChecked="True" />
33+
<CheckBox Content="PAT" x:Name="usePat" MinWidth="80" IsChecked="True" />
34+
<CheckBox Content="Basic" x:Name="useBasic" MinWidth="80" />
35+
</StackPanel>
36+
<Label Grid.Row="1" Grid.Column="0"
37+
Content="Instance URL" />
38+
<TextBox Grid.Row="1" Grid.Column="1"
39+
x:Name="instanceUrl" />
40+
<Label Grid.Row="2" Grid.Column="0"
41+
Content="Username" />
42+
<TextBox Grid.Row="2" Grid.Column="1"
43+
x:Name="username" />
44+
</Grid>
45+
<Button Classes="accent" Content="Show" Click="ShowCredentials" />
46+
</StackPanel>
47+
</TabItem>
48+
</TabControl>
49+
</Window>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using System;
2+
using Avalonia;
3+
using Avalonia.Controls;
4+
using Avalonia.Interactivity;
5+
using Avalonia.Markup.Xaml;
6+
using GitLab.UI.ViewModels;
7+
using GitLab.UI.Views;
8+
using GitCredentialManager;
9+
using GitCredentialManager.Interop.Linux;
10+
using GitCredentialManager.Interop.MacOS;
11+
using GitCredentialManager.Interop.Posix;
12+
using GitCredentialManager.Interop.Windows;
13+
using GitCredentialManager.UI.Controls;
14+
15+
namespace GitLab.UI.Controls
16+
{
17+
public class TesterWindow : Window
18+
{
19+
private readonly IEnvironment _environment;
20+
21+
public TesterWindow()
22+
{
23+
InitializeComponent();
24+
#if DEBUG
25+
this.AttachDevTools();
26+
#endif
27+
28+
if (PlatformUtils.IsWindows())
29+
{
30+
_environment = new WindowsEnvironment(new WindowsFileSystem());
31+
}
32+
else
33+
{
34+
IFileSystem fs;
35+
if (PlatformUtils.IsMacOS())
36+
{
37+
fs = new MacOSFileSystem();
38+
}
39+
else
40+
{
41+
fs = new LinuxFileSystem();
42+
}
43+
44+
_environment = new PosixEnvironment(fs);
45+
}
46+
}
47+
48+
private void InitializeComponent()
49+
{
50+
AvaloniaXamlLoader.Load(this);
51+
}
52+
53+
private void ShowCredentials(object sender, RoutedEventArgs e)
54+
{
55+
var vm = new CredentialsViewModel(_environment)
56+
{
57+
ShowBrowserLogin = this.FindControl<CheckBox>("useBrowser").IsChecked ?? false,
58+
ShowTokenLogin = this.FindControl<CheckBox>("usePat").IsChecked ?? false,
59+
ShowBasicLogin = this.FindControl<CheckBox>("useBasic").IsChecked ?? false,
60+
Url = this.FindControl<TextBox>("instanceUrl").Text,
61+
UserName = this.FindControl<TextBox>("username").Text
62+
};
63+
var view = new CredentialsView();
64+
var window = new DialogWindow(view) {DataContext = vm};
65+
window.ShowDialog(this);
66+
}
67+
}
68+
}

0 commit comments

Comments
 (0)