Skip to content

Commit

Permalink
GL any cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Canzanella committed Mar 17, 2021
1 parent 21e8ba9 commit b3363f5
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 31 deletions.
15 changes: 13 additions & 2 deletions shared/agent/src/protocol/agent.protocol.gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ export interface GitLabFetchListsResponse {

export interface GitLabMergeRequestWrapper {
error: any;
currentUser: any;
currentUser: {
name: string;
login: string;
avatarUrl: string;
id: string;
};
project: {
mergeRequestsEnabled: boolean;
mergeRequestsFfOnlyEnabled: boolean;
Expand Down Expand Up @@ -252,7 +257,12 @@ export interface GitLabMergeRequest {
}[];
};
pendingReview: {
comments: {
id: string;
author: {
login: string;
avatarUrl: string;
};
comments?: {
totalCount: number;
};
};
Expand Down Expand Up @@ -303,6 +313,7 @@ export interface GitLabMergeRequest {
avatarUrl: string;
viewerCanDelete?: boolean;
};
viewerDidAuthor: boolean;
webUrl: string;
workInProgress: boolean;
baseWebUrl: string;
Expand Down
16 changes: 10 additions & 6 deletions shared/agent/src/providers/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1115,18 +1115,22 @@ export class GitLabProvider extends ThirdPartyIssueProviderBase<CSGitLabProvider
// add reviews
const pendingReview = await this.gitLabReviewStore.get(base_id);
if (pendingReview?.comments?.length) {
const commentsAsDiscussionNodes = pendingReview.comments.map(_ => {
return this.gitLabReviewStore.mapToDiscussionNode(_, this._currentGitlabUser!);
});
response.project.mergeRequest.discussions.nodes = response.project.mergeRequest.discussions.nodes.concat(
commentsAsDiscussionNodes
);
response.project.mergeRequest.pendingReview = {
id: "undefined",
author: commentsAsDiscussionNodes[0].notes?.nodes[0].author!,
comments: {
totalCount: pendingReview.comments.length
}
};

response.project.mergeRequest.discussions.nodes = response.project.mergeRequest.discussions.nodes.concat(
pendingReview.comments.map(_ => {
return this.gitLabReviewStore.mapToDiscussionNode(_, this._currentGitlabUser!);
})
);
}
response.project.mergeRequest.viewerDidAuthor =
response.project.mergeRequest.author.login == response.currentUser.login;

// get all timeline events
(
Expand Down
1 change: 0 additions & 1 deletion shared/ui/Stream/PullRequestFilesChangedTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { FileStatus } from "@codestream/protocols/api";
import { LoadingMessage } from "../src/components/LoadingMessage";
import { getPullRequestCommits, getPullRequestFiles } from "../store/providerPullRequests/actions";
import { PullRequestFilesChangedList } from "./PullRequestFilesChangedList";
import { HostApi } from "../webview-api";
import { FetchThirdPartyPullRequestPullRequest } from "@codestream/protocols/agent";

const STATUS_MAP = {
Expand Down
35 changes: 15 additions & 20 deletions shared/ui/Stream/PullRequestFinishReview.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import React, { useState, useReducer } from "react";
import {
FetchThirdPartyPullRequestPullRequest,
ExecuteThirdPartyTypedType
} from "../protocols/agent/agent.protocol.providers";
import React, { useState } from "react";
import { PRCommentCard, ButtonRow } from "./PullRequestComponents";
import MessageInput from "./MessageInput";
import { RadioGroup, Radio } from "../src/components/RadioGroup";
Expand All @@ -16,27 +12,26 @@ import { api } from "../store/providerPullRequests/actions";
import { replaceHtml } from "../utils";

export const PullRequestFinishReview = (props: {
pr: FetchThirdPartyPullRequestPullRequest;
pr: {
providerId: string;
viewerDidAuthor: boolean;
pendingReview: {
id: string;
author: {
login: string;
avatarUrl: string;
};
comments?: {
totalCount: number;
};
};
};
mode: "dropdown" | "timeline";
fetch: Function;
setIsLoadingMessage: Function;
setFinishReviewOpen?: Function;
}) => {
const dispatch = useDispatch();
const derivedState = useSelector((state: CodeStreamState) => {
const currentUser = state.users[state.session.userId!] as CSMe;
const team = state.teams[state.context.currentTeamId];
return {
reviewsState: state.reviews,
currentUser,
currentPullRequestId: state.context.currentPullRequest
? state.context.currentPullRequest.id
: undefined,
composeCodemarkActive: state.context.composeCodemarkActive,
team
};
});

const [reviewText, setReviewText] = useState("");
const [submittingReview, setSubmittingReview] = useState(false);
const [reviewType, setReviewType] = useState<"COMMENT" | "APPROVE" | "REQUEST_CHANGES">(
Expand Down
2 changes: 1 addition & 1 deletion shared/ui/Stream/PullRequests/GitLab/PullRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ export const PullRequest = () => {
</Button>
{finishReviewOpen && (
<PullRequestFinishReview
pr={pr as any}
pr={pr}
mode="dropdown"
fetch={fetch}
setIsLoadingMessage={setIsLoadingMessage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const ReactAndDisplayOptions = props => {
return (
<Root>
<PullRequestReactions
pr={pr as any}
pr={pr}
targetId={pr.id.replace(/.*\//, "")}
setIsLoadingMessage={setIsLoadingMessage}
thumbsFirst
Expand Down

0 comments on commit b3363f5

Please sign in to comment.