2022-12-20 07:46:40 +00:00
|
|
|
import React, { useCallback, useEffect, useState } from "react";
|
2022-11-19 14:21:26 +00:00
|
|
|
// next
|
2022-12-15 04:17:56 +00:00
|
|
|
import Link from "next/link";
|
2022-12-21 13:41:04 +00:00
|
|
|
import dynamic from "next/dynamic";
|
2022-11-19 14:21:26 +00:00
|
|
|
import type { NextPage } from "next";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
// swr
|
2022-12-21 13:41:04 +00:00
|
|
|
import { mutate } from "swr";
|
2022-11-19 14:21:26 +00:00
|
|
|
// react hook form
|
2022-12-16 16:20:09 +00:00
|
|
|
import { useForm } from "react-hook-form";
|
2022-12-20 07:46:40 +00:00
|
|
|
// headless ui
|
|
|
|
import { Disclosure, Menu, Tab, Transition } from "@headlessui/react";
|
|
|
|
// fetch keys
|
2022-12-21 13:41:04 +00:00
|
|
|
import { PROJECT_ISSUES_LIST } from "constants/fetch-keys";
|
2022-11-19 14:21:26 +00:00
|
|
|
// services
|
2022-12-12 04:49:52 +00:00
|
|
|
import issuesServices from "lib/services/issues.service";
|
2022-12-20 07:46:40 +00:00
|
|
|
// common
|
|
|
|
import { debounce } from "constants/common";
|
2022-11-19 14:21:26 +00:00
|
|
|
// hooks
|
|
|
|
import useUser from "lib/hooks/useUser";
|
2022-12-08 14:59:12 +00:00
|
|
|
// hoc
|
|
|
|
import withAuth from "lib/hoc/withAuthWrapper";
|
2022-11-19 14:21:26 +00:00
|
|
|
// layouts
|
2022-12-13 15:52:44 +00:00
|
|
|
import AppLayout from "layouts/app-layout";
|
2022-11-19 14:21:26 +00:00
|
|
|
// components
|
2022-12-16 16:20:09 +00:00
|
|
|
import AddAsSubIssue from "components/project/issues/issue-detail/add-as-sub-issue";
|
2022-12-21 13:41:04 +00:00
|
|
|
import CreateUpdateIssuesModal from "components/project/issues/create-update-issue-modal";
|
2022-12-15 04:17:56 +00:00
|
|
|
import IssueDetailSidebar from "components/project/issues/issue-detail/issue-detail-sidebar";
|
2022-12-21 13:41:04 +00:00
|
|
|
import IssueCommentSection from "components/project/issues/issue-detail/comment/IssueCommentSection";
|
|
|
|
const IssueActivitySection = dynamic(
|
|
|
|
() => import("components/project/issues/issue-detail/activity"),
|
|
|
|
{
|
|
|
|
loading: () => (
|
|
|
|
<div className="w-full h-full flex justify-center items-center">
|
|
|
|
<Spinner />
|
|
|
|
</div>
|
|
|
|
),
|
|
|
|
ssr: false,
|
|
|
|
}
|
|
|
|
);
|
2022-11-19 14:21:26 +00:00
|
|
|
// ui
|
2022-12-21 13:41:04 +00:00
|
|
|
import { Spinner, TextArea, HeaderButton, Breadcrumbs } from "ui";
|
2022-11-24 13:48:18 +00:00
|
|
|
// icons
|
2022-12-02 14:12:58 +00:00
|
|
|
import {
|
|
|
|
ChevronLeftIcon,
|
|
|
|
ChevronRightIcon,
|
|
|
|
EllipsisHorizontalIcon,
|
|
|
|
PlusIcon,
|
|
|
|
} from "@heroicons/react/24/outline";
|
2022-12-17 20:01:13 +00:00
|
|
|
// types
|
2022-12-21 13:41:04 +00:00
|
|
|
import { IIssue, IssueResponse } from "types";
|
2022-11-19 14:21:26 +00:00
|
|
|
|
2022-12-13 15:52:44 +00:00
|
|
|
const RichTextEditor = dynamic(() => import("components/lexical/editor"), {
|
|
|
|
ssr: false,
|
|
|
|
});
|
2022-11-19 14:21:26 +00:00
|
|
|
|
2022-12-21 13:41:04 +00:00
|
|
|
const defaultValues = {
|
|
|
|
name: "",
|
|
|
|
description: "",
|
|
|
|
state: "",
|
|
|
|
assignees_list: [],
|
|
|
|
priority: "low",
|
|
|
|
blockers_list: [],
|
|
|
|
blocked_list: [],
|
|
|
|
target_date: new Date().toString(),
|
|
|
|
issue_cycle: null,
|
|
|
|
labels_list: [],
|
|
|
|
};
|
|
|
|
|
2022-12-13 15:52:44 +00:00
|
|
|
const IssueDetail: NextPage = () => {
|
2022-12-21 13:41:04 +00:00
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
const { issueId, projectId } = router.query;
|
|
|
|
|
|
|
|
const { activeWorkspace, activeProject, issues, mutateIssues } = useUser();
|
|
|
|
|
|
|
|
const issueDetail = issues?.results?.find((issue) => issue.id === issueId);
|
|
|
|
|
|
|
|
const prevIssue = issues?.results[issues?.results.findIndex((issue) => issue.id === issueId) - 1];
|
|
|
|
const nextIssue = issues?.results[issues?.results.findIndex((issue) => issue.id === issueId) + 1];
|
|
|
|
|
|
|
|
const subIssues = (issues && issues.results.filter((i) => i.parent === issueId)) ?? [];
|
|
|
|
const siblingIssues =
|
|
|
|
issueDetail &&
|
|
|
|
issues?.results.filter((i) => i.parent === issueDetail.parent && i.id !== issueId);
|
2022-11-19 14:21:26 +00:00
|
|
|
|
|
|
|
const [isOpen, setIsOpen] = useState(false);
|
2022-12-02 14:12:58 +00:00
|
|
|
const [isAddAsSubIssueOpen, setIsAddAsSubIssueOpen] = useState(false);
|
2022-11-19 14:21:26 +00:00
|
|
|
|
2022-12-02 14:12:58 +00:00
|
|
|
const [preloadedData, setPreloadedData] = useState<
|
|
|
|
(Partial<IIssue> & { actionType: "createIssue" | "edit" | "delete" }) | undefined
|
|
|
|
>(undefined);
|
|
|
|
|
|
|
|
const [issueDescriptionValue, setIssueDescriptionValue] = useState("");
|
2022-12-13 15:52:44 +00:00
|
|
|
|
2022-12-02 14:12:58 +00:00
|
|
|
const handleDescriptionChange: any = (value: any) => {
|
|
|
|
console.log(value);
|
|
|
|
setIssueDescriptionValue(value);
|
|
|
|
};
|
|
|
|
|
2022-11-19 14:21:26 +00:00
|
|
|
const {
|
|
|
|
register,
|
|
|
|
formState: { errors },
|
|
|
|
handleSubmit,
|
|
|
|
reset,
|
|
|
|
control,
|
2022-12-03 13:41:07 +00:00
|
|
|
watch,
|
2022-11-30 15:58:45 +00:00
|
|
|
} = useForm<IIssue>({
|
2022-12-21 13:41:04 +00:00
|
|
|
defaultValues,
|
2022-11-30 15:58:45 +00:00
|
|
|
});
|
2022-11-19 14:21:26 +00:00
|
|
|
|
|
|
|
const submitChanges = useCallback(
|
|
|
|
(formData: Partial<IIssue>) => {
|
|
|
|
if (!activeWorkspace || !activeProject || !issueId) return;
|
2022-12-03 13:41:07 +00:00
|
|
|
|
2022-11-19 14:21:26 +00:00
|
|
|
mutateIssues(
|
|
|
|
(prevData) => ({
|
|
|
|
...(prevData as IssueResponse),
|
|
|
|
results: (prevData?.results ?? []).map((issue) => {
|
|
|
|
if (issue.id === issueId) {
|
|
|
|
return { ...issue, ...formData };
|
|
|
|
}
|
|
|
|
return issue;
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
false
|
|
|
|
);
|
2022-12-03 13:41:07 +00:00
|
|
|
|
2022-12-13 15:52:44 +00:00
|
|
|
const payload = {
|
|
|
|
...formData,
|
|
|
|
// description: formData.description ? JSON.parse(formData.description) : null,
|
|
|
|
};
|
|
|
|
|
2022-11-19 14:21:26 +00:00
|
|
|
issuesServices
|
2022-12-13 15:52:44 +00:00
|
|
|
.patchIssue(activeWorkspace.slug, projectId as string, issueId as string, payload)
|
2022-11-19 14:21:26 +00:00
|
|
|
.then((response) => {
|
2022-12-20 07:46:40 +00:00
|
|
|
mutateIssues((prevData) => ({
|
|
|
|
...(prevData as IssueResponse),
|
|
|
|
results: (prevData?.results ?? []).map((issue) => {
|
|
|
|
if (issue.id === issueId) {
|
|
|
|
return { ...issue, ...response };
|
|
|
|
}
|
|
|
|
return issue;
|
|
|
|
}),
|
|
|
|
}));
|
2022-11-19 14:21:26 +00:00
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.log(error);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
[activeProject, activeWorkspace, issueId, projectId, mutateIssues]
|
|
|
|
);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (issueDetail)
|
|
|
|
reset({
|
|
|
|
...issueDetail,
|
2022-12-13 15:52:44 +00:00
|
|
|
// description: JSON.stringify(issueDetail.description),
|
2022-11-19 14:21:26 +00:00
|
|
|
blockers_list:
|
|
|
|
issueDetail.blockers_list ??
|
|
|
|
issueDetail.blocker_issues?.map((issue) => issue.blocker_issue_detail?.id),
|
|
|
|
blocked_list:
|
|
|
|
issueDetail.blocked_list ??
|
|
|
|
issueDetail.blocked_issues?.map((issue) => issue.blocked_issue_detail?.id),
|
|
|
|
assignees_list:
|
|
|
|
issueDetail.assignees_list ?? issueDetail.assignee_details?.map((user) => user.id),
|
2022-12-20 07:46:40 +00:00
|
|
|
labels_list: issueDetail.labels_list ?? issueDetail.labels,
|
|
|
|
labels: issueDetail.labels_list ?? issueDetail.labels,
|
2022-11-19 14:21:26 +00:00
|
|
|
});
|
|
|
|
}, [issueDetail, reset]);
|
|
|
|
|
2022-12-06 14:38:28 +00:00
|
|
|
const handleSubIssueRemove = (issueId: string) => {
|
2022-12-02 14:12:58 +00:00
|
|
|
if (activeWorkspace && activeProject) {
|
|
|
|
issuesServices
|
|
|
|
.patchIssue(activeWorkspace.slug, activeProject.id, issueId, { parent: null })
|
|
|
|
.then((res) => {
|
|
|
|
mutate<IssueResponse>(
|
|
|
|
PROJECT_ISSUES_LIST(activeWorkspace.slug, activeProject.id),
|
|
|
|
(prevData) => ({
|
|
|
|
...(prevData as IssueResponse),
|
|
|
|
results: (prevData?.results ?? []).map((p) =>
|
|
|
|
p.id === issueId ? { ...p, ...res } : p
|
|
|
|
),
|
|
|
|
}),
|
|
|
|
false
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
console.log(e);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-11-19 14:21:26 +00:00
|
|
|
return (
|
2022-12-13 15:52:44 +00:00
|
|
|
<AppLayout
|
|
|
|
noPadding={true}
|
|
|
|
bg="secondary"
|
|
|
|
breadcrumbs={
|
|
|
|
<Breadcrumbs>
|
2022-12-21 13:41:04 +00:00
|
|
|
<Breadcrumbs.BreadcrumbItem
|
2022-12-13 15:52:44 +00:00
|
|
|
title={`${activeProject?.name ?? "Project"} Issues`}
|
|
|
|
link={`/projects/${activeProject?.id}/issues`}
|
|
|
|
/>
|
2022-12-21 13:41:04 +00:00
|
|
|
<Breadcrumbs.BreadcrumbItem
|
2022-12-13 15:52:44 +00:00
|
|
|
title={`Issue ${activeProject?.identifier ?? "Project"}-${
|
|
|
|
issueDetail?.sequence_id ?? "..."
|
|
|
|
} Details`}
|
|
|
|
/>
|
|
|
|
</Breadcrumbs>
|
|
|
|
}
|
|
|
|
right={
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
<HeaderButton
|
|
|
|
Icon={ChevronLeftIcon}
|
|
|
|
label="Previous"
|
2022-12-20 07:46:40 +00:00
|
|
|
className={!prevIssue ? "cursor-not-allowed opacity-70" : ""}
|
2022-12-13 15:52:44 +00:00
|
|
|
onClick={() => {
|
|
|
|
if (!prevIssue) return;
|
|
|
|
router.push(`/projects/${prevIssue.project}/issues/${prevIssue.id}`);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<HeaderButton
|
|
|
|
Icon={ChevronRightIcon}
|
|
|
|
disabled={!nextIssue}
|
|
|
|
label="Next"
|
2022-12-20 07:46:40 +00:00
|
|
|
className={!nextIssue ? "cursor-not-allowed opacity-70" : ""}
|
2022-12-13 15:52:44 +00:00
|
|
|
onClick={() => {
|
|
|
|
if (!nextIssue) return;
|
|
|
|
router.push(`/projects/${nextIssue.project}/issues/${nextIssue?.id}`);
|
|
|
|
}}
|
|
|
|
position="reverse"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
>
|
2022-12-21 13:41:04 +00:00
|
|
|
{isOpen && (
|
|
|
|
<CreateUpdateIssuesModal
|
|
|
|
isOpen={isOpen}
|
|
|
|
setIsOpen={setIsOpen}
|
|
|
|
projectId={projectId as string}
|
|
|
|
prePopulateData={{
|
|
|
|
...preloadedData,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{isAddAsSubIssueOpen && (
|
|
|
|
<AddAsSubIssue
|
|
|
|
isOpen={isAddAsSubIssueOpen}
|
|
|
|
setIsOpen={setIsAddAsSubIssueOpen}
|
|
|
|
parent={issueDetail}
|
|
|
|
/>
|
|
|
|
)}
|
2022-12-01 14:29:21 +00:00
|
|
|
{issueDetail && activeProject ? (
|
2022-12-17 20:01:13 +00:00
|
|
|
<div className="h-full flex gap-5">
|
|
|
|
<div className="basis-2/3 space-y-5 p-5">
|
2022-12-13 15:52:44 +00:00
|
|
|
<div className="mb-5"></div>
|
2022-12-07 23:27:10 +00:00
|
|
|
<div className="rounded-lg">
|
2022-12-06 14:38:28 +00:00
|
|
|
{issueDetail.parent !== null && issueDetail.parent !== "" ? (
|
|
|
|
<div className="bg-gray-100 flex items-center gap-2 p-2 text-xs rounded mb-5 w-min whitespace-nowrap">
|
|
|
|
<Link href={`/projects/${activeProject.id}/issues/${issueDetail.parent}`}>
|
|
|
|
<a className="flex items-center gap-2">
|
|
|
|
<span
|
2022-12-20 07:46:40 +00:00
|
|
|
className="h-1.5 w-1.5 block rounded-full"
|
2022-12-06 14:38:28 +00:00
|
|
|
style={{
|
|
|
|
backgroundColor: issueDetail.state_detail.color,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<span className="flex-shrink-0 text-gray-600">
|
2022-12-07 23:27:10 +00:00
|
|
|
{activeProject.identifier}-
|
|
|
|
{issues?.results.find((i) => i.id === issueDetail.parent)?.sequence_id}
|
2022-12-06 14:38:28 +00:00
|
|
|
</span>
|
|
|
|
<span className="font-medium truncate">
|
|
|
|
{issues?.results
|
|
|
|
.find((i) => i.id === issueDetail.parent)
|
|
|
|
?.name.substring(0, 50)}
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
<Menu as="div" className="relative inline-block">
|
|
|
|
<Menu.Button className="grid relative place-items-center hover:bg-gray-200 rounded p-1 focus:outline-none">
|
|
|
|
<EllipsisHorizontalIcon className="h-4 w-4" />
|
|
|
|
</Menu.Button>
|
|
|
|
|
|
|
|
<Transition
|
|
|
|
as={React.Fragment}
|
|
|
|
enter="transition ease-out duration-100"
|
|
|
|
enterFrom="transform opacity-0 scale-95"
|
|
|
|
enterTo="transform opacity-100 scale-100"
|
|
|
|
leave="transition ease-in duration-75"
|
|
|
|
leaveFrom="transform opacity-100 scale-100"
|
|
|
|
leaveTo="transform opacity-0 scale-95"
|
|
|
|
>
|
|
|
|
<Menu.Items className="absolute left-0 mt-1 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none z-50">
|
|
|
|
<div className="p-1">
|
|
|
|
{siblingIssues && siblingIssues.length > 0 ? (
|
|
|
|
siblingIssues.map((issue) => (
|
|
|
|
<Menu.Item as="div" key={issue.id}>
|
|
|
|
<Link href={`/projects/${activeProject.id}/issues/${issue.id}`}>
|
|
|
|
<a className="flex items-center gap-2 p-2 text-left text-gray-900 hover:bg-theme hover:text-white rounded-md text-xs whitespace-nowrap">
|
|
|
|
{activeProject.identifier}-{issue.sequence_id}
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
</Menu.Item>
|
|
|
|
))
|
|
|
|
) : (
|
|
|
|
<Menu.Item
|
|
|
|
as="div"
|
|
|
|
className="flex items-center gap-2 p-2 text-left text-gray-900 text-xs whitespace-nowrap"
|
|
|
|
>
|
|
|
|
No other sub-issues
|
|
|
|
</Menu.Item>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</Menu.Items>
|
|
|
|
</Transition>
|
|
|
|
</Menu>
|
|
|
|
</div>
|
|
|
|
) : null}
|
2022-12-02 14:12:58 +00:00
|
|
|
<div>
|
|
|
|
<TextArea
|
|
|
|
id="name"
|
|
|
|
placeholder="Enter issue name"
|
|
|
|
name="name"
|
|
|
|
autoComplete="off"
|
|
|
|
validations={{ required: true }}
|
|
|
|
register={register}
|
|
|
|
onChange={debounce(() => {
|
|
|
|
handleSubmit(submitChanges)();
|
|
|
|
}, 5000)}
|
|
|
|
mode="transparent"
|
|
|
|
className="text-xl font-medium"
|
|
|
|
/>
|
2022-12-06 14:38:28 +00:00
|
|
|
<TextArea
|
2022-12-02 14:12:58 +00:00
|
|
|
id="description"
|
|
|
|
name="description"
|
|
|
|
error={errors.description}
|
|
|
|
validations={{
|
|
|
|
required: true,
|
|
|
|
}}
|
|
|
|
onChange={debounce(() => {
|
|
|
|
handleSubmit(submitChanges)();
|
|
|
|
}, 5000)}
|
|
|
|
placeholder="Enter issue description"
|
|
|
|
mode="transparent"
|
|
|
|
register={register}
|
2022-12-06 14:38:28 +00:00
|
|
|
/>
|
|
|
|
{/* <Controller
|
2022-12-03 13:41:07 +00:00
|
|
|
name="description"
|
|
|
|
control={control}
|
2022-12-13 15:52:44 +00:00
|
|
|
render={({ field: { value, onChange } }) => (
|
2022-12-03 13:41:07 +00:00
|
|
|
<RichTextEditor
|
2022-12-13 15:52:44 +00:00
|
|
|
// value={JSON.stringify(issueDetail.description)}
|
|
|
|
value={value}
|
|
|
|
onChange={(val) => {
|
|
|
|
debounce(() => {
|
|
|
|
console.log("Debounce");
|
|
|
|
// handleSubmit(submitChanges)();
|
|
|
|
}, 5000)();
|
|
|
|
onChange(val);
|
|
|
|
}}
|
2022-12-03 13:41:07 +00:00
|
|
|
id="issueDescriptionEditor"
|
|
|
|
/>
|
|
|
|
)}
|
2022-12-06 14:38:28 +00:00
|
|
|
/> */}
|
2022-12-02 14:12:58 +00:00
|
|
|
</div>
|
|
|
|
<div className="mt-2">
|
|
|
|
{subIssues && subIssues.length > 0 ? (
|
2022-12-07 23:27:10 +00:00
|
|
|
<Disclosure defaultOpen={true}>
|
2022-12-02 14:12:58 +00:00
|
|
|
{({ open }) => (
|
|
|
|
<>
|
|
|
|
<div className="flex justify-between items-center">
|
|
|
|
<Disclosure.Button className="flex items-center gap-1 px-2 py-1 rounded hover:bg-gray-100 text-xs font-medium">
|
|
|
|
<ChevronRightIcon className={`h-3 w-3 ${open ? "rotate-90" : ""}`} />
|
|
|
|
Sub-issues{" "}
|
|
|
|
<span className="text-gray-600 ml-1">{subIssues.length}</span>
|
|
|
|
</Disclosure.Button>
|
|
|
|
{open ? (
|
|
|
|
<div className="flex items-center">
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="flex items-center gap-1 px-2 py-1 rounded hover:bg-gray-100 text-xs font-medium"
|
|
|
|
onClick={() => {
|
|
|
|
setIsOpen(true);
|
|
|
|
setPreloadedData({
|
|
|
|
parent: issueDetail.id,
|
|
|
|
actionType: "createIssue",
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<PlusIcon className="h-3 w-3" />
|
2022-12-06 14:38:28 +00:00
|
|
|
Create new
|
2022-12-02 14:12:58 +00:00
|
|
|
</button>
|
|
|
|
|
|
|
|
<Menu as="div" className="relative inline-block">
|
|
|
|
<Menu.Button className="grid relative place-items-center rounded p-1 hover:bg-gray-100 focus:outline-none">
|
|
|
|
<EllipsisHorizontalIcon className="h-4 w-4" />
|
|
|
|
</Menu.Button>
|
|
|
|
|
|
|
|
<Transition
|
|
|
|
as={React.Fragment}
|
|
|
|
enter="transition ease-out duration-100"
|
|
|
|
enterFrom="transform opacity-0 scale-95"
|
|
|
|
enterTo="transform opacity-100 scale-100"
|
|
|
|
leave="transition ease-in duration-75"
|
|
|
|
leaveFrom="transform opacity-100 scale-100"
|
|
|
|
leaveTo="transform opacity-0 scale-95"
|
|
|
|
>
|
|
|
|
<Menu.Items className="origin-top-right absolute right-0 mt-2 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none z-50">
|
|
|
|
<div className="p-1">
|
|
|
|
<Menu.Item as="div">
|
2022-12-20 07:46:40 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="flex items-center gap-2 p-2 text-left text-gray-900 hover:bg-theme hover:text-white rounded-md text-xs whitespace-nowrap"
|
|
|
|
onClick={() => setIsAddAsSubIssueOpen(true)}
|
|
|
|
>
|
|
|
|
Add an existing issue
|
|
|
|
</button>
|
2022-12-02 14:12:58 +00:00
|
|
|
</Menu.Item>
|
|
|
|
</div>
|
|
|
|
</Menu.Items>
|
|
|
|
</Transition>
|
|
|
|
</Menu>
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
<Transition
|
|
|
|
enter="transition duration-100 ease-out"
|
|
|
|
enterFrom="transform scale-95 opacity-0"
|
|
|
|
enterTo="transform scale-100 opacity-100"
|
|
|
|
leave="transition duration-75 ease-out"
|
|
|
|
leaveFrom="transform scale-100 opacity-100"
|
|
|
|
leaveTo="transform scale-95 opacity-0"
|
|
|
|
>
|
|
|
|
<Disclosure.Panel className="flex flex-col gap-y-1 mt-3">
|
|
|
|
{subIssues.map((subIssue) => (
|
2022-12-06 14:38:28 +00:00
|
|
|
<div
|
2022-12-02 14:12:58 +00:00
|
|
|
key={subIssue.id}
|
2022-12-07 23:27:10 +00:00
|
|
|
className="group flex justify-between items-center gap-2 rounded p-2 hover:bg-gray-100"
|
2022-12-02 14:12:58 +00:00
|
|
|
>
|
2022-12-06 14:38:28 +00:00
|
|
|
<Link href={`/projects/${activeProject.id}/issues/${subIssue.id}`}>
|
|
|
|
<a className="flex items-center gap-2 rounded text-xs">
|
2022-12-02 14:12:58 +00:00
|
|
|
<span
|
|
|
|
className={`h-1.5 w-1.5 block rounded-full`}
|
|
|
|
style={{
|
|
|
|
backgroundColor: subIssue.state_detail.color,
|
|
|
|
}}
|
|
|
|
/>
|
2022-12-06 14:38:28 +00:00
|
|
|
<span className="flex-shrink-0 text-gray-600">
|
2022-12-02 14:12:58 +00:00
|
|
|
{activeProject.identifier}-{subIssue.sequence_id}
|
|
|
|
</span>
|
2022-12-06 14:38:28 +00:00
|
|
|
<span className="font-medium max-w-sm break-all">
|
|
|
|
{subIssue.name}
|
|
|
|
</span>
|
|
|
|
</a>
|
|
|
|
</Link>
|
2022-12-07 23:27:10 +00:00
|
|
|
<div className="opacity-0 group-hover:opacity-100">
|
2022-12-06 14:38:28 +00:00
|
|
|
<Menu as="div" className="relative inline-block">
|
2022-12-07 23:27:10 +00:00
|
|
|
<Menu.Button className="grid relative place-items-center hover:bg-gray-200 p-1 focus:outline-none">
|
2022-12-06 14:38:28 +00:00
|
|
|
<EllipsisHorizontalIcon className="h-4 w-4" />
|
|
|
|
</Menu.Button>
|
2022-12-02 14:12:58 +00:00
|
|
|
|
2022-12-06 14:38:28 +00:00
|
|
|
<Transition
|
|
|
|
as={React.Fragment}
|
|
|
|
enter="transition ease-out duration-100"
|
|
|
|
enterFrom="transform opacity-0 scale-95"
|
|
|
|
enterTo="transform opacity-100 scale-100"
|
|
|
|
leave="transition ease-in duration-75"
|
|
|
|
leaveFrom="transform opacity-100 scale-100"
|
|
|
|
leaveTo="transform opacity-0 scale-95"
|
|
|
|
>
|
|
|
|
<Menu.Items className="origin-top-right absolute right-0 mt-2 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none z-50">
|
|
|
|
<div className="p-1">
|
|
|
|
<Menu.Item as="div">
|
2022-12-20 07:46:40 +00:00
|
|
|
<button
|
|
|
|
className="flex items-center gap-2 p-2 text-left text-gray-900 hover:bg-theme hover:text-white rounded-md text-xs whitespace-nowrap"
|
|
|
|
onClick={() => handleSubIssueRemove(subIssue.id)}
|
|
|
|
>
|
|
|
|
Remove as sub-issue
|
|
|
|
</button>
|
2022-12-06 14:38:28 +00:00
|
|
|
</Menu.Item>
|
|
|
|
</div>
|
|
|
|
</Menu.Items>
|
|
|
|
</Transition>
|
|
|
|
</Menu>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-12-02 14:12:58 +00:00
|
|
|
))}
|
|
|
|
</Disclosure.Panel>
|
|
|
|
</Transition>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</Disclosure>
|
|
|
|
) : (
|
|
|
|
<Menu as="div" className="relative inline-block">
|
|
|
|
<Menu.Button className="flex items-center gap-1 px-2 py-1 rounded hover:bg-gray-100 text-xs font-medium">
|
|
|
|
<PlusIcon className="h-3 w-3" />
|
|
|
|
Add sub-issue
|
|
|
|
</Menu.Button>
|
|
|
|
|
|
|
|
<Transition
|
|
|
|
as={React.Fragment}
|
|
|
|
enter="transition ease-out duration-100"
|
|
|
|
enterFrom="transform opacity-0 scale-95"
|
|
|
|
enterTo="transform opacity-100 scale-100"
|
|
|
|
leave="transition ease-in duration-75"
|
|
|
|
leaveFrom="transform opacity-100 scale-100"
|
|
|
|
leaveTo="transform opacity-0 scale-95"
|
|
|
|
>
|
2022-12-20 14:50:45 +00:00
|
|
|
<Menu.Items className="absolute origin-top-right left-0 mt-1 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none z-10">
|
|
|
|
<div className="py-1">
|
2022-12-02 14:12:58 +00:00
|
|
|
<Menu.Item as="div">
|
2022-12-20 07:46:40 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
2022-12-20 14:50:45 +00:00
|
|
|
className="text-left p-2 text-gray-900 hover:bg-indigo-50 text-xs whitespace-nowrap w-full"
|
2022-12-20 07:46:40 +00:00
|
|
|
onClick={() => {
|
|
|
|
setIsOpen(true);
|
|
|
|
setPreloadedData({
|
|
|
|
parent: issueDetail.id,
|
|
|
|
actionType: "createIssue",
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Create new
|
|
|
|
</button>
|
2022-12-02 14:12:58 +00:00
|
|
|
</Menu.Item>
|
|
|
|
<Menu.Item as="div">
|
2022-12-20 07:46:40 +00:00
|
|
|
<button
|
|
|
|
type="button"
|
2022-12-20 14:50:45 +00:00
|
|
|
className="p-2 text-left text-gray-900 hover:bg-indigo-50 text-xs whitespace-nowrap"
|
2022-12-20 07:46:40 +00:00
|
|
|
onClick={() => {
|
|
|
|
setIsAddAsSubIssueOpen(true);
|
|
|
|
setPreloadedData({
|
|
|
|
parent: issueDetail.id,
|
|
|
|
actionType: "createIssue",
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Add an existing issue
|
|
|
|
</button>
|
2022-12-02 14:12:58 +00:00
|
|
|
</Menu.Item>
|
|
|
|
</div>
|
|
|
|
</Menu.Items>
|
|
|
|
</Transition>
|
|
|
|
</Menu>
|
|
|
|
)}
|
|
|
|
</div>
|
2022-12-01 14:29:21 +00:00
|
|
|
</div>
|
2022-12-07 23:27:10 +00:00
|
|
|
<div className="bg-secondary rounded-lg space-y-5">
|
2022-12-01 14:29:21 +00:00
|
|
|
<Tab.Group>
|
|
|
|
<Tab.List className="flex gap-x-3">
|
|
|
|
{["Comments", "Activity"].map((item) => (
|
|
|
|
<Tab
|
|
|
|
key={item}
|
|
|
|
className={({ selected }) =>
|
|
|
|
`px-3 py-1 text-sm rounded-md border-2 border-gray-700 ${
|
|
|
|
selected ? "bg-gray-700 text-white" : ""
|
|
|
|
}`
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{item}
|
|
|
|
</Tab>
|
|
|
|
))}
|
|
|
|
</Tab.List>
|
|
|
|
<Tab.Panels>
|
|
|
|
<Tab.Panel>
|
2022-12-21 13:41:04 +00:00
|
|
|
<IssueCommentSection />
|
2022-12-01 14:29:21 +00:00
|
|
|
</Tab.Panel>
|
|
|
|
<Tab.Panel>
|
2022-12-21 13:41:04 +00:00
|
|
|
<IssueActivitySection />
|
2022-12-01 14:29:21 +00:00
|
|
|
</Tab.Panel>
|
|
|
|
</Tab.Panels>
|
|
|
|
</Tab.Group>
|
2022-11-24 13:48:18 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-12-17 20:01:13 +00:00
|
|
|
<div className="h-full basis-1/3 space-y-5 p-5 border-l">
|
|
|
|
{/* TODO add flex-grow, if needed */}
|
2022-12-01 14:29:21 +00:00
|
|
|
<IssueDetailSidebar
|
|
|
|
control={control}
|
|
|
|
issueDetail={issueDetail}
|
|
|
|
submitChanges={submitChanges}
|
2022-12-07 23:27:10 +00:00
|
|
|
watch={watch}
|
2022-12-01 14:29:21 +00:00
|
|
|
/>
|
2022-11-24 13:48:18 +00:00
|
|
|
</div>
|
2022-12-01 14:29:21 +00:00
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div className="h-full w-full grid place-items-center px-4 sm:px-0">
|
|
|
|
<Spinner />
|
|
|
|
</div>
|
|
|
|
)}
|
2022-12-07 23:27:10 +00:00
|
|
|
</AppLayout>
|
2022-11-19 14:21:26 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-12-08 14:59:12 +00:00
|
|
|
export default withAuth(IssueDetail);
|