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

Fix deletion of issues with present subtasks #148

Merged
merged 2 commits into from
Mar 11, 2024
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
35 changes: 8 additions & 27 deletions electron/providers/jira-cloud-provider/JiraCloudProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1145,38 +1145,19 @@ export class JiraCloudProvider implements IProvider {
deleteIssue(issueIdOrKey: string): Promise<void> {
return new Promise((resolve, reject) => {
this.getRestApiClient(2)
.delete(`/issue/${issueIdOrKey}`)
.delete(`/issue/${issueIdOrKey}?deleteSubtasks=true`)
.then(async () => {
resolve();
})
.catch((error) => {
let specificError = error;
if (error.response) {
if (error.response.status === 400) {
specificError = new Error(
"The issue has subtasks and deleteSubtasks is not set to true",
);
} else if (error.response.status === 403) {
specificError = new Error(
"The user does not have permission to delete the issue",
);
} else if (error.response.status === 404) {
specificError = new Error(
"The issue was not found or the user does not have the necessary permissions",
);
} else if (error.response.status === 405) {
specificError = new Error(
"An anonymous call has been made to the operation",
);
}
switch (error.response?.status) {
case 403: throw new Error("The user does not have permission to delete the issue");
case 404: throw new Error("The issue was not found or the user does not have the necessary permissions");
case 405: throw new Error("An anonymous call has been made to the operation");
default:
}

reject(
new Error(
`Error deleting the subtask ${issueIdOrKey}: ${specificError}`,
),
);
});
})
.catch((error) => reject(new Error(`Error deleting the subtask ${issueIdOrKey}: ${error}`)));
});
}

Expand Down
4 changes: 1 addition & 3 deletions src/components/DetailView/DetailView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ export function DetailView({
mutationDescription.mutate({ description: newDescription });
}}
/>
<Text c="dimmed" mb="sm">
Child Issues
</Text>
<Text c="dimmed" mb="sm">Subtasks</Text>
<Paper mb="lg" mr="sm">
<Stack gap="xs">
{subtasks.map((subtask) => (
Expand Down