Skip to content
Closed
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
17 changes: 11 additions & 6 deletions src/commands/issue/issue-comment-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import {
} from "../../utils/upload.ts"
import { shouldShowSpinner } from "../../utils/hyperlink.ts"
import { CliError, handleError, ValidationError } from "../../utils/errors.ts"
import {
buildBodyFields,
processTextWithMentions,
} from "../../utils/mentions.ts"

export const commentAddCommand = new Command()
.name("add")
Expand Down Expand Up @@ -114,14 +118,15 @@ export const commentAddCommand = new Command()
}
`)

// Process @mentions in the comment body
const mentionResult = await processTextWithMentions(commentBody || "")
const bodyFields = buildBodyFields(mentionResult, "body")

const client = getGraphQLClient()
const input: Record<string, unknown> = {
body: commentBody,
const input = {
issueId: resolvedIdentifier,
}

if (parent) {
input.parentId = parent
...bodyFields,
...(parent ? { parentId: parent } : {}),
}

const data = await client.request(mutation, {
Expand Down
12 changes: 9 additions & 3 deletions src/commands/issue/issue-comment-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { Input } from "@cliffy/prompt"
import { gql } from "../../__codegen__/gql.ts"
import { getGraphQLClient } from "../../utils/graphql.ts"
import { CliError, handleError, ValidationError } from "../../utils/errors.ts"
import {
buildBodyFields,
processTextWithMentions,
} from "../../utils/mentions.ts"

export const commentUpdateCommand = new Command()
.name("update")
Expand Down Expand Up @@ -61,12 +65,14 @@ export const commentUpdateCommand = new Command()
}
`)

// Process @mentions in the comment body
const mentionResult = await processTextWithMentions(newBody)
const input = buildBodyFields(mentionResult, "body")

const client = getGraphQLClient()
const data = await client.request(mutation, {
id: commentId,
input: {
body: newBody,
},
input,
})

if (!data.commentUpdate.success) {
Expand Down
51 changes: 36 additions & 15 deletions src/commands/issue/issue-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import {
NotFoundError,
ValidationError,
} from "../../utils/errors.ts"
import {
buildBodyFields,
processTextWithMentions,
} from "../../utils/mentions.ts"

type IssueLabel = { id: string; name: string; color: string }

Expand Down Expand Up @@ -558,6 +562,14 @@ export const createCommand = new Command()
console.log(`Creating issue...`)
console.log()

// Process @mentions in the description
const descriptionFields = interactiveData.description
? buildBodyFields(
await processTextWithMentions(interactiveData.description),
"description",
)
: {}

const createIssueMutation = gql(`
mutation CreateIssue($input: IssueCreateInput!) {
issueCreate(input: $input) {
Expand All @@ -568,21 +580,22 @@ export const createCommand = new Command()
`)

const client = getGraphQLClient()
const baseInput = {
title: interactiveData.title,
assigneeId: interactiveData.assigneeId,
dueDate: undefined,
parentId: interactiveData.parentId,
priority: interactiveData.priority,
estimate: interactiveData.estimate,
labelIds: interactiveData.labelIds,
teamId: interactiveData.teamId,
projectId: interactiveData.projectId,
stateId: interactiveData.stateId,
useDefaultTemplate,
...descriptionFields,
}
const data = await client.request(createIssueMutation, {
input: {
title: interactiveData.title,
assigneeId: interactiveData.assigneeId,
dueDate: undefined,
parentId: interactiveData.parentId,
priority: interactiveData.priority,
estimate: interactiveData.estimate,
labelIds: interactiveData.labelIds,
teamId: interactiveData.teamId,
projectId: interactiveData.projectId,
stateId: interactiveData.stateId,
useDefaultTemplate,
description: interactiveData.description,
},
input: baseInput,
})

if (!data.issueCreate.success) {
Expand Down Expand Up @@ -736,6 +749,14 @@ export const createCommand = new Command()
parentData = await fetchParentIssueData(parentId)
}

// Process @mentions in the description
const descriptionFields = description
? buildBodyFields(
await processTextWithMentions(description),
"description",
)
: {}

const input = {
title,
assigneeId,
Expand All @@ -748,7 +769,7 @@ export const createCommand = new Command()
projectId: projectId || parentData?.projectId,
stateId,
useDefaultTemplate,
description,
...descriptionFields,
}
spinner?.stop()
console.log(`Creating issue in ${team}`)
Expand Down
13 changes: 12 additions & 1 deletion src/commands/issue/issue-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import {
NotFoundError,
ValidationError,
} from "../../utils/errors.ts"
import {
buildBodyFields,
processTextWithMentions,
} from "../../utils/mentions.ts"

export const updateCommand = new Command()
.name("update")
Expand Down Expand Up @@ -179,7 +183,14 @@ export const updateCommand = new Command()
}
if (priority !== undefined) input.priority = priority
if (estimate !== undefined) input.estimate = estimate
if (description !== undefined) input.description = description
if (description !== undefined) {
// Process @mentions in the description
const descriptionFields = buildBodyFields(
await processTextWithMentions(description),
"description",
)
Object.assign(input, descriptionFields)
}
if (labelIds.length > 0) input.labelIds = labelIds
if (teamId !== undefined) input.teamId = teamId
if (projectId !== undefined) input.projectId = projectId
Expand Down
Loading