diff --git a/Source/TeamMate/Model/ProjectContextSerializer.cs b/Source/TeamMate/Model/ProjectContextSerializer.cs index 7f82b6f..d6a071b 100644 --- a/Source/TeamMate/Model/ProjectContextSerializer.cs +++ b/Source/TeamMate/Model/ProjectContextSerializer.cs @@ -1,4 +1,5 @@ -using Microsoft.Tools.TeamMate.Foundation.Collections; +using Microsoft.TeamFoundation.SourceControl.WebApi; +using Microsoft.Tools.TeamMate.Foundation.Collections; using Microsoft.Tools.TeamMate.Foundation.Diagnostics; using Microsoft.Tools.TeamMate.Foundation.Xml; using Microsoft.Tools.TeamMate.Model.Settings; @@ -74,6 +75,8 @@ namespace Microsoft.Tools.TeamMate.Model query.Name = e.GetAttribute(Schema.Name); query.ReviewStatus = e.GetAttribute(Schema.ReviewStatus); + query.AssignedTo = e.GetAttribute(Schema.AssignedTo); + query.CreatedBy = e.GetAttribute(Schema.CreatedBy); return query; } @@ -140,6 +143,8 @@ namespace Microsoft.Tools.TeamMate.Model XElement e = new XElement(Schema.PullRequestQueryInfo); e.SetAttribute(Schema.Name, query.Name); e.SetAttribute(Schema.ReviewStatus, query.ReviewStatus); + e.SetAttribute(Schema.CreatedBy, query.CreatedBy); + e.SetAttribute(Schema.AssignedTo, query.AssignedTo); return e; } @@ -322,7 +327,7 @@ namespace Microsoft.Tools.TeamMate.Model result.SetAttribute(Schema.Date, entry.Date); WorkItemReference workItemReference = entry.Key as WorkItemReference; - PullRequestReference pullRequestReference = entry.Key as PullRequestReference; + GitPullRequest pullRequestReference = entry.Key as GitPullRequest; if (workItemReference != null) { result.Add(WriteWorkItemReference(workItemReference)); @@ -330,8 +335,8 @@ namespace Microsoft.Tools.TeamMate.Model else if (pullRequestReference != null) { XElement e = new XElement(Schema.PullRequest); - e.SetAttribute(Schema.PullRequestProjectId, pullRequestReference.ProjectId); - e.SetAttribute(Schema.PullRequestId, pullRequestReference.Id); + e.SetAttribute(Schema.PullRequestProjectId, pullRequestReference.Repository.Id); + e.SetAttribute(Schema.PullRequestId, pullRequestReference.PullRequestId); result.Add(e); } else diff --git a/Source/TeamMate/Model/PullRequestQueryInfo.cs b/Source/TeamMate/Model/PullRequestQueryInfo.cs index c9391b9..7995b32 100644 --- a/Source/TeamMate/Model/PullRequestQueryInfo.cs +++ b/Source/TeamMate/Model/PullRequestQueryInfo.cs @@ -16,6 +16,9 @@ namespace Microsoft.Tools.TeamMate.Model public string Name { get; set; } public PullRequestQueryReviewStatus ReviewStatus { get; set; } + public string CreatedBy { get; set; } + + public string AssignedTo { get; set; } } public enum PullRequestQueryReviewStatus { @@ -26,7 +29,7 @@ namespace Microsoft.Tools.TeamMate.Model Completed, [Description("All")] - All + All, } } diff --git a/Source/TeamMate/ViewModels/PullRequestPageViewModel.cs b/Source/TeamMate/ViewModels/PullRequestPageViewModel.cs index f7ed720..0427fb7 100644 --- a/Source/TeamMate/ViewModels/PullRequestPageViewModel.cs +++ b/Source/TeamMate/ViewModels/PullRequestPageViewModel.cs @@ -58,6 +58,8 @@ namespace Microsoft.Tools.TeamMate.ViewModels var actionableFilter = new ListViewFilter("Assigned To Me", (o) => ((PullRequestRowViewModel)o).IsAssignedToMe); model.Filters.Add(actionableFilter); + var createByActionableFilter = new ListViewFilter("Created By Me", (o) => ((PullRequestRowViewModel)o).IsOwnedByMe); + model.Filters.Add(createByActionableFilter); model.Filters.Add(new ListViewFilter("Pending", (o) => ((PullRequestRowViewModel)o).IsPending)); model.Filters.Add(new ListViewFilter("Waiting", (o) => ((PullRequestRowViewModel)o).IsWaiting)); model.Filters.Add(new ListViewFilter("Signed Off", (o) => ((PullRequestRowViewModel)o).IsSignedOff)); diff --git a/Source/TeamMate/ViewModels/PullRequestPickerViewModel.cs b/Source/TeamMate/ViewModels/PullRequestPickerViewModel.cs index b5ce21e..e498d72 100644 --- a/Source/TeamMate/ViewModels/PullRequestPickerViewModel.cs +++ b/Source/TeamMate/ViewModels/PullRequestPickerViewModel.cs @@ -3,6 +3,8 @@ using Microsoft.Tools.TeamMate.Foundation.Validation; using Microsoft.Tools.TeamMate.Foundation.Windows.MVVM; using Microsoft.Tools.TeamMate.Model; using System; +using System.Collections; +using System.Collections.ObjectModel; using System.Linq; namespace Microsoft.Tools.TeamMate.ViewModels @@ -13,6 +15,20 @@ namespace Microsoft.Tools.TeamMate.ViewModels private PullRequestQueryInfo queryInfo; private PullRequestQueryReviewStatus reviewStatus; + private string _selectedAssignedTo; + private ObservableCollection _assignedTo = new ObservableCollection() + { + "@me", + "", + }; + + private string _selectedCreatedBy; + private ObservableCollection _createdBy = new ObservableCollection() + { + "@me", + "", + }; + public PullRequestPickerViewModel() { Validator.RuleForProperty(() => Name) @@ -42,13 +58,75 @@ namespace Microsoft.Tools.TeamMate.ViewModels get { return this.reviewStatus; } set { SetProperty(ref this.reviewStatus, value); } } + public IEnumerable AssignedTo + { + get { return this._assignedTo; } + } + public string SelectedAssignedTo + { + get { return this._selectedAssignedTo; } + set + { + this._selectedAssignedTo = value; + OnPropertyChanged("SelectedAssignedTo"); + } + } + public string NewAssignedTo + { + set + { + if (SelectedAssignedTo != null) + { + return; + } + + if (!string.IsNullOrEmpty(value)) + { + this._assignedTo.Add(value); + SelectedAssignedTo = value; + } + } + } + + public IEnumerable CreatedBy + { + get { return this._createdBy; } + } + public string SelectedCreatedBy + { + get { return this._selectedCreatedBy; } + set + { + this._selectedCreatedBy = value; + OnPropertyChanged("SelectedCreatedBy"); + } + } + + public string NewCreatedBy + { + set + { + if (SelectedCreatedBy != null) + { + return; + } + + if (!string.IsNullOrEmpty(value)) + { + this._createdBy.Add(value); + SelectedCreatedBy = value; + } + } + } private void Invalidate() { if (this.queryInfo != null) { this.Name = this.queryInfo.Name; this.ReviewStatus = this.queryInfo.ReviewStatus; + this.SelectedAssignedTo = this.queryInfo.AssignedTo; + this.SelectedCreatedBy = this.queryInfo.CreatedBy; } } @@ -58,6 +136,8 @@ namespace Microsoft.Tools.TeamMate.ViewModels { this.queryInfo.Name = this.Name.Trim(); this.queryInfo.ReviewStatus = this.ReviewStatus; + this.queryInfo.AssignedTo = this.SelectedAssignedTo; + this.queryInfo.CreatedBy = this.SelectedCreatedBy; } } diff --git a/Source/TeamMate/ViewModels/PullRequestQueryViewModel.cs b/Source/TeamMate/ViewModels/PullRequestQueryViewModel.cs index 7c20686..be2bea9 100644 --- a/Source/TeamMate/ViewModels/PullRequestQueryViewModel.cs +++ b/Source/TeamMate/ViewModels/PullRequestQueryViewModel.cs @@ -160,9 +160,18 @@ namespace Microsoft.Tools.TeamMate.ViewModels query.GitPullRequestSearchCriteria = new GitPullRequestSearchCriteria { Status = PullRequestQueryInfo.ReviewStatusesMap[this.queryInfo.ReviewStatus], - ReviewerId = pc.Identity.Id }; + if (this.queryInfo.AssignedTo == "@me") + { + query.GitPullRequestSearchCriteria.ReviewerId = pc.Identity.Id; + } + + if (this.queryInfo.CreatedBy == "@me") + { + query.GitPullRequestSearchCriteria.CreatorId = pc.Identity.Id; + } + return query; } diff --git a/Source/TeamMate/Windows/PullRequestQueryEditorDialog.xaml b/Source/TeamMate/Windows/PullRequestQueryEditorDialog.xaml index b229d4d..6cca54d 100644 --- a/Source/TeamMate/Windows/PullRequestQueryEditorDialog.xaml +++ b/Source/TeamMate/Windows/PullRequestQueryEditorDialog.xaml @@ -1,12 +1,13 @@ - + SizeToContent="WidthAndHeight" Height="294" + >