Skip to content

Commit

Permalink
Show a summary of changes (added/deleted/changed) in notifications (#781
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cplesner-humio authored Jun 3, 2021
1 parent 2333829 commit 689be9d
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 6 deletions.
52 changes: 46 additions & 6 deletions src/components/PullRequestItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,34 @@ const Title = styled.div`
padding: 8px;
`;

const Repo = styled.div`
const ContextSummary = styled.div`
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-size: 0.9em;
color: #555;
padding: 8px;
`;

const ChangeSummary = styled.span`
margin-left: 8px;
`;

const LinesAdded = styled.span`
color: #22863a;
`;

const LinesDeleted = styled.span`
color: #cb2431;
`;

const ChangedFiles = styled.span`
color: #555;
`;

const Repo = styled.span`
color: #555;
`;

const AuthorWidth = "80px";
const AuthorAvatarSize = "40px";

Expand Down Expand Up @@ -186,10 +205,31 @@ export const PullRequestItem = observer((props: PullRequestItemProps) => {
)}
</Title>
<PullRequestStatus pullRequest={props.pullRequest} />
<Repo>
{props.pullRequest.repoOwner}/{props.pullRequest.repoName} (#
{props.pullRequest.pullRequestNumber})
</Repo>
<ContextSummary>
<Repo>
{props.pullRequest.repoOwner}/{props.pullRequest.repoName} (#
{props.pullRequest.pullRequestNumber})
</Repo>
{props.pullRequest.changeSummary &&
(() => {
const adds = props.pullRequest.changeSummary.additions;
const dels = props.pullRequest.changeSummary.deletions;
const files = props.pullRequest.changeSummary.changedFiles;
return (
<ChangeSummary
title={`${adds} line${
adds == 1 ? "" : "s"
} added, ${dels} line${
dels == 1 ? "" : "s"
} removed, ${files} file${files == 1 ? "" : "s"} changed`}
>
<LinesAdded>+{adds}</LinesAdded>
<LinesDeleted>-{dels}</LinesDeleted>
<ChangedFiles>@{files}</ChangedFiles>
</ChangeSummary>
);
})()}
</ContextSummary>
</Info>
<AuthorBox title={props.pullRequest.author.login}>
{props.pullRequest.author && (
Expand Down
5 changes: 5 additions & 0 deletions src/loading/internal/pull-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ function pullRequestFromResponse(
login: response.user.login,
avatarUrl: response.user.avatar_url,
},
changeSummary: {
changedFiles: details.changed_files,
additions: details.additions,
deletions: details.deletions,
},
title: response.title,
draft: response.draft,
mergeable: details.mergeable,
Expand Down
5 changes: 5 additions & 0 deletions src/storage/loaded-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export interface PullRequest {
login: string;
avatarUrl: string;
};
changeSummary: {
changedFiles: number;
additions: number;
deletions: number;
};
title: string;
draft?: boolean;
mergeable?: boolean;
Expand Down
5 changes: 5 additions & 0 deletions src/testing/fake-pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ class FakePullRequestBuilder {
login: this._author,
avatarUrl: "",
},
changeSummary: {
changedFiles: 5,
additions: 100,
deletions: 50,
},
title: "PR",
repoOwner: this._ref.repo.owner,
repoName: this._ref.repo.name,
Expand Down

0 comments on commit 689be9d

Please sign in to comment.