2023-09-01 11:12:30 +00:00
|
|
|
import React, { useEffect, useState } from "react";
|
|
|
|
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
|
|
|
|
// mobx
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
// headless ui
|
|
|
|
import { Dialog, Transition } from "@headlessui/react";
|
|
|
|
// components
|
|
|
|
import { FullScreenPeekView, SidePeekView } from "components/issues/peek-overview";
|
|
|
|
// lib
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
|
|
|
|
|
|
|
type Props = {};
|
|
|
|
|
2023-12-01 07:55:48 +00:00
|
|
|
export const IssuePeekOverview: React.FC<Props> = observer(() => {
|
|
|
|
// states
|
2023-09-01 11:12:30 +00:00
|
|
|
const [isSidePeekOpen, setIsSidePeekOpen] = useState(false);
|
|
|
|
const [isModalPeekOpen, setIsModalPeekOpen] = useState(false);
|
|
|
|
// router
|
|
|
|
const router = useRouter();
|
2023-12-06 10:57:33 +00:00
|
|
|
const { workspace_slug, project_slug, peekId, board, priorities, states, labels } = router.query as {
|
|
|
|
workspace_slug: string;
|
|
|
|
project_slug: string;
|
|
|
|
peekId: string;
|
|
|
|
board: string;
|
|
|
|
priorities: string;
|
|
|
|
states: string;
|
|
|
|
labels: string;
|
|
|
|
};
|
2023-09-01 11:12:30 +00:00
|
|
|
// store
|
|
|
|
const { issueDetails: issueDetailStore, issue: issueStore } = useMobxStore();
|
|
|
|
const issueDetails = issueDetailStore.peekId && peekId ? issueDetailStore.details[peekId.toString()] : undefined;
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (workspace_slug && project_slug && peekId && issueStore.issues && issueStore.issues.length > 0) {
|
|
|
|
if (!issueDetails) {
|
|
|
|
issueDetailStore.fetchIssueDetails(workspace_slug.toString(), project_slug.toString(), peekId.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [workspace_slug, project_slug, issueDetailStore, issueDetails, peekId, issueStore.issues]);
|
|
|
|
|
|
|
|
const handleClose = () => {
|
|
|
|
issueDetailStore.setPeekId(null);
|
2023-12-06 10:57:33 +00:00
|
|
|
|
|
|
|
const params: any = { board: board };
|
|
|
|
if (states && states.length > 0) params.states = states;
|
|
|
|
if (priorities && priorities.length > 0) params.priorities = priorities;
|
|
|
|
if (labels && labels.length > 0) params.labels = labels;
|
|
|
|
|
|
|
|
router.replace({ pathname: `/${workspace_slug?.toString()}/${project_slug}`, query: { ...params } }, undefined, {
|
|
|
|
shallow: true,
|
|
|
|
});
|
2023-09-01 11:12:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (peekId) {
|
|
|
|
if (issueDetailStore.peekMode === "side") {
|
|
|
|
setIsSidePeekOpen(true);
|
|
|
|
setIsModalPeekOpen(false);
|
|
|
|
} else {
|
|
|
|
setIsModalPeekOpen(true);
|
|
|
|
setIsSidePeekOpen(false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
setIsSidePeekOpen(false);
|
|
|
|
setIsModalPeekOpen(false);
|
|
|
|
}
|
|
|
|
}, [peekId, issueDetailStore.peekMode]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Transition.Root appear show={isSidePeekOpen} as={React.Fragment}>
|
2023-09-04 09:17:28 +00:00
|
|
|
<Dialog as="div" onClose={handleClose}>
|
|
|
|
<Transition.Child
|
|
|
|
as={React.Fragment}
|
|
|
|
enter="transition-transform duration-300"
|
|
|
|
enterFrom="translate-x-full"
|
|
|
|
enterTo="translate-x-0"
|
|
|
|
leave="transition-transform duration-200"
|
|
|
|
leaveFrom="translate-x-0"
|
|
|
|
leaveTo="translate-x-full"
|
|
|
|
>
|
2024-01-30 06:46:21 +00:00
|
|
|
<Dialog.Panel className="fixed right-0 top-0 z-20 h-full w-1/2 bg-neutral-component-surface-light shadow-custom-shadow-sm">
|
2023-09-04 09:17:28 +00:00
|
|
|
<SidePeekView handleClose={handleClose} issueDetails={issueDetails} />
|
|
|
|
</Dialog.Panel>
|
|
|
|
</Transition.Child>
|
2023-09-01 11:12:30 +00:00
|
|
|
</Dialog>
|
|
|
|
</Transition.Root>
|
|
|
|
<Transition.Root appear show={isModalPeekOpen} as={React.Fragment}>
|
2023-09-04 09:17:28 +00:00
|
|
|
<Dialog as="div" onClose={handleClose}>
|
2023-09-01 11:12:30 +00:00
|
|
|
<Transition.Child
|
|
|
|
as={React.Fragment}
|
|
|
|
enter="ease-out duration-300"
|
|
|
|
enterFrom="opacity-0"
|
|
|
|
enterTo="opacity-100"
|
|
|
|
leave="ease-in duration-200"
|
|
|
|
leaveFrom="opacity-100"
|
|
|
|
leaveTo="opacity-0"
|
|
|
|
>
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="fixed inset-0 z-20 bg-custom-backdrop bg-opacity-50 transition-opacity" />
|
2023-09-01 11:12:30 +00:00
|
|
|
</Transition.Child>
|
2023-09-04 09:17:28 +00:00
|
|
|
<Transition.Child
|
|
|
|
as={React.Fragment}
|
|
|
|
enter="ease-out duration-300"
|
|
|
|
enterFrom="opacity-0"
|
|
|
|
enterTo="opacity-100"
|
|
|
|
leave="ease-in duration-200"
|
|
|
|
leaveFrom="opacity-100"
|
|
|
|
leaveTo="opacity-0"
|
|
|
|
>
|
|
|
|
<Dialog.Panel>
|
|
|
|
<div
|
2024-01-30 06:46:21 +00:00
|
|
|
className={`fixed left-1/2 top-1/2 z-20 -translate-x-1/2 -translate-y-1/2 rounded-lg bg-neutral-component-surface-light shadow-custom-shadow-xl transition-all duration-300 ${
|
2023-09-04 09:17:28 +00:00
|
|
|
issueDetailStore.peekMode === "modal" ? "h-[70%] w-3/5" : "h-[95%] w-[95%]"
|
|
|
|
}`}
|
|
|
|
>
|
|
|
|
{issueDetailStore.peekMode === "modal" && (
|
|
|
|
<SidePeekView handleClose={handleClose} issueDetails={issueDetails} />
|
|
|
|
)}
|
|
|
|
{issueDetailStore.peekMode === "full" && (
|
|
|
|
<FullScreenPeekView handleClose={handleClose} issueDetails={issueDetails} />
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</Dialog.Panel>
|
|
|
|
</Transition.Child>
|
2023-09-01 11:12:30 +00:00
|
|
|
</Dialog>
|
|
|
|
</Transition.Root>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
});
|