Filter archived repos in GH PR plugin

Signed-off-by: Klara Ward <klaraw@spotify.com>
This commit is contained in:
Klara Ward
2022-09-27 09:57:42 +02:00
committed by tylerhekman-procore
parent 17d44daba9
commit 2ef8aee1d0
7 changed files with 37 additions and 2 deletions
@@ -36,6 +36,7 @@ export const useGetPullRequestDetails = () => {
owner {
login
}
isArchived
}
title
url
@@ -29,6 +29,7 @@ import { PRCardFormating } from '../../utils/types';
import { shouldDisplayCard } from '../../utils/functions';
import { DraftPrIcon } from '../icons/DraftPr';
import { useUserRepositoriesAndTeam } from '../../hooks/useUserRepositoriesAndTeam';
import UnarchiveIcon from '@material-ui/icons/Unarchive';
/** @public */
export interface EntityTeamPullRequestsCardProps {
@@ -71,6 +72,11 @@ const EntityTeamPullRequestsCard = (props: EntityTeamPullRequestsCardProps) => {
value: 'draft',
ariaLabel: 'Show draft PRs',
},
{
icon: <UnarchiveIcon />,
value: 'archivedRepo',
ariaLabel: 'Show archived repos',
},
{
icon: <FullscreenIcon />,
value: 'fullscreen',
@@ -127,6 +133,7 @@ const EntityTeamPullRequestsCard = (props: EntityTeamPullRequestsCardProps) => {
url={url}
reviews={latestReviews.nodes}
repositoryName={repository.name}
repositoryIsArchived={repository.isArchived}
isDraft={isDraft}
/>
),
@@ -27,6 +27,7 @@ import { PRCardFormating } from '../../utils/types';
import { shouldDisplayCard } from '../../utils/functions';
import { DraftPrIcon } from '../icons/DraftPr';
import { useUserRepositoriesAndTeam } from '../../hooks/useUserRepositoriesAndTeam';
import UnarchiveIcon from '@material-ui/icons/Unarchive';
/** @public */
export interface EntityTeamPullRequestsContentProps {
@@ -71,6 +72,11 @@ const EntityTeamPullRequestsContent = (
value: 'draft',
ariaLabel: 'Show draft PRs',
},
{
icon: <UnarchiveIcon />,
value: 'archivedRepo',
ariaLabel: 'Show archived repos',
},
]}
/>
</InfoCardHeader>
@@ -119,6 +125,7 @@ const EntityTeamPullRequestsContent = (
url={url}
reviews={latestReviews.nodes}
repositoryName={repository.name}
repositoryIsArchived={repository.isArchived}
isDraft={isDraft}
/>
),
@@ -31,6 +31,7 @@ type Props = {
url: string;
reviews: Reviews;
repositoryName: string;
repositoryIsArchived: boolean;
isDraft: boolean;
};
@@ -43,6 +44,7 @@ const PullRequestCard: FunctionComponent<Props> = (props: Props) => {
url,
reviews,
repositoryName,
repositoryIsArchived,
isDraft,
} = props;
@@ -50,7 +52,11 @@ const PullRequestCard: FunctionComponent<Props> = (props: Props) => {
const commentsReviews = getCommentedReviews(reviews);
const changeRequests = getChangeRequests(reviews);
const cardTitle = isDraft ? `🔧 DRAFT - ${title}` : title;
// Resolved in this way to satisfy merge - Author: tylerhekman-procore
// This information should probably be moved into dedicated CardHeader fields
// instead of title prefixes
const cardTitleModifiers = [isDraft && '🔧 DRAFT', repositoryIsArchived && '📁 ARCHIVED'].filter(Boolean);
const cardTitle = cardTitleModifiers.length > 0 ? `(${cardTitleModifiers.join(' | ')}) - ${title}` : title;
return (
<Card
@@ -137,6 +137,11 @@ export const shouldDisplayCard = (
return false;
}
// hide PRs from archived repositories unless "archivedRepo" filter is toggled
if (infoCardFormat.includes('archivedRepo') !== repository.isArchived) {
return false
}
// when "team" filter is toggled on, only shows PR from team members
if (infoCardFormat.includes('team')) {
return teamMembers.includes(author.login);
@@ -73,6 +73,7 @@ export type Repository = {
owner: {
login: string;
};
isArchived: boolean;
};
export type PullRequest = {
@@ -99,7 +100,7 @@ export type PullRequestsColumn = {
content: PullRequests;
};
export type PRCardFormating = 'compacted' | 'fullscreen' | 'draft' | 'team';
export type PRCardFormating = 'compacted' | 'fullscreen' | 'draft' | 'team' | 'archivedRepo';
export type ReviewDecision = 'IN_PROGRESS' | 'APPROVED' | 'REVIEW_REQUIRED';