feat: Display Linear notification reason

This commit is contained in:
2024-02-03 08:33:30 +01:00
parent ad43bf3c86
commit a17b259e50
4 changed files with 35 additions and 2 deletions

View File

@@ -2,6 +2,10 @@
## [Unreleased] ## [Unreleased]
### Added
- Display Linear notification reason
## [0.1.2] - 2024-02-01 ## [0.1.2] - 2024-02-01
### Added ### Added

View File

@@ -1,6 +1,7 @@
import { Icon, Image, List } from "@raycast/api"; import { Icon, Image, List } from "@raycast/api";
import { getAvatarIcon } from "@raycast/utils"; import { getAvatarIcon } from "@raycast/utils";
import { LinearUser } from "./types"; import { LinearUser } from "./types";
import { match } from "ts-pattern";
export function getLinearUserAccessory(user?: LinearUser): List.Item.Accessory { export function getLinearUserAccessory(user?: LinearUser): List.Item.Accessory {
if (user) { if (user) {
@@ -11,3 +12,27 @@ export function getLinearUserAccessory(user?: LinearUser): List.Item.Accessory {
} }
return { icon: Icon.Person, tooltip: "Unknown" }; 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 } };
}

View File

@@ -1,7 +1,7 @@
import { LinearWorkflowStateType, LinearIssueNotification, LinearWorkflowState } from "../types"; import { LinearWorkflowStateType, LinearIssueNotification, LinearWorkflowState } from "../types";
import { getLinearNotificationReasonAccessory, getLinearUserAccessory } from "../accessories";
import { NotificationActions } from "../../../action/NotificationActions"; import { NotificationActions } from "../../../action/NotificationActions";
import { LinearIssuePreview } from "../preview/LinearIssuePreview"; import { LinearIssuePreview } from "../preview/LinearIssuePreview";
import { getLinearUserAccessory } from "../accessories";
import { Notification } from "../../../notification"; import { Notification } from "../../../notification";
import { MutatePromise } from "@raycast/utils"; import { MutatePromise } from "@raycast/utils";
import { Page } from "../../../types"; import { Page } from "../../../types";
@@ -23,8 +23,10 @@ export function LinearIssueNotificationListItem({
const state = getLinearIssueStateAccessory(linearIssueNotification.issue.state); const state = getLinearIssueStateAccessory(linearIssueNotification.issue.state);
const assignee = getLinearUserAccessory(linearIssueNotification.issue.assignee); const assignee = getLinearUserAccessory(linearIssueNotification.issue.assignee);
const reason = getLinearNotificationReasonAccessory(linearIssueNotification.type);
const accessories: List.Item.Accessory[] = [ const accessories: List.Item.Accessory[] = [
reason,
state, state,
assignee, assignee,
{ {

View File

@@ -1,7 +1,7 @@
import { getLinearNotificationReasonAccessory, getLinearUserAccessory } from "../accessories";
import { LinearProjectNotification, LinearProjectState, LinearProject } from "../types"; import { LinearProjectNotification, LinearProjectState, LinearProject } from "../types";
import { NotificationActions } from "../../../action/NotificationActions"; import { NotificationActions } from "../../../action/NotificationActions";
import { LinearProjectPreview } from "../preview/LinearProjectPreview"; import { LinearProjectPreview } from "../preview/LinearProjectPreview";
import { getLinearUserAccessory } from "../accessories";
import { Notification } from "../../../notification"; import { Notification } from "../../../notification";
import { MutatePromise } from "@raycast/utils"; import { MutatePromise } from "@raycast/utils";
import { List, Color } from "@raycast/api"; import { List, Color } from "@raycast/api";
@@ -23,8 +23,10 @@ export function LinearProjectNotificationListItem({
const state = getLinearProjectStateAccessory(linearProjectNotification.project); const state = getLinearProjectStateAccessory(linearProjectNotification.project);
const lead = getLinearUserAccessory(linearProjectNotification.project.lead); const lead = getLinearUserAccessory(linearProjectNotification.project.lead);
const reason = getLinearNotificationReasonAccessory(linearProjectNotification.type);
const accessories: List.Item.Accessory[] = [ const accessories: List.Item.Accessory[] = [
reason,
state, state,
lead, lead,
{ {