-
Notifications
You must be signed in to change notification settings - Fork 8
Allow for PR queries across projects #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a6da6da
PR: Customizable project for Pull Request Queries
supermem613 37bddc2
PR: Make the project picker show a list of projects
supermem613 409c730
Add resolution for Created By and Assigned To for PRs
supermem613 8cf9a88
Improve resolution
supermem613 4197771
Make resolution async
supermem613 f366004
Move project initialization to the right spot
supermem613 818e7a4
Add validation for the project field
supermem613 5ff0215
Fix persistence for PR queries
supermem613 37e94a3
Fix IsSignedOffByMe
supermem613 ccb9d43
Make IsSignedOffByMe into IsSignedOffOrDeclinedByMe
supermem613 b9ab229
Persist AssignedTo / CreatedBy for PR Queries
supermem613 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| using Microsoft.VisualStudio.Services.Graph.Client; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Collections.ObjectModel; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using System.Windows.Controls; | ||
|
|
||
| namespace Microsoft.Tools.TeamMate.Services | ||
| { | ||
| public class ResolverService | ||
| { | ||
| private List<GraphUser> GraphUserCache { get; set; } | ||
|
|
||
| private List<GraphGroup> GraphGroupCache { get; set; } | ||
|
|
||
| private List<Task> Tasks = new List<Task>(); | ||
|
|
||
| private async Task<List<GraphUser>> FetchUsersAsync( | ||
| GraphHttpClient graphClient) | ||
| { | ||
| if (GraphUserCache != null) | ||
| { | ||
| return GraphUserCache; | ||
| } | ||
|
|
||
| List<GraphUser> users = new List<GraphUser>(); | ||
|
|
||
| string continuationToken = null; | ||
| do | ||
| { | ||
| var data = await graphClient.ListUsersAsync(null, continuationToken); | ||
| continuationToken = data.ContinuationToken != null ? data.ContinuationToken.First() : null; | ||
| foreach (var user in data.GraphUsers) | ||
| { | ||
| users.Add(user); | ||
| } | ||
| } | ||
| while (continuationToken != null); | ||
|
|
||
| GraphUserCache = users; | ||
|
|
||
| return users; | ||
| } | ||
|
|
||
| private async Task<List<GraphGroup>> FetchGroupsAsync( | ||
| GraphHttpClient graphClient) | ||
| { | ||
| if (GraphGroupCache != null) | ||
| { | ||
| return GraphGroupCache; | ||
| } | ||
|
|
||
| List<GraphGroup> groups = new List<GraphGroup>(); | ||
|
|
||
| string continuationToken = null; | ||
| do | ||
| { | ||
| // ListGroupsAsync | ||
| var data = await graphClient.ListGroupsAsync(null, null, continuationToken); | ||
| continuationToken = data.ContinuationToken != null ? data.ContinuationToken.First() : null; | ||
| foreach (var group in data.GraphGroups) | ||
| { | ||
| groups.Add(group); | ||
| } | ||
| } | ||
| while (continuationToken != null); | ||
|
|
||
| GraphGroupCache = groups; | ||
|
|
||
| return groups; | ||
| } | ||
|
|
||
| public void FetchDataSync( | ||
| GraphHttpClient client) | ||
| { | ||
| Tasks.Add(FetchUsersAsync(client)); | ||
| Tasks.Add(FetchGroupsAsync(client)); | ||
| } | ||
|
|
||
| public async Task<Guid?> Resolve( | ||
| GraphHttpClient client, | ||
| string value) | ||
| { | ||
| if (value == null) | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| await Task.Run(() => { foreach (var task in this.Tasks) { task.Wait(); } }); | ||
|
|
||
| foreach (var user in GraphUserCache) | ||
| { | ||
| if (user.MailAddress != null && | ||
| (user.MailAddress.Contains(value))) | ||
| { | ||
| var storageKey = client.GetStorageKeyAsync(user.Descriptor).Result; | ||
|
|
||
| return storageKey.Value; | ||
| } | ||
| } | ||
|
|
||
| foreach (var group in GraphGroupCache) | ||
| { | ||
| if (group.MailAddress != null && | ||
| (group.MailAddress.Contains(value))) | ||
| { | ||
| var storageKey = client.GetStorageKeyAsync(group.Descriptor).Result; | ||
|
|
||
| return storageKey.Value; | ||
| } | ||
| } | ||
|
|
||
| throw new ArgumentException("Could not resolve '" + value + "'. Try the full email for the person and/or group."); | ||
|
|
||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ public enum CommandBarType | |
| None, | ||
| Home, | ||
| WorkItems, | ||
| CodeReviews, | ||
| PullRequests, | ||
| Projects | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.