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 11using System ;
22using System . ComponentModel . Composition ;
33using System . Reactive . Linq ;
4- using GitHub . App ;
5- using GitHub . Primitives ;
64using GitHub . Services ;
75using ReactiveUI ;
86
@@ -28,8 +26,7 @@ public LoginCredentialsViewModel(
2826 ( x , y ) => x . Value || y . Value
2927 ) . ToProperty ( this , vm => vm . IsLoginInProgress ) ;
3028
31- UpdateLoginMode ( ) ;
32- connectionManager . Connections . CollectionChanged += ( _ , __ ) => UpdateLoginMode ( ) ;
29+ LoginMode = LoginMode . DotComOrEnterprise ;
3330
3431 Done = Observable . Merge (
3532 loginToGitHubViewModel . Login ,
@@ -55,21 +52,5 @@ public LoginMode LoginMode
5552 public bool IsLoginInProgress { get { return isLoginInProgress . Value ; } }
5653
5754 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- }
7455 }
7556}
Original file line number Diff line number Diff line change @@ -76,8 +76,10 @@ public async Task AllowsLoginFromEnterpriseAfterGitHubLoginHasFailedAsync()
7676 public class TheLoginModeProperty : TestBaseClass
7777 {
7878 [ Test ]
79- public void LoginModeTracksAvailableConnections ( )
79+ public void LoginModeIgnoresAvailableConnections ( )
8080 {
81+ // We always want to option to log-in to GitHub or GitHub Enterprise
82+
8183 var connectionManager = Substitute . For < IConnectionManager > ( ) ;
8284 var connections = new ObservableCollectionEx < IConnection > ( ) ;
8385 var gitHubLogin = Substitute . For < ILoginToGitHubViewModel > ( ) ;
@@ -96,13 +98,13 @@ public void LoginModeTracksAvailableConnections()
9698 Assert . That ( LoginMode . DotComOrEnterprise , Is . EqualTo ( loginViewModel . LoginMode ) ) ;
9799
98100 connections . Add ( enterpriseConnection ) ;
99- Assert . That ( LoginMode . DotComOnly , Is . EqualTo ( loginViewModel . LoginMode ) ) ;
101+ Assert . That ( LoginMode . DotComOrEnterprise , Is . EqualTo ( loginViewModel . LoginMode ) ) ;
100102
101103 connections . Add ( gitHubConnection ) ;
102- Assert . That ( LoginMode . None , Is . EqualTo ( loginViewModel . LoginMode ) ) ;
104+ Assert . That ( LoginMode . DotComOrEnterprise , Is . EqualTo ( loginViewModel . LoginMode ) ) ;
103105
104106 connections . RemoveAt ( 0 ) ;
105- Assert . That ( LoginMode . EnterpriseOnly , Is . EqualTo ( loginViewModel . LoginMode ) ) ;
107+ Assert . That ( LoginMode . DotComOrEnterprise , Is . EqualTo ( loginViewModel . LoginMode ) ) ;
106108 }
107109 }
108110
You can’t perform that action at this time.
0 commit comments