From 6ee98792ca7048449c5068a1c672fb49be971dda Mon Sep 17 00:00:00 2001 From: Josh Uvi Date: Tue, 20 Feb 2024 13:17:24 +0000 Subject: [PATCH] chore: changes made due to review comments Signed-off-by: Josh Uvi --- .changeset/chilled-dolphins-tap.md | 2 +- .../src/components/Card/Card.tsx | 2 +- .../src/components/Card/CardHeader.test.tsx | 7 ++++++- .../src/components/Card/CardHeader.tsx | 4 ++-- .../src/components/PullRequestCard/PullRequestCard.tsx | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.changeset/chilled-dolphins-tap.md b/.changeset/chilled-dolphins-tap.md index 92549aaef0..c4f4c98aec 100644 --- a/.changeset/chilled-dolphins-tap.md +++ b/.changeset/chilled-dolphins-tap.md @@ -2,4 +2,4 @@ '@backstage/plugin-github-pull-requests-board': patch --- -The cardheader component in the github-pull-requests-board plugin now requires that a `status` is passed to the component. +The `CardHeader` component in the `github-pull-requests-board` plugin will show the status for the PR diff --git a/plugins/github-pull-requests-board/src/components/Card/Card.tsx b/plugins/github-pull-requests-board/src/components/Card/Card.tsx index 09c6352b60..6642cdeb06 100644 --- a/plugins/github-pull-requests-board/src/components/Card/Card.tsx +++ b/plugins/github-pull-requests-board/src/components/Card/Card.tsx @@ -29,7 +29,7 @@ type Props = { isDraft: boolean; repositoryIsArchived: boolean; labels?: Label[]; - status: Status; + status?: Status; }; const Card: FunctionComponent> = ( diff --git a/plugins/github-pull-requests-board/src/components/Card/CardHeader.test.tsx b/plugins/github-pull-requests-board/src/components/Card/CardHeader.test.tsx index 0ca1bfd43f..b4bda755d2 100644 --- a/plugins/github-pull-requests-board/src/components/Card/CardHeader.test.tsx +++ b/plugins/github-pull-requests-board/src/components/Card/CardHeader.test.tsx @@ -65,6 +65,11 @@ describe('', () => { it('finds commit status in PR Card Header', async () => { await renderInTestApp(); expect(screen.getByText('Commit Status:')).toBeInTheDocument(); - expect(props.status.commit.statusCheckRollup.state).toBeTruthy(); + expect(props.status?.commit.statusCheckRollup.state).toBeTruthy(); + }); + + it('does not find commit status in PR Card Header when PR does not include status', async () => { + await renderInTestApp(); + expect(CardHeader.defaultProps?.status).toBeUndefined(); }); }); diff --git a/plugins/github-pull-requests-board/src/components/Card/CardHeader.tsx b/plugins/github-pull-requests-board/src/components/Card/CardHeader.tsx index 9a47938139..652cf740c4 100644 --- a/plugins/github-pull-requests-board/src/components/Card/CardHeader.tsx +++ b/plugins/github-pull-requests-board/src/components/Card/CardHeader.tsx @@ -32,7 +32,7 @@ type Props = { isDraft: boolean; repositoryIsArchived: boolean; labels?: Label[]; - status: Status; + status?: Status; }; const CardHeader: FunctionComponent = (props: Props) => { @@ -91,7 +91,7 @@ const CardHeader: FunctionComponent = (props: Props) => { Commit Status:{' '} - {status.commit.statusCheckRollup.state} + {status?.commit.statusCheckRollup.state} {labels && ( diff --git a/plugins/github-pull-requests-board/src/components/PullRequestCard/PullRequestCard.tsx b/plugins/github-pull-requests-board/src/components/PullRequestCard/PullRequestCard.tsx index 8736644f09..59f7892d0e 100644 --- a/plugins/github-pull-requests-board/src/components/PullRequestCard/PullRequestCard.tsx +++ b/plugins/github-pull-requests-board/src/components/PullRequestCard/PullRequestCard.tsx @@ -30,7 +30,7 @@ type Props = { author: Author; url: string; reviews: Reviews; - status: Status; + status?: Status; repositoryName: string; repositoryIsArchived: boolean; isDraft: boolean;