Skip to content

Commit

Permalink
Fixup minor bugs in Jira Cloud and Server (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilianruesch authored Mar 20, 2024
1 parent df50d2d commit 11c66eb
Show file tree
Hide file tree
Showing 39 changed files with 512 additions and 633 deletions.
7 changes: 1 addition & 6 deletions electron/providers/base-provider/BaseProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ export interface IProvider {
editIssue(issue: Issue, issueIdOrKey: string): Promise<void>,
deleteIssue(issueIdOrKey: string): Promise<void>,
createIssue(issue: Issue): Promise<string>,
createSubtask(
parentIssueKey: string,
subtaskSummary: string,
projectId: string,
subtaskIssueTypeId: string
): Promise<{ id: string, key: string }>,
createSubtask(parentIssueKey: string, subtaskSummary: string, projectKey: string, subtaskIssueTypeId: string): Promise<string>,
getEpicsByProject(projectIdOrKey: string): Promise<Issue[]>,
getLabels(): Promise<string[]>,
getPriorities(): Promise<Priority[]>,
Expand Down
20 changes: 7 additions & 13 deletions electron/providers/jira-cloud-provider/JiraCloudProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,10 +615,9 @@ export class JiraCloudProvider implements IProvider {
// }),
},
})
.then(async (response) => {
const createdIssue = response.data;
resolve(createdIssue.key);
this.setTransition(createdIssue.id, status);
.then(async (response: AxiosResponse<{ id: string, key: string }>) => {
await this.setTransition(response.data.id, status);
resolve(response.data.key);
})
.catch((error) => {
if (error.response && error.response.status === 404) {
Expand Down Expand Up @@ -845,7 +844,7 @@ export class JiraCloudProvider implements IProvider {
return new Promise((resolve, reject) => {
this.getRestApiClient(2)
.delete(`/issue/${issueIdOrKey}?deleteSubtasks=true`)
.then(() => resolve)
.then(() => resolve())
.catch((error) => {
switch (error.response?.status) {
case 403: throw new Error("The user does not have permission to delete the issue");
Expand All @@ -858,23 +857,18 @@ export class JiraCloudProvider implements IProvider {
});
}

createSubtask(
parentIssueKey: string,
subtaskSummary: string,
projectId: string,
subtaskIssueTypeId: string,
): Promise<{ id: string, key: string }> {
createSubtask(parentIssueKey: string, subtaskSummary: string, projectKey: string, subtaskIssueTypeId: string): Promise<string> {
return new Promise((resolve, reject) => {
this.getRestApiClient(3)
.post("/issue", {
fields: {
summary: subtaskSummary,
issuetype: { id: subtaskIssueTypeId },
parent: { key: parentIssueKey },
project: { id: projectId },
project: { key: projectKey },
},
})
.then(async (response: AxiosResponse<{ id: string, key: string }>) => resolve(response.data))
.then(async (response: AxiosResponse<{ key: string }>) => resolve(response.data.key))
.catch((error) => reject(new Error(`Error creating subtask: ${error}`)));
});
}
Expand Down
34 changes: 13 additions & 21 deletions electron/providers/jira-server-provider/JiraServerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ export class JiraServerProvider implements IProvider {
type: jiraIssue.fields.issuetype.name,
storyPointsEstimate: await this.getIssueStoryPointsEstimate(jiraIssue.key),
epic: {
issueKey: jiraIssue.fields.parent?.key,
summary: jiraIssue.fields.parent?.fields.summary,
issueKey: jiraIssue.fields[this.customFields.get("Epic Link")!] as string | undefined,
summary: jiraIssue.fields[this.customFields.get("Epic Link")!] as string | undefined,
},
labels: jiraIssue.fields.labels,
assignee: jiraIssue.fields.assignee ? await this.mapUser(jiraIssue.fields.assignee) : undefined,
Expand Down Expand Up @@ -498,16 +498,14 @@ export class JiraServerProvider implements IProvider {
.post("/issue", {
fields: {
summary,
parent: { key: epic.issueKey },
...(epic.issueKey && {
[this.customFields.get("Epic Link")!]: epic.issueKey,
}),
issuetype: { id: type },
project: { id: projectKey },
project: { key: projectKey },
reporter: { name: reporter.name },
...(priority.id && { priority }),
...(assignee && {
assignee: {
name: assignee.name,
},
}),
assignee: { name: assignee?.name ?? "" },
description,
labels,
...(offsetStartDate && {
Expand All @@ -533,10 +531,9 @@ export class JiraServerProvider implements IProvider {
// }),
},
})
.then(async (response) => {
const createdIssue = response.data;
resolve(JSON.stringify(createdIssue.key));
await this.setTransition(createdIssue.id, status);
.then(async (response: AxiosResponse<{ id: string, key: string }>) => {
await this.setTransition(response.data.id, status);
resolve(response.data.key);
})
.catch((error) => {
switch (error.response?.status) {
Expand Down Expand Up @@ -748,23 +745,18 @@ export class JiraServerProvider implements IProvider {
});
}

createSubtask(
parentIssueKey: string,
subtaskSummary: string,
projectId: string,
subtaskIssueTypeId: string,
): Promise<{ id: string, key: string }> {
createSubtask(parentIssueKey: string, subtaskSummary: string, projectKey: string, subtaskIssueTypeId: string): Promise<string> {
return new Promise((resolve, reject) => {
this.getRestApiClient(2)
.post("/issue", {
fields: {
summary: subtaskSummary,
issuetype: { id: subtaskIssueTypeId },
parent: { key: parentIssueKey },
project: { id: projectId },
project: { key: projectKey },
},
})
.then((response: AxiosResponse<{ id: string, key: string }>) => resolve(response.data))
.then((response: AxiosResponse<{ key: string }>) => resolve(response.data.key))
.catch((error) => reject(new Error(`Error creating subtask: ${error}`)));
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/BacklogView/Issue/IssueCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function IssueCard({
epic,
labels,
assignee,
sprint,
index,
}: Issue & { index: number }) {
const [opened, setOpened] = useState(false);
Expand Down Expand Up @@ -179,6 +180,7 @@ export function IssueCard({
>
<DetailView
issueKey={issueKey}
sprint={sprint}
closeModal={() => {
setOpened(false);
queryClient.invalidateQueries({ queryKey: ["issues"] });
Expand Down
7 changes: 6 additions & 1 deletion src/components/BacklogView/Issue/IssueIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ThemeIcon } from "@mantine/core";
import { IconBookmark, IconCheck, IconBug, IconBolt, IconEdit } from "@tabler/icons-react";
import { IconBookmark, IconCheck, IconBug, IconBolt, IconEdit, IconBinaryTree2 } from "@tabler/icons-react";
import { ReactElement } from "react";

export function IssueIcon({ type }: { type: string }) {
Expand Down Expand Up @@ -36,6 +36,11 @@ export function IssueIcon({ type }: { type: string }) {
iconGradient1 = "violet";
iconGradient2 = "white";
break;
case "Sub-task":
icon = <IconBinaryTree2 />;
iconGradient1 = "primaryBlue";
iconGradient2 = "primaryBlue";
break;
default:
icon = <IconEdit />;
iconGradient1 = stringToColor(type);
Expand Down
4 changes: 2 additions & 2 deletions src/components/CreateIssue/CreateIssueModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { showNotification } from "@mantine/notifications";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { Issue } from "types";
import { useCanvasStore } from "../../lib/Store";
import { getResource, uploadAttachment } from "../DetailView/Components/Attachments/queryFunctions";
import { uploadAttachment } from "../issue-details/Attachments/queryFunctions";
import {
ProjectSelect,
IssueTypeSelect,
Expand Down Expand Up @@ -78,7 +78,7 @@ export function CreateIssueModalContent({
const filesForm = new FormData();
if (files) {
files.forEach((f) => filesForm.append("file", f, f.name));
getResource().then((r) => uploadAttachment(issueKey, r, filesForm));
window.provider.getResource().then((r) => uploadAttachment(issueKey, r, filesForm));
}
showNotification({
message: `The issue ${issueKey} has been created!`,
Expand Down
64 changes: 0 additions & 64 deletions src/components/DetailView/Components/AddSubtask/AddSubtask.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/DetailView/Components/AddSubtask/index.ts

This file was deleted.

22 changes: 0 additions & 22 deletions src/components/DetailView/Components/AddSubtask/queries.ts

This file was deleted.

14 changes: 0 additions & 14 deletions src/components/DetailView/Components/AddSubtask/queryFunctions.ts

This file was deleted.

Loading

0 comments on commit 11c66eb

Please sign in to comment.