Skip to content

Commit

Permalink
Fix server provider for creating epics
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilianruesch committed Nov 27, 2023
1 parent 60f7867 commit 51dc1b3
Showing 1 changed file with 62 additions and 54 deletions.
116 changes: 62 additions & 54 deletions electron/providers/jira-server-provider/JiraServerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,62 +439,70 @@ export class JiraServerProvider implements IProvider {
const offsetDueDate = this.offsetDate(dueDate)

return new Promise((resolve, reject) => {
this.getRestApiClient(2)
.post(
`/issue`,
{
fields: {
summary,
parent: { key: epic },
issuetype: { id: type },
project: {
id: projectId,
},
reporter: {
name: reporter.name,
},
...(priority.id && { priority }),
...(assignee && {
assignee: {
name: assignee.name,
this.getIssueTypesByProject(projectId)
.then((issueTypes) => {
const relevantIssueType = issueTypes.find((issueType) => issueType.id === type)

this.getRestApiClient(2)
.post(
`/issue`,
{
fields: {
summary,
parent: { key: epic },
issuetype: { id: type },
project: {
id: projectId,
},
reporter: {
name: reporter.name,
},
...(priority.id && { priority }),
...(assignee && {
assignee: {
name: assignee.name,
},
}),
description,
labels,
...(offsetStartDate && {
[this.customFields.get("Start date")!]: offsetStartDate,
}),
...(offsetDueDate && {
[this.customFields.get("Due date")!]: offsetDueDate,
}),
...(sprint &&
sprint.id && {
[this.customFields.get("Sprint")!]: +sprint.id,
}),
...(storyPointsEstimate && {
[this.customFields.get("Story point estimate")!]:
storyPointsEstimate,
}),
...(relevantIssueType && relevantIssueType.name === 'Epic' && {
[this.customFields.get("Epic Name")!]: summary
}),
// ...(files && {
// [this.customFields.get("Attachment")!]: files,
// }),
},
}),
description,
labels,
...(offsetStartDate && {
[this.customFields.get("Start date")!]: offsetStartDate,
}),
...(offsetDueDate && {
[this.customFields.get("Due date")!]: offsetDueDate,
}),
...(sprint &&
sprint.id && {
[this.customFields.get("Sprint")!]: +sprint.id,
}),
...(storyPointsEstimate && {
[this.customFields.get("Story point estimate")!]:
storyPointsEstimate,
}),
// ...(files && {
// [this.customFields.get("Attachment")!]: files,
// }),
},
}
)
.then(async (response) => {
const createdIssue = response.data
resolve(JSON.stringify(createdIssue.key))
await this.setTransition(createdIssue.id, status)
})
.catch((error) => {
let specificError = error
if (error.response) {
if (error.response.status === 404) {
specificError = new Error("The user does not have the necessary permissions")
}
}
}
)
.then(async (response) => {
const createdIssue = response.data
resolve(JSON.stringify(createdIssue.key))
await this.setTransition(createdIssue.id, status)
})
.catch((error) => {
let specificError = error
if (error.response) {
if (error.response.status === 404) {
specificError = new Error("The user does not have the necessary permissions")
}
}

reject(new Error(`Error creating issue: ${specificError}`))
reject(new Error(`Error creating issue: ${specificError}`))
})
})
})
}
Expand Down

0 comments on commit 51dc1b3

Please sign in to comment.