Skip to content
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

Mentions in Comment Widget #842

Merged
merged 12 commits into from
Jan 29, 2019
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/master' into rebornix/mentions
  • Loading branch information
rebornix committed Jan 28, 2019
commit 74e6b427cd18dac1944be0c72b9253871f3c3a5a
8 changes: 6 additions & 2 deletions src/github/githubRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ import { PRType, IGitHubRepository, IAccount } from './interface';
import { PullRequestModel } from './pullRequestModel';
import { CredentialStore, GitHub } from './credentials';
import { AuthenticationError } from '../common/authentication';
import { QueryOptions, MutationOptions, ApolloQueryResult } from 'apollo-boost';
const queries = require('./queries.gql');

import { QueryOptions, MutationOptions, ApolloQueryResult, NetworkStatus } from 'apollo-boost';
import { PRDocumentCommentProvider, PRDocumentCommentProviderGraphQL } from '../view/prDocumentCommentProvider';
import { convertRESTPullRequestToRawPullRequest } from './utils';
const queries = require('./queries.gql');


\
export const PULL_REQUEST_PAGE_SIZE = 20;

const GRAPHQL_COMPONENT_ID = 'GraphQL';
Expand Down
1 change: 0 additions & 1 deletion src/github/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export interface IAccount {
ownedPrivateRepositoryCount?: number;
privateRepositoryInPlanCount?: number;
url: string;
type: string;
}

export interface MergePullRequest {
Expand Down
26 changes: 4 additions & 22 deletions src/github/pullRequestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { Repository, RefType, UpstreamRef } from '../git/api';
import Logger from '../common/logger';
import { EXTENSION_ID } from '../constants';
import { fromPRUri, PRUriParams } from '../common/uri';

import { convertRESTPullRequestToRawPullRequest, convertPullRequestsGetCommentsResponseItemToComment, convertIssuesCreateCommentResponseToComment, parseGraphQLTimelineEvents, convertRESTTimelineEvents, getRelatedUsersFromTimelineEvents } from './utils';
import { convertRESTPullRequestToRawPullRequest, convertPullRequestsGetCommentsResponseItemToComment, convertIssuesCreateCommentResponseToComment, parseGraphQLTimelineEvents, convertRESTTimelineEvents, getRelatedUsersFromTimelineEvents, parseGraphQLComment } from './utils';
import { PendingReviewIdResponse, TimelineEventsResponse, PullRequestCommentsResponse, AddCommentResponse, SubmitReviewResponse, DeleteReviewResponse, EditCommentResponse } from './graphql';
const queries = require('./queries.gql');

interface PageInformation {
Expand Down Expand Up @@ -793,7 +793,7 @@ export class PullRequestManager {
return parseGraphQLComment(comment);
}

async createComment(pullRequest: PullRequestModel, body: string, commentPath: string, position: number): Promise<Comment> {
async createComment(pullRequest: PullRequestModel, body: string, commentPath: string, position: number): Promise<Comment | undefined> {
const pendingReviewId = await this.getPendingReviewId(pullRequest as PullRequestModel);
if (pendingReviewId) {
return this.addCommentToPendingReview(pullRequest as PullRequestModel, pendingReviewId, body, { path: commentPath, position });
Expand Down Expand Up @@ -1371,22 +1371,4 @@ const titleAndBodyFrom = (message: string): { title: string, body: string } => {
? ''
: message.slice(idxLineBreak + 1),
};
};

const toComment = (comment: any): any => ({
id: comment.databaseId,
node_id: comment.id,
body: comment.body,
user: {
login: comment.author.login,
avatar_url: comment.author.avatarUrl,
},
position: comment.position,
url: comment.url,
path: comment.path,
original_position: comment.originalPosition,
diff_hunk: comment.diffHunk,
isDraft: comment.state === 'PENDING',
pull_request_review_id: comment.pullRequestReview && comment.pullRequestReview.databaseId,
commitId: comment.commit.id
});
};
1 change: 1 addition & 0 deletions src/github/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IAccount, PullRequest } from './interface';
import { Comment } from '../common/comment';
import { parseDiffHunk, DiffHunk } from '../common/diffHunk';
import { EventType, TimelineEvent, isCommitEvent, isReviewEvent, isCommentEvent } from '../common/timelineEvent';
import { ReviewComment } from './graphql';

export function convertRESTUserToAccount(user: Octokit.PullRequestsGetAllResponseItemUser): IAccount {
return {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.