Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 84631f5

Browse files
committed
Replace ActivateItem with open/diff file ommands.
1 parent 3baf00e commit 84631f5

File tree

4 files changed

+19
-48
lines changed

4 files changed

+19
-48
lines changed

src/GitHub.App/SampleData/PullRequestDetailViewModelDesigner.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public PullRequestDetailViewModelDesigner()
7676
public ReactiveCommand<object> ActivateItem { get; }
7777
public ReactiveCommand<object> ToggleChangedFilesView { get; }
7878
public ReactiveCommand<object> ToggleOpenChangedFileAction { get; }
79-
public ReactiveCommand<object> ViewOpenFile { get; }
79+
public ReactiveCommand<object> OpenFile { get; }
80+
public ReactiveCommand<object> DiffFile { get; }
8081
}
8182
}

src/GitHub.App/ViewModels/PullRequestDetailViewModel.cs

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ public PullRequestDetailViewModel(
9797
Checkout = ReactiveCommand.CreateAsyncObservable(canCheckout, DoCheckout);
9898

9999
OpenOnGitHub = ReactiveCommand.Create();
100-
ActivateItem = ReactiveCommand.Create();
101-
ActivateItem.Subscribe(x => DoOpenFile((IPullRequestFileViewModel)x));
102100

103101
ToggleChangedFilesView = ReactiveCommand.Create();
104102
ToggleChangedFilesView.Subscribe(_ =>
@@ -114,7 +112,8 @@ public PullRequestDetailViewModel(
114112
OpenChangedFileAction.Open : OpenChangedFileAction.Diff;
115113
});
116114

117-
ViewOpenFile = ReactiveCommand.Create();
115+
OpenFile = ReactiveCommand.Create();
116+
DiffFile = ReactiveCommand.Create();
118117
}
119118

120119
/// <summary>
@@ -273,16 +272,6 @@ public string CheckoutDisabledMessage
273272
/// </summary>
274273
public ReactiveCommand<object> OpenOnGitHub { get; }
275274

276-
/// <summary>
277-
/// Gets a command that opens the specified file according to <see cref="ChangedFilesView"/>.
278-
/// </summary>
279-
/// <remarks>
280-
/// An <see cref="IPullRequestFileViewModel"/> should be passed as the parameter to this command's
281-
/// Execute method. It triggers <see cref="ViewOpenFile"/> or <see cref="ViewCompareFiles"/> which
282-
/// should be handled by the view to implement opening or comparing the file.
283-
/// </remarks>
284-
public ReactiveCommand<object> ActivateItem { get; }
285-
286275
/// <summary>
287276
/// Gets a command that toggles the <see cref="ChangedFilesView"/> property.
288277
/// </summary>
@@ -294,12 +283,14 @@ public string CheckoutDisabledMessage
294283
public ReactiveCommand<object> ToggleOpenChangedFileAction { get; }
295284

296285
/// <summary>
297-
/// Gets a command that informs the view that the specified file should be opened.
286+
/// Gets a command that opens a <see cref="IPullRequestFileViewModel"/>.
287+
/// </summary>
288+
public ReactiveCommand<object> OpenFile { get; }
289+
290+
/// <summary>
291+
/// Gets a command that diffs a <see cref="IPullRequestFileViewModel"/>.
298292
/// </summary>
299-
/// <remarks>
300-
/// The parameter passed is a string detailing the full path to the file.
301-
/// </remarks>
302-
public ReactiveCommand<object> ViewOpenFile { get; }
293+
public ReactiveCommand<object> DiffFile { get; }
303294

304295
/// <summary>
305296
/// Initializes the view model with new data.
@@ -513,12 +504,5 @@ IObservable<Unit> DoCheckout(object unused)
513504
return Observable.Empty<Unit>();
514505
});
515506
}
516-
517-
void DoOpenFile(IPullRequestFileViewModel x)
518-
{
519-
// TODO: Handle diffing files accoring to OpenChangedFileAction and getting a file from another branch etc.
520-
var fullPath = Path.Combine(repository.LocalPath, x.Path, x.FileName);
521-
ViewOpenFile.Execute(fullPath);
522-
}
523507
}
524508
}

src/GitHub.Exports.Reactive/ViewModels/IPullRequestDetailViewModel.cs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,6 @@ public interface IPullRequestDetailViewModel : IViewModel, IHasBusy
176176
/// </summary>
177177
ReactiveCommand<object> OpenOnGitHub { get; }
178178

179-
/// <summary>
180-
/// Gets a command that opens the specified file according to <see cref="ChangedFilesView"/>.
181-
/// </summary>
182-
/// <remarks>
183-
/// An <see cref="IPullRequestFileViewModel"/> should be passed as the parameter to this command's
184-
/// Execute method. It triggers <see cref="ViewOpenFile"/> or <see cref="ViewCompareFiles"/> which
185-
/// should be handled by the view to implement opening or comparing the file.
186-
/// </remarks>
187-
ReactiveCommand<object> ActivateItem { get; }
188-
189179
/// <summary>
190180
/// Gets a command that toggles the <see cref="ChangedFilesView"/> property.
191181
/// </summary>
@@ -197,11 +187,13 @@ public interface IPullRequestDetailViewModel : IViewModel, IHasBusy
197187
ReactiveCommand<object> ToggleOpenChangedFileAction { get; }
198188

199189
/// <summary>
200-
/// Gets a command that informs the view that the specified file should be opened.
190+
/// Gets a command that opens a <see cref="IPullRequestFileViewModel"/>.
191+
/// </summary>
192+
ReactiveCommand<object> OpenFile { get; }
193+
194+
/// <summary>
195+
/// Gets a command that diffs a <see cref="IPullRequestFileViewModel"/>.
201196
/// </summary>
202-
/// <remarks>
203-
/// The parameter passed is a string detailing the full path to the file.
204-
/// </remarks>
205-
ReactiveCommand<object> ViewOpenFile { get; }
197+
ReactiveCommand<object> DiffFile { get; }
206198
}
207199
}

src/GitHub.VisualStudio/UI/Views/PullRequestDetailView.xaml.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public PullRequestDetailView()
4040
this.WhenActivated(d =>
4141
{
4242
d(ViewModel.OpenOnGitHub.Subscribe(_ => DoOpenOnGitHub()));
43-
d(ViewModel.ViewOpenFile.Subscribe(x => DoOpenFile((string)x)));
4443
});
4544

4645
OpenChangesOptionsMenu = ReactiveCommand.Create();
@@ -111,18 +110,13 @@ void DoOpenChangesOptionsMenu(dynamic o)
111110
menu.IsOpen = true;
112111
}
113112

114-
void DoOpenFile(string fileName)
115-
{
116-
Services.Dte.ItemOperations.OpenFile(fileName);
117-
}
118-
119113
private void FileListMouseDoubleClick(object sender, MouseButtonEventArgs e)
120114
{
121115
var file = (e.OriginalSource as FrameworkElement)?.DataContext as IPullRequestFileViewModel;
122116

123117
if (file != null)
124118
{
125-
ViewModel.ActivateItem.Execute(file);
119+
// TODO: Implement open/diff.
126120
}
127121
}
128122
}

0 commit comments

Comments
 (0)