Skip to content

feat: show notification number for issues, prs, discussions #1276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,18 @@ export const NotificationRow: FC<INotificationRow> = ({
? `${notification.subject.user.login} updated ${updatedAt}`
: `Updated ${updatedAt}`;

const notificationTitle = formatForDisplay([
const notificationType = formatForDisplay([
notification.subject.state,
notification.subject.type,
]);

const notificationNumber = notification.subject?.number
? `#${notification.subject.number}`
: '';

const notificationTitle =
`${notification.subject.title} ${notificationNumber}`.trim();

const commentsPillDescription = `${notification.subject.comments} ${
notification.subject.comments > 1 ? 'comments' : 'comment'
}`;
Expand All @@ -112,7 +119,7 @@ export const NotificationRow: FC<INotificationRow> = ({
>
<div
className={cn('mr-3 flex w-5 items-center justify-center', iconColor)}
title={notificationTitle}
title={notificationType}
>
<NotificationIcon size={16} aria-label={notification.subject.type} />
</div>
Expand All @@ -124,9 +131,10 @@ export const NotificationRow: FC<INotificationRow> = ({
<div
className="mb-1 cursor-pointer truncate text-sm"
role="main"
title={notification.subject.title}
title={notificationTitle}
>
{notification.subject.title}
<span className="text-xs"> {notificationNumber}</span>
</div>

<div className="flex flex-wrap items-center gap-1 text-xs capitalize">
Expand Down
120 changes: 120 additions & 0 deletions src/components/__snapshots__/NotificationRow.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/typesGitHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ interface GitHubSubject {

// This is not in the GitHub API, but we add it to the type to make it easier to work with
export interface GitifySubject {
number?: number;
state?: StateType;
user?: SubjectUser;
reviews?: GitifyPullRequestReview[];
Expand Down Expand Up @@ -494,6 +495,7 @@ export interface GraphQLSearch<T> {
}

export interface Discussion {
number: number;
title: string;
stateReason: DiscussionStateType;
isAnswered: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/utils/api/__mocks__/response-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ export const mockGraphQLResponse: GraphQLSearch<Discussion> = {
search: {
nodes: [
{
number: 123,
title: '1.16.0',
isAnswered: false,
stateReason: 'OPEN',
Expand Down
1 change: 1 addition & 0 deletions src/utils/api/graphql/discussions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const QUERY_SEARCH_DISCUSSIONS = gql`
search(query: $queryStatement, type: DISCUSSION, first: $firstDiscussions) {
nodes {
... on Discussion {
number
title
stateReason
isAnswered
Expand Down
Loading