From a17b259e5068a8b2df0413ea50c642369732dd63 Mon Sep 17 00:00:00 2001 From: David Rousselie Date: Sat, 3 Feb 2024 08:33:30 +0100 Subject: [PATCH] feat: Display Linear notification reason --- CHANGELOG.md | 4 +++ src/integrations/linear/accessories.ts | 25 +++++++++++++++++++ .../LinearIssueNotificationListItem.tsx | 4 ++- .../LinearProjectNotificationListItem.tsx | 4 ++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79268e7..46a91e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Added + +- Display Linear notification reason + ## [0.1.2] - 2024-02-01 ### Added diff --git a/src/integrations/linear/accessories.ts b/src/integrations/linear/accessories.ts index aad852f..3c5c184 100644 --- a/src/integrations/linear/accessories.ts +++ b/src/integrations/linear/accessories.ts @@ -1,6 +1,7 @@ import { Icon, Image, List } from "@raycast/api"; import { getAvatarIcon } from "@raycast/utils"; import { LinearUser } from "./types"; +import { match } from "ts-pattern"; export function getLinearUserAccessory(user?: LinearUser): List.Item.Accessory { if (user) { @@ -11,3 +12,27 @@ export function getLinearUserAccessory(user?: LinearUser): List.Item.Accessory { } return { icon: Icon.Person, tooltip: "Unknown" }; } + +export function getLinearNotificationReasonAccessory(notification_type: string): List.Item.Accessory { + const reason = match(notification_type) + .with("") + .with("issueAddedToTriage", () => "Added To Triage") + .with("issueAddedToView", () => "Added To View") + .with("issueAssignedToYou", () => "Assigned To You") + .with("issueBlocking", () => "Blocked") + .with("issueCommentMention", () => "Comment Mention") + .with("issueCommentReaction", () => "Comment Reaction") + .with("issueCreated", () => "Created") + .with("issueDue", () => "Due") + .with("issueEmojiReaction", () => "Reaction") + .with("issueMention", () => "Mention") + .with("issueNewComment", () => "New Comment") + .with("issueStatusChanged", () => "Status Changed") + .with("issueUnassignedFromYou", () => "Unassigned From You") + .with("projectAddedAsLead", () => "Added As Lead") + .with("projectAddedAsMember", () => "Added As Member") + .with("projectUpdateCreated", () => "Update Created") + .with("projectUpdateMentionPrompt", () => "Update Mention") + .otherwise(() => notification_type); + return { tag: { value: reason } }; +} diff --git a/src/integrations/linear/listitem/LinearIssueNotificationListItem.tsx b/src/integrations/linear/listitem/LinearIssueNotificationListItem.tsx index f819c25..ffa4661 100644 --- a/src/integrations/linear/listitem/LinearIssueNotificationListItem.tsx +++ b/src/integrations/linear/listitem/LinearIssueNotificationListItem.tsx @@ -1,7 +1,7 @@ import { LinearWorkflowStateType, LinearIssueNotification, LinearWorkflowState } from "../types"; +import { getLinearNotificationReasonAccessory, getLinearUserAccessory } from "../accessories"; import { NotificationActions } from "../../../action/NotificationActions"; import { LinearIssuePreview } from "../preview/LinearIssuePreview"; -import { getLinearUserAccessory } from "../accessories"; import { Notification } from "../../../notification"; import { MutatePromise } from "@raycast/utils"; import { Page } from "../../../types"; @@ -23,8 +23,10 @@ export function LinearIssueNotificationListItem({ const state = getLinearIssueStateAccessory(linearIssueNotification.issue.state); const assignee = getLinearUserAccessory(linearIssueNotification.issue.assignee); + const reason = getLinearNotificationReasonAccessory(linearIssueNotification.type); const accessories: List.Item.Accessory[] = [ + reason, state, assignee, { diff --git a/src/integrations/linear/listitem/LinearProjectNotificationListItem.tsx b/src/integrations/linear/listitem/LinearProjectNotificationListItem.tsx index 689c34d..97b2f64 100644 --- a/src/integrations/linear/listitem/LinearProjectNotificationListItem.tsx +++ b/src/integrations/linear/listitem/LinearProjectNotificationListItem.tsx @@ -1,7 +1,7 @@ +import { getLinearNotificationReasonAccessory, getLinearUserAccessory } from "../accessories"; import { LinearProjectNotification, LinearProjectState, LinearProject } from "../types"; import { NotificationActions } from "../../../action/NotificationActions"; import { LinearProjectPreview } from "../preview/LinearProjectPreview"; -import { getLinearUserAccessory } from "../accessories"; import { Notification } from "../../../notification"; import { MutatePromise } from "@raycast/utils"; import { List, Color } from "@raycast/api"; @@ -23,8 +23,10 @@ export function LinearProjectNotificationListItem({ const state = getLinearProjectStateAccessory(linearProjectNotification.project); const lead = getLinearUserAccessory(linearProjectNotification.project.lead); + const reason = getLinearNotificationReasonAccessory(linearProjectNotification.type); const accessories: List.Item.Accessory[] = [ + reason, state, lead, {