Skip to content

Commit

Permalink
Add a link to open all PRs (#328)
Browse files Browse the repository at this point in the history
Fixes #305.
  • Loading branch information
fwouts authored Aug 10, 2019
1 parent 7a857ec commit b9f66d0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
10 changes: 10 additions & 0 deletions src/components/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ export const Popup = observer((props: PopupProps) => {
currentFilter: Filter.INCOMING
});

const onOpenAll = () => {
const pullRequests = props.core.filteredPullRequests
? props.core.filteredPullRequests[state.currentFilter]
: [];
for (const pullRequest of pullRequests) {
onOpen(pullRequest.htmlUrl);
}
};

const onOpen = (pullRequestUrl: string) => {
props.core.openPullRequest(pullRequestUrl).catch(console.error);
};
Expand Down Expand Up @@ -131,6 +140,7 @@ export const Popup = observer((props: PopupProps) => {
? "allow-unmuting"
: "none"
}
onOpenAll={onOpenAll}
onOpen={onOpen}
onMute={onMute}
onUnmute={onUnmute}
Expand Down
36 changes: 25 additions & 11 deletions src/components/PullRequestList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,28 @@ import React from "react";
import { EnrichedPullRequest } from "../filtering/enriched-pull-request";
import { PullRequest } from "../storage/loaded-state";
import { MuteType } from "../storage/mute-configuration";
import { Link } from "./design/Link";
import { Paragraph } from "./design/Paragraph";
import { Loader } from "./Loader";
import { PullRequestItem } from "./PullRequestItem";

export const List = styled.div`
const List = styled.div`
border: 1px solid #ddd;
border-radius: 0 8px 8px 8px;
background: #fff;
margin-bottom: 16px;
`;

const OpenAllParagraph = styled(Paragraph)`
text-align: center;
color: #777;
`;

export interface PullRequestListProps {
pullRequests: EnrichedPullRequest[] | null;
emptyMessage: string;
mutingConfiguration: "allow-muting" | "allow-unmuting" | "none";
onOpenAll(): void;
onOpen(pullRequestUrl: string): void;
onMute(pullRequest: PullRequest, muteType: MuteType): void;
onUnmute(pullRequest: PullRequest): void;
Expand All @@ -31,16 +38,23 @@ export const PullRequestList = observer((props: PullRequestListProps) => (
) : props.pullRequests.length === 0 ? (
<Paragraph>{props.emptyMessage}</Paragraph>
) : (
props.pullRequests.map(pullRequest => (
<PullRequestItem
key={pullRequest.nodeId}
pullRequest={pullRequest}
mutingConfiguration={props.mutingConfiguration}
onOpen={props.onOpen}
onMute={props.onMute}
onUnmute={props.onUnmute}
/>
))
<>
{props.pullRequests.map(pullRequest => (
<PullRequestItem
key={pullRequest.nodeId}
pullRequest={pullRequest}
mutingConfiguration={props.mutingConfiguration}
onOpen={props.onOpen}
onMute={props.onMute}
onUnmute={props.onUnmute}
/>
))}
{props.pullRequests.length > 1 && (
<OpenAllParagraph>
<Link onClick={props.onOpenAll}>Open them all</Link>
</OpenAllParagraph>
)}
</>
)}
</List>
));

0 comments on commit b9f66d0

Please sign in to comment.