Skip to content

feat: support icons/colors for checksuite / workflow notifications #814

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 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 2 additions & 5 deletions src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@ export const NotificationRow: React.FC<IProps> = ({
};

const reason = formatReason(notification.reason);
const NotificationIcon = getNotificationTypeIcon(
notification.subject.type,
notification.subject.state,
);
const iconColor = getNotificationTypeIconColor(notification.subject.state);
const NotificationIcon = getNotificationTypeIcon(notification.subject);
const iconColor = getNotificationTypeIconColor(notification.subject);
const realIconColor = settings
? (settings.colors && iconColor) || ''
: iconColor;
Expand Down
15 changes: 15 additions & 0 deletions src/typesGithub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ export type StateType = IssueStateType | PullRequestStateType;

export type ViewerSubscription = 'IGNORED' | 'SUBSCRIBED' | 'UNSUBSCRIBED';

export type CheckSuiteStatus =
| 'action_required'
| 'cancelled'
| 'completed'
| 'failure'
| 'in_progress'
| 'pending'
| 'queued'
| 'requested'
| 'skipped'
| 'stale'
| 'success'
| 'timed_out'
| 'waiting';

export interface Notification {
id: string;
unread: boolean;
Expand Down
72 changes: 41 additions & 31 deletions src/utils/__snapshots__/github-api.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,122 +1,132 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`./utils/github-api.ts should format the notification color 1`] = `"text-red-500"`;

exports[`./utils/github-api.ts should format the notification color 2`] = `"text-purple-500"`;

exports[`./utils/github-api.ts should format the notification color 3`] = `"text-gray-600"`;

exports[`./utils/github-api.ts should format the notification color 4`] = `"text-purple-500"`;

exports[`./utils/github-api.ts should format the notification color 5`] = `"text-gray-300"`;

exports[`./utils/github-api.ts should format the notification color 6`] = `"text-green-500"`;

exports[`./utils/github-api.ts should format the notification color 7`] = `"text-green-500"`;

exports[`./utils/github-api.ts should format the notification color 8`] = `"text-gray-300"`;

exports[`./utils/github-api.ts should format the notification reason 1`] = `
exports[`formatReason should format the notification reason 1`] = `
{
"description": "You were assigned to the issue.",
"type": "Assign",
}
`;

exports[`./utils/github-api.ts should format the notification reason 2`] = `
exports[`formatReason should format the notification reason 2`] = `
{
"description": "You created the thread.",
"type": "Author",
}
`;

exports[`./utils/github-api.ts should format the notification reason 3`] = `
exports[`formatReason should format the notification reason 3`] = `
{
"description": "A GitHub Actions workflow run was triggered for your repository",
"type": "Workflow Run",
}
`;

exports[`./utils/github-api.ts should format the notification reason 4`] = `
exports[`formatReason should format the notification reason 4`] = `
{
"description": "You commented on the thread.",
"type": "Comment",
}
`;

exports[`./utils/github-api.ts should format the notification reason 5`] = `
exports[`formatReason should format the notification reason 5`] = `
{
"description": "You accepted an invitation to contribute to the repository.",
"type": "Invitation",
}
`;

exports[`./utils/github-api.ts should format the notification reason 6`] = `
exports[`formatReason should format the notification reason 6`] = `
{
"description": "You subscribed to the thread (via an issue or pull request).",
"type": "Manual",
}
`;

exports[`./utils/github-api.ts should format the notification reason 7`] = `
exports[`formatReason should format the notification reason 7`] = `
{
"description": "Organization members have requested to enable a feature such as Draft Pull Requests or CoPilot.",
"type": "Member Feature Requested",
}
`;

exports[`./utils/github-api.ts should format the notification reason 8`] = `
exports[`formatReason should format the notification reason 8`] = `
{
"description": "You were specifically @mentioned in the content.",
"type": "Mention",
}
`;

exports[`./utils/github-api.ts should format the notification reason 9`] = `
exports[`formatReason should format the notification reason 9`] = `
{
"description": "You, or a team you're a member of, were requested to review a pull request.",
"type": "Review Requested",
}
`;

exports[`./utils/github-api.ts should format the notification reason 10`] = `
exports[`formatReason should format the notification reason 10`] = `
{
"description": "You were credited for contributing to a security advisory.",
"type": "Security Advisory Credit",
}
`;

exports[`./utils/github-api.ts should format the notification reason 11`] = `
exports[`formatReason should format the notification reason 11`] = `
{
"description": "GitHub discovered a security vulnerability in your repository.",
"type": "Security Alert",
}
`;

exports[`./utils/github-api.ts should format the notification reason 12`] = `
exports[`formatReason should format the notification reason 12`] = `
{
"description": "You changed the thread state (for example, closing an issue or merging a pull request).",
"type": "State Change",
}
`;

exports[`./utils/github-api.ts should format the notification reason 13`] = `
exports[`formatReason should format the notification reason 13`] = `
{
"description": "You're watching the repository.",
"type": "Subscribed",
}
`;

exports[`./utils/github-api.ts should format the notification reason 14`] = `
exports[`formatReason should format the notification reason 14`] = `
{
"description": "You were on a team that was mentioned.",
"type": "Team Mention",
}
`;

exports[`./utils/github-api.ts should format the notification reason 15`] = `
exports[`formatReason should format the notification reason 15`] = `
{
"description": "The reason for this notification is not supported by the app.",
"type": "Unknown",
}
`;

exports[`getNotificationTypeIconColor should format the notification color for check suite 1`] = `"text-gray-500"`;

exports[`getNotificationTypeIconColor should format the notification color for check suite 2`] = `"text-red-500"`;

exports[`getNotificationTypeIconColor should format the notification color for check suite 3`] = `"text-gray-500"`;

exports[`getNotificationTypeIconColor should format the notification color for check suite 4`] = `"text-green-500"`;

exports[`getNotificationTypeIconColor should format the notification color for check suite 5`] = `"text-gray-300"`;

exports[`getNotificationTypeIconColor should format the notification color for state 1`] = `"text-red-500"`;

exports[`getNotificationTypeIconColor should format the notification color for state 2`] = `"text-purple-500"`;

exports[`getNotificationTypeIconColor should format the notification color for state 3`] = `"text-gray-600"`;

exports[`getNotificationTypeIconColor should format the notification color for state 4`] = `"text-purple-500"`;

exports[`getNotificationTypeIconColor should format the notification color for state 5`] = `"text-gray-300"`;

exports[`getNotificationTypeIconColor should format the notification color for state 6`] = `"text-green-500"`;

exports[`getNotificationTypeIconColor should format the notification color for state 7`] = `"text-green-500"`;

exports[`getNotificationTypeIconColor should format the notification color for state 8`] = `"text-gray-300"`;
Loading