1010using GitHub . Models ;
1111using GitHub . Services ;
1212using ReactiveUI ;
13+ using Rothko ;
1314using Serilog ;
1415
1516namespace GitHub . ViewModels . Dialog . Clone
@@ -19,6 +20,7 @@ namespace GitHub.ViewModels.Dialog.Clone
1920 public class RepositoryCloneViewModel : ViewModelBase , IRepositoryCloneViewModel
2021 {
2122 static readonly ILogger log = LogManager . ForContext < RepositoryCloneViewModel > ( ) ;
23+ readonly IOperatingSystem os ;
2224 readonly IConnectionManager connectionManager ;
2325 readonly IRepositoryCloneService service ;
2426 readonly IReadOnlyList < IRepositoryCloneTabViewModel > tabs ;
@@ -29,12 +31,14 @@ public class RepositoryCloneViewModel : ViewModelBase, IRepositoryCloneViewModel
2931
3032 [ ImportingConstructor ]
3133 public RepositoryCloneViewModel (
34+ IOperatingSystem os ,
3235 IConnectionManager connectionManager ,
3336 IRepositoryCloneService service ,
3437 IRepositorySelectViewModel gitHubTab ,
3538 IRepositorySelectViewModel enterpriseTab ,
3639 IRepositoryUrlViewModel urlTab )
3740 {
41+ this . os = os ;
3842 this . connectionManager = connectionManager ;
3943 this . service = service ;
4044
@@ -61,6 +65,7 @@ public RepositoryCloneViewModel(
6165 ( repo , error ) => ( repo , error ) )
6266 . Select ( x => x . repo != null && x . error == null ) ;
6367
68+ Browse = ReactiveCommand . Create ( ) . OnExecuteCompleted ( _ => BrowseForDirectory ( ) ) ;
6469 Clone = ReactiveCommand . CreateAsyncObservable (
6570 canClone ,
6671 _ => repository . Select ( x => new CloneDialogResult ( Path , x ) ) ) ;
@@ -88,6 +93,8 @@ public int SelectedTabIndex
8893
8994 public IObservable < object > Done => Clone ;
9095
96+ public ReactiveCommand < object > Browse { get ; }
97+
9198 public ReactiveCommand < CloneDialogResult > Clone { get ; }
9299
93100 public async Task InitializeAsync ( IConnection connection )
@@ -114,6 +121,24 @@ public async Task InitializeAsync(IConnection connection)
114121 this . WhenAnyValue ( x => x . SelectedTabIndex ) . Subscribe ( x => tabs [ x ] . Activate ( ) . Forget ( ) ) ;
115122 }
116123
124+ void BrowseForDirectory ( )
125+ {
126+ var result = os . Dialog . BrowseForDirectory ( Path , Resources . BrowseForDirectory ) ;
127+
128+ if ( result != BrowseDirectoryResult . Failed )
129+ {
130+ var path = result . DirectoryPath ;
131+ var selected = tabs [ SelectedTabIndex ] . Repository ;
132+
133+ if ( selected != null )
134+ {
135+ path = System . IO . Path . Combine ( path , selected . Name ) ;
136+ }
137+
138+ Path = path ;
139+ }
140+ }
141+
117142 void UpdatePath ( IRepositoryModel repository )
118143 {
119144 if ( repository != null )
0 commit comments