-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Benedict Teutsch <bene210@web.de> Co-authored-by: Julian Rupprecht <rupprecht.julian@web.de>
- Loading branch information
1 parent
23f3e02
commit 435c09b
Showing
15 changed files
with
442 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
src/components/EpicDetailView/Components/IssueSprint.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { Text, Box, Select, useMantineTheme } from "@mantine/core" | ||
import { showNotification } from "@mantine/notifications" | ||
import { useMutation, useQuery } from "@tanstack/react-query" | ||
import { Issue, Sprint } from "types" | ||
import { useState } from "react" | ||
import { useCanvasStore } from "../../../lib/Store" | ||
import { | ||
getSprints, | ||
moveIssueToBacklog, | ||
} from "../../CreateIssue/queryFunctions" | ||
import { editIssue } from "../helpers/queryFunctions" | ||
|
||
export function IssueSprint(props: { | ||
sprint: Sprint | undefined | ||
issueKey: string | ||
}) { | ||
const theme = useMantineTheme() | ||
const [defaultsprint, setdefaultsprint] = useState(props.sprint || undefined) | ||
const [showSprintInput, setshowSprintInput] = useState(false) | ||
|
||
const boardIds = useCanvasStore((state) => state.selectedProjectBoardIds) | ||
const currentBoardId = boardIds[0] | ||
const { data: sprints } = useQuery({ | ||
queryKey: ["sprints"], | ||
queryFn: () => getSprints(currentBoardId), | ||
enabled: !!currentBoardId, | ||
}) | ||
|
||
const mutationSprint = useMutation({ | ||
mutationFn: (issue: Issue) => editIssue(issue, props.issueKey), | ||
onError: () => { | ||
showNotification({ | ||
message: `An error occured while modifing the sprint 😢`, | ||
color: "red", | ||
}) | ||
}, | ||
onSuccess: () => { | ||
showNotification({ | ||
message: `The sprint for issue ${props.issueKey} has been modified!`, | ||
color: "green", | ||
}) | ||
}, | ||
}) | ||
const mutationBacklog = useMutation({ | ||
mutationFn: () => moveIssueToBacklog(props.issueKey), | ||
onError: () => { | ||
showNotification({ | ||
message: `An error occured while modifing the sprint 😢`, | ||
color: "red", | ||
}) | ||
}, | ||
onSuccess: () => { | ||
showNotification({ | ||
message: `The sprint for issue ${props.issueKey} has been modified!`, | ||
color: "green", | ||
}) | ||
}, | ||
}) | ||
const sprintNames = sprints ? sprints?.map((sprint) => sprint.name) : [] | ||
return ( | ||
<span> | ||
{showSprintInput ? ( | ||
<Select | ||
nothingFound="No Options" | ||
searchable | ||
clearable | ||
defaultValue={props.sprint ? props.sprint.name : ""} | ||
data={sprintNames} | ||
onBlur={() => { | ||
setshowSprintInput(false) | ||
if (defaultsprint) | ||
mutationSprint.mutate({ | ||
sprint: defaultsprint, | ||
} as Issue) | ||
else mutationBacklog.mutate() | ||
}} | ||
onChange={(value) => { | ||
if (value === "") setdefaultsprint(undefined) | ||
else | ||
setdefaultsprint( | ||
sprints?.find((sprint) => sprint.name === value)! | ||
) | ||
}} | ||
/> | ||
) : ( | ||
<Box | ||
onClick={() => setshowSprintInput(true)} | ||
sx={{ | ||
":hover": { | ||
cursor: "pointer", | ||
boxShadow: theme.shadows.xs, | ||
borderRadius: theme.radius.xs, | ||
transition: "background-color .8s ease-out", | ||
}, | ||
}} | ||
> | ||
{defaultsprint ? ( | ||
<Text>{defaultsprint.name}</Text> | ||
) : ( | ||
<Text color="dimmed">None</Text> | ||
)} | ||
</Box> | ||
)} | ||
</span> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Text, Textarea } from "@mantine/core" | ||
import { Issue } from "types" | ||
import { useState } from "react" | ||
import { showNotification } from "@mantine/notifications" | ||
import { useMutation } from "@tanstack/react-query" | ||
import { editIssue } from "../helpers/queryFunctions" | ||
|
||
export function IssueSummary({ | ||
summary, | ||
issueKey, | ||
onMutate = () => {}, | ||
}: { | ||
summary: string | ||
issueKey: string | ||
onMutate?: () => void | ||
}) { | ||
const [defaultSummary, setDefaultSummary] = useState(summary) | ||
const [showSummaryInput, setShowSummaryInput] = useState(false) | ||
|
||
const mutationSummary = useMutation({ | ||
mutationFn: (issue: Issue) => editIssue(issue, issueKey), | ||
onError: () => { | ||
showNotification({ | ||
message: `An error occurred while modifying the summary 😢`, | ||
color: "red", | ||
}) | ||
}, | ||
onSuccess: () => { | ||
if (defaultSummary !== summary) { | ||
showNotification({ | ||
message: `The summary of issue ${issueKey} has been modified!`, | ||
color: "green", | ||
}) | ||
onMutate() | ||
} | ||
}, | ||
}) | ||
return ( | ||
<Text> | ||
{showSummaryInput ? ( | ||
<Textarea | ||
value={defaultSummary} | ||
onChange={(e) => setDefaultSummary(e.target.value)} | ||
onBlur={() => { | ||
if (defaultSummary === "") | ||
showNotification({ | ||
message: `The summary of an issue cannot be empty`, | ||
color: "red", | ||
}) | ||
else { | ||
setShowSummaryInput(false) | ||
mutationSummary.mutate({ | ||
summary: defaultSummary, | ||
} as Issue) | ||
} | ||
}} | ||
autosize | ||
sx={{ | ||
textarea: { | ||
fontSize: "inherit", | ||
fontWeight: "inherit", | ||
}, | ||
}} | ||
/> | ||
) : ( | ||
<Text lineClamp={1} onClick={() => setShowSummaryInput(true)}> | ||
{defaultSummary} | ||
</Text> | ||
)} | ||
</Text> | ||
) | ||
} |
62 changes: 62 additions & 0 deletions
62
src/components/EpicDetailView/Components/SubTask/Subtask.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Box, Group, Loader, Text, ThemeIcon } from "@mantine/core" | ||
import { IconBinaryTree2, IconTrash } from "@tabler/icons" | ||
import { useQueryClient } from "@tanstack/react-query" | ||
import { IssueSummary } from "../IssueSummary" | ||
import { deleteSubtaskMutation } from "./queries" | ||
|
||
export function Subtask({ | ||
id, | ||
subtaskKey, | ||
fields, | ||
}: { | ||
id: string | ||
subtaskKey: string | ||
fields: { | ||
summary: string | ||
} | ||
}) { | ||
const queryClient = useQueryClient() | ||
const deleteSubtask = deleteSubtaskMutation(queryClient) | ||
return ( | ||
<Group | ||
align="center" | ||
key={id} | ||
sx={(theme) => ({ | ||
borderRadius: theme.radius.sm, | ||
transition: "background-color .8s ease-out", | ||
boxShadow: theme.shadows.xs, | ||
":hover": { | ||
backgroundColor: "#ebecf0", | ||
transition: "background-color .1s ease-in", | ||
}, | ||
})} | ||
p="sm" | ||
> | ||
<ThemeIcon size="sm" sx={{ flex: 2 }}> | ||
<IconBinaryTree2 /> | ||
</ThemeIcon> | ||
<Text size="sm" color="blue" span sx={{ flex: 15 }} lineClamp={1}> | ||
{subtaskKey} | ||
</Text> | ||
<Box sx={{ flex: 50 }}> | ||
<IssueSummary summary={fields.summary} issueKey={subtaskKey} /> | ||
</Box> | ||
{deleteSubtask.isLoading && <Loader size="sm" />} | ||
<ThemeIcon | ||
variant="outline" | ||
size="sm" | ||
color="gray" | ||
ml="auto" | ||
sx={{ | ||
flex: 2, | ||
":hover": { color: "red", borderColor: "red", cursor: "pointer" }, | ||
}} | ||
onClick={() => { | ||
deleteSubtask.mutate(subtaskKey) | ||
}} | ||
> | ||
<IconTrash /> | ||
</ThemeIcon> | ||
</Group> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Subtask" |
21 changes: 21 additions & 0 deletions
21
src/components/EpicDetailView/Components/SubTask/queries.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { showNotification } from "@mantine/notifications" | ||
import { QueryClient, useMutation } from "@tanstack/react-query" | ||
import { deleteIssueSubtask } from "./queryFunctions" | ||
|
||
export const deleteSubtaskMutation = (queryClient: QueryClient) => | ||
useMutation({ | ||
mutationFn: deleteIssueSubtask, | ||
onError: () => { | ||
showNotification({ | ||
message: "The subtask couldn't be deleted! 😢", | ||
color: "red", | ||
}) | ||
}, | ||
onSuccess: () => { | ||
showNotification({ | ||
message: "Subtask has been deleted!", | ||
color: "green", | ||
}) | ||
queryClient.invalidateQueries({ queryKey: ["issues"] }) | ||
}, | ||
}) |
2 changes: 2 additions & 0 deletions
2
src/components/EpicDetailView/Components/SubTask/queryFunctions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const deleteIssueSubtask = (issueIdOrKey: string): Promise<void> => | ||
window.provider.deleteIssue(issueIdOrKey) |
Oops, something went wrong.