This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-24
lines changed
src/GitHub.App/ViewModels/Dialog
test/GitHub.App.UnitTests/ViewModels/Dialog Expand file tree Collapse file tree 2 files changed +7
-24
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . ComponentModel . Composition ;
3
3
using System . Reactive . Linq ;
4
- using GitHub . App ;
5
- using GitHub . Primitives ;
6
4
using GitHub . Services ;
7
5
using ReactiveUI ;
8
6
@@ -28,8 +26,7 @@ public LoginCredentialsViewModel(
28
26
( x , y ) => x . Value || y . Value
29
27
) . ToProperty ( this , vm => vm . IsLoginInProgress ) ;
30
28
31
- UpdateLoginMode ( ) ;
32
- connectionManager . Connections . CollectionChanged += ( _ , __ ) => UpdateLoginMode ( ) ;
29
+ LoginMode = LoginMode . DotComOrEnterprise ;
33
30
34
31
Done = Observable . Merge (
35
32
loginToGitHubViewModel . Login ,
@@ -55,21 +52,5 @@ public LoginMode LoginMode
55
52
public bool IsLoginInProgress { get { return isLoginInProgress . Value ; } }
56
53
57
54
public IObservable < object > Done { get ; }
58
-
59
- void UpdateLoginMode ( )
60
- {
61
- var result = LoginMode . DotComOrEnterprise ;
62
-
63
- foreach ( var connection in ConnectionManager . Connections )
64
- {
65
- if ( connection . IsLoggedIn )
66
- {
67
- result &= ~ ( ( connection . HostAddress == HostAddress . GitHubDotComHostAddress ) ?
68
- LoginMode . DotComOnly : LoginMode . EnterpriseOnly ) ;
69
- }
70
- }
71
-
72
- LoginMode = result ;
73
- }
74
55
}
75
56
}
Original file line number Diff line number Diff line change @@ -76,8 +76,10 @@ public async Task AllowsLoginFromEnterpriseAfterGitHubLoginHasFailedAsync()
76
76
public class TheLoginModeProperty : TestBaseClass
77
77
{
78
78
[ Test ]
79
- public void LoginModeTracksAvailableConnections ( )
79
+ public void LoginModeIgnoresAvailableConnections ( )
80
80
{
81
+ // We always want to option to log-in to GitHub or GitHub Enterprise
82
+
81
83
var connectionManager = Substitute . For < IConnectionManager > ( ) ;
82
84
var connections = new ObservableCollectionEx < IConnection > ( ) ;
83
85
var gitHubLogin = Substitute . For < ILoginToGitHubViewModel > ( ) ;
@@ -96,13 +98,13 @@ public void LoginModeTracksAvailableConnections()
96
98
Assert . That ( LoginMode . DotComOrEnterprise , Is . EqualTo ( loginViewModel . LoginMode ) ) ;
97
99
98
100
connections . Add ( enterpriseConnection ) ;
99
- Assert . That ( LoginMode . DotComOnly , Is . EqualTo ( loginViewModel . LoginMode ) ) ;
101
+ Assert . That ( LoginMode . DotComOrEnterprise , Is . EqualTo ( loginViewModel . LoginMode ) ) ;
100
102
101
103
connections . Add ( gitHubConnection ) ;
102
- Assert . That ( LoginMode . None , Is . EqualTo ( loginViewModel . LoginMode ) ) ;
104
+ Assert . That ( LoginMode . DotComOrEnterprise , Is . EqualTo ( loginViewModel . LoginMode ) ) ;
103
105
104
106
connections . RemoveAt ( 0 ) ;
105
- Assert . That ( LoginMode . EnterpriseOnly , Is . EqualTo ( loginViewModel . LoginMode ) ) ;
107
+ Assert . That ( LoginMode . DotComOrEnterprise , Is . EqualTo ( loginViewModel . LoginMode ) ) ;
106
108
}
107
109
}
108
110
You can’t perform that action at this time.
0 commit comments