Skip to content
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

Add comment support in epic detail view #84

Merged
merged 13 commits into from
Dec 20, 2023
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
15 changes: 12 additions & 3 deletions electron/providers/jira-cloud-provider/JiraCloudProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
User,
} from "../../../types"
import {
JiraEpic,
JiraIssue,
JiraIssueType,
JiraPriority,
Expand Down Expand Up @@ -859,10 +860,10 @@ export class JiraCloudProvider implements IProvider {
async getEpicsByProject(projectIdOrKey: string): Promise<Issue[]> {
return new Promise((resolve, reject) => {
this.getRestApiClient(3)
.get(`search?jql=issuetype = Epic AND project = ${projectIdOrKey}`)
.get(`search?jql=issuetype = Epic AND project = ${projectIdOrKey}&fields=*all`)
.then(async (response) => {
const epics: Promise<Issue[]> = Promise.all(
response.data.issues.map(async (element: JiraIssue) => ({
response.data.issues.map(async (element: JiraEpic) => ({
issueKey: element.key,
summary: element.fields.summary,
epic: element.fields.epic,
Expand All @@ -875,7 +876,15 @@ export class JiraCloudProvider implements IProvider {
subtasks: element.fields.subtasks,
created: element.fields.created,
updated: element.fields.updated,
comment: element.fields.comment ?? {
comment: {
comments: element.fields.comment.comments.map((commentElement) => ({
id: commentElement.id,
body: commentElement.body.content[0].content[0].text,
author: commentElement.author,
created: commentElement.created,
updated: commentElement.updated,
})),
} ?? {
comments: [],
},
projectId: element.fields.project.id,
Expand Down
19 changes: 16 additions & 3 deletions electron/providers/jira-server-provider/JiraServerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
SprintCreate,
User,
} from "../../../types"
import {JiraIssue, JiraIssueType, JiraProject, JiraSprint,} from "../../../types/jira"
import {JiraEpic, JiraIssue, JiraIssueType, JiraProject, JiraSprint,} from "../../../types/jira"
import {IProvider} from "../base-provider"
import {JiraServerInfo, JiraServerUser} from "./server-types";

Expand Down Expand Up @@ -579,10 +579,10 @@ export class JiraServerProvider implements IProvider {
getEpicsByProject(projectIdOrKey: string): Promise<Issue[]> {
return new Promise((resolve, reject) => {
this.getRestApiClient(2)
.get(`search?jql=issuetype = Epic AND project = ${projectIdOrKey}`)
.get(`search?jql=issuetype = Epic AND project = ${projectIdOrKey}&fields=*all`)
.then(async (response) => {
const epics: Promise<Issue[]> = Promise.all(
response.data.issues.map(async (element: JiraIssue) => ({
response.data.issues.map(async (element: JiraEpic) => ({
issueKey: element.key,
summary: element.fields.summary,
labels: element.fields.labels,
Expand All @@ -593,6 +593,19 @@ export class JiraServerProvider implements IProvider {
displayName: element.fields.assignee?.displayName,
avatarUrls: element.fields.assignee?.avatarUrls,
},
subtasks: element.fields.subtasks,
comment: {
comments: element.fields.comment.comments.map((commentElement) => ({
id: commentElement.id,
body: commentElement.body,
author: commentElement.author,
created: commentElement.created,
updated: commentElement.updated,
})),
},
projectId: element.fields.project.id,
sprint: element.fields.sprint,
attachments: element.fields.attachment,
}))
)
resolve(epics)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const addCommentMutation = (queryClient: QueryClient) =>
color: "green",
})
queryClient.invalidateQueries({ queryKey: ["issues"] })
queryClient.invalidateQueries({queryKey: ["epics"]})
},
})

Expand All @@ -53,6 +54,7 @@ export const editCommentMutation = (queryClient: QueryClient) =>
color: "green",
})
queryClient.invalidateQueries({ queryKey: ["issues"] })
queryClient.invalidateQueries({queryKey: ["epics"]})
},
})

Expand All @@ -77,5 +79,6 @@ export const deleteCommentMutation = (queryClient: QueryClient) =>
color: "green",
})
queryClient.invalidateQueries({ queryKey: ["issues"] })
queryClient.invalidateQueries({queryKey: ["epics"]})
},
})
25 changes: 24 additions & 1 deletion src/components/EpicDetailView/EpicDetailView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
storyPointsAccumulator,
} from "./helpers/storyPointsHelper"
import { StoryPointsHoverCard } from "./Components/StoryPointsHoverCard";
import { CommentSection } from "../DetailView/Components/CommentSection";

export function EpicDetailView({
issueKey,
Expand All @@ -42,6 +43,7 @@ export function EpicDetailView({
description,
created,
updated,
comment,
closeModal,
}: {
issueKey: string
Expand All @@ -51,6 +53,17 @@ export function EpicDetailView({
description: string
created: string
updated: string
comment: {
comments: [
{
id: string
author: User
body: string
created: string
updated: string
}
]
}
closeModal: () => void
}) {
const queryClient = useQueryClient()
Expand Down Expand Up @@ -238,7 +251,17 @@ export function EpicDetailView({
</Accordion.Panel>
</Accordion.Item>
</Accordion>
<Text size="xs" color="dimmed">
<Accordion variant="contained" mb={20}>
<Accordion.Item value="Comments">
<Accordion.Control sx={{ textAlign: "left" }}>
Comments
</Accordion.Control>
<Accordion.Panel>
<CommentSection issueKey={issueKey} comment={comment} />
</Accordion.Panel>
</Accordion.Item>
</Accordion>
<Text size="xs" color="dimmed">
Created {dateFormat.format(new Date(created))}
</Text>
<Text size="xs" color="dimmed">
Expand Down
84 changes: 83 additions & 1 deletion types/jira.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Attachment, Priority } from "."
import {Attachment, Priority} from "."

export interface JiraProject {
projectTypeKey: string
Expand All @@ -18,6 +18,88 @@ export interface JiraSprint {
name: string
}

// EpicIssue structure differs from normal Issue structure
export interface JiraEpic {
key: string
fields: {
description: {
type: string,
version: string,
content: string & {
content: {
type: string,
text: string
}[]
}[]
}
summary: string
creator: { name: string; displayName: string }
status: { name: string }
issuetype: { name: string }
// TODO: improve this, let's try not to hardcode customfields
customfield_10107: number
parent: { id: string; fields: { summary: string } }
epic: { name: string }
labels: string[]
assignee: {
displayName: string
avatarUrls: {
"16x16": string
"24x24": string
"36x36": string
"48x48": string
}
}
[rankCustomField: string]: string | unknown
subtasks: {
id: string
key: string
fields: {
summary: string
}
}[]
project: { id: string }
created: string
updated: string
comment: {
comments: [
{
id: string
author: {
accountId: string
avatarUrls: {
"48x48": string
"24x24": string
"16x16": string
"32x32": string
}
displayName: string
}
body: {
type: string
version: number
content: [
{
type: string
content: [
{
type: string
text: string
}
]
}
]
}
created: string
updated: string
}
]
}
sprint?: JiraSprint
attachment?: Attachment[]
}
}

export interface JiraIssue {
key: string
fields: {
Expand Down