refactor: issues folder structure

This commit is contained in:
Aaryan Khandelwal 2023-02-02 15:00:35 +05:30
parent 7e92efee23
commit 8b1bf53831
44 changed files with 249 additions and 324 deletions

View File

@ -5,16 +5,16 @@ import { useRouter } from "next/router";
import useSWR, { mutate } from "swr"; import useSWR, { mutate } from "swr";
// headless ui
import { Listbox, Transition } from "@headlessui/react";
// services // services
import issuesService from "services/issues.service"; import issuesService from "services/issues.service";
import workspaceService from "services/workspace.service"; import workspaceService from "services/workspace.service";
import stateService from "services/state.service"; import stateService from "services/state.service";
// headless ui // components
import { Listbox, Transition } from "@headlessui/react"; import { DeleteIssueModal } from "components/issues";
// ui // ui
import { CustomMenu, CustomSelect, AssigneesList, Avatar, CustomDatePicker } from "components/ui"; import { CustomMenu, CustomSelect, AssigneesList, Avatar, CustomDatePicker } from "components/ui";
// components
import ConfirmIssueDeletion from "components/project/issues/confirm-issue-deletion";
// helpers // helpers
import { renderShortNumericDateFormat, findHowManyDaysLeft } from "helpers/date-time.helper"; import { renderShortNumericDateFormat, findHowManyDaysLeft } from "helpers/date-time.helper";
import { addSpaceIfCamelCase } from "helpers/string.helper"; import { addSpaceIfCamelCase } from "helpers/string.helper";
@ -152,7 +152,7 @@ const SingleListIssue: React.FC<Props> = ({
return ( return (
<> <>
<ConfirmIssueDeletion <DeleteIssueModal
handleClose={() => setDeleteIssue(undefined)} handleClose={() => setDeleteIssue(undefined)}
isOpen={!!deleteIssue} isOpen={!!deleteIssue}
data={deleteIssue} data={deleteIssue}

View File

@ -14,7 +14,7 @@ import {
// services // services
import issuesServices from "services/issues.service"; import issuesServices from "services/issues.service";
// components // components
import CommentCard from "components/project/issues/issue-detail/comment/issue-comment-card"; import { CommentCard } from "components/issues/comment";
// ui // ui
import { Loader } from "components/ui"; import { Loader } from "components/ui";
// icons // icons
@ -76,7 +76,7 @@ const activityDetails: {
}, },
}; };
const IssueActivitySection: React.FC<{ export const IssueActivitySection: React.FC<{
issueActivities: IIssueActivity[]; issueActivities: IIssueActivity[];
mutate: KeyedMutator<IIssueActivity[]>; mutate: KeyedMutator<IIssueActivity[]>;
}> = ({ issueActivities, mutate }) => { }> = ({ issueActivities, mutate }) => {
@ -216,7 +216,7 @@ const IssueActivitySection: React.FC<{
</div> </div>
</div> </div>
); );
} else if ("comment_json" in activity) { } else if ("comment_json" in activity)
return ( return (
<CommentCard <CommentCard
key={activity.id} key={activity.id}
@ -225,7 +225,6 @@ const IssueActivitySection: React.FC<{
handleCommentDeletion={onCommentDelete} handleCommentDeletion={onCommentDelete}
/> />
); );
}
})} })}
</div> </div>
) : ( ) : (
@ -247,5 +246,3 @@ const IssueActivitySection: React.FC<{
</> </>
); );
}; };
export default IssueActivitySection;

View File

@ -14,10 +14,9 @@ import stateServices from "services/state.service";
import issuesServices from "services/issues.service"; import issuesServices from "services/issues.service";
import projectService from "services/project.service"; import projectService from "services/project.service";
// components // components
import SingleBoard from "components/project/issues/BoardView/single-board"; import SingleBoard from "components/issues/board-view/single-board";
import StrictModeDroppable from "components/dnd/StrictModeDroppable"; import StrictModeDroppable from "components/dnd/StrictModeDroppable";
import { CreateUpdateIssueModal } from "components/issues/modal"; import { CreateUpdateIssueModal, DeleteIssueModal } from "components/issues";
import ConfirmIssueDeletion from "components/project/issues/confirm-issue-deletion";
// ui // ui
import { Spinner } from "components/ui"; import { Spinner } from "components/ui";
// types // types
@ -185,7 +184,7 @@ const BoardView: React.FC<Props> = ({ issues, handleDeleteIssue, userAuth }) =>
return ( return (
<> <>
<ConfirmIssueDeletion <DeleteIssueModal
isOpen={isIssueDeletionOpen} isOpen={isIssueDeletionOpen}
handleClose={() => setIsIssueDeletionOpen(false)} handleClose={() => setIsIssueDeletionOpen(false)}
data={issueDeletionData} data={issueDeletionData}

View File

@ -28,7 +28,8 @@ const defaultValues: Partial<IIssueComment> = {
comment_html: "", comment_html: "",
comment_json: "", comment_json: "",
}; };
const AddIssueComment: React.FC<{
export const AddComment: React.FC<{
mutate: KeyedMutator<IIssueActivity[]>; mutate: KeyedMutator<IIssueActivity[]>;
}> = ({ mutate }) => { }> = ({ mutate }) => {
const { const {
@ -111,5 +112,3 @@ const AddIssueComment: React.FC<{
</div> </div>
); );
}; };
export default AddIssueComment;

View File

@ -24,7 +24,7 @@ type Props = {
handleCommentDeletion: (comment: string) => void; handleCommentDeletion: (comment: string) => void;
}; };
const CommentCard: React.FC<Props> = ({ comment, onSubmit, handleCommentDeletion }) => { export const CommentCard: React.FC<Props> = ({ comment, onSubmit, handleCommentDeletion }) => {
const { user } = useUser(); const { user } = useUser();
const [isEditing, setIsEditing] = useState(false); const [isEditing, setIsEditing] = useState(false);
@ -130,5 +130,3 @@ const CommentCard: React.FC<Props> = ({ comment, onSubmit, handleCommentDeletion
</div> </div>
); );
}; };
export default CommentCard;

View File

@ -0,0 +1,2 @@
export * from "./add-comment";
export * from "./comment-card";

View File

@ -25,7 +25,7 @@ type Props = {
data?: IIssue; data?: IIssue;
}; };
const ConfirmIssueDeletion: React.FC<Props> = ({ isOpen, handleClose, data }) => { export const DeleteIssueModal: React.FC<Props> = ({ isOpen, handleClose, data }) => {
const cancelButtonRef = useRef(null); const cancelButtonRef = useRef(null);
const [isDeleteLoading, setIsDeleteLoading] = useState(false); const [isDeleteLoading, setIsDeleteLoading] = useState(false);
@ -43,8 +43,6 @@ const ConfirmIssueDeletion: React.FC<Props> = ({ isOpen, handleClose, data }) =>
handleClose(); handleClose();
}; };
console.log(data);
const handleDeletion = async () => { const handleDeletion = async () => {
setIsDeleteLoading(true); setIsDeleteLoading(true);
if (!data || !workspaceSlug) return; if (!data || !workspaceSlug) return;
@ -173,5 +171,3 @@ const ConfirmIssueDeletion: React.FC<Props> = ({ isOpen, handleClose, data }) =>
</Transition.Root> </Transition.Root>
); );
}; };
export default ConfirmIssueDeletion;

View File

@ -16,7 +16,7 @@ import {
IssueStateSelect, IssueStateSelect,
} from "components/issues/select"; } from "components/issues/select";
import { CycleSelect as IssueCycleSelect } from "components/cycles/select"; import { CycleSelect as IssueCycleSelect } from "components/cycles/select";
import CreateUpdateStateModal from "components/project/issues/BoardView/state/create-update-state-modal"; import { CreateUpdateStateModal } from "components/states";
import CreateUpdateCycleModal from "components/project/cycles/create-update-cycle-modal"; import CreateUpdateCycleModal from "components/project/cycles/create-update-cycle-modal";
// ui // ui
import { Button, CustomDatePicker, CustomMenu, Input, Loader } from "components/ui"; import { Button, CustomDatePicker, CustomMenu, Input, Loader } from "components/ui";

View File

@ -1,5 +1,13 @@
export * from "./list-item"; export * from "./board-view";
export * from "./comment";
export * from "./activity";
export * from "./delete-issue-modal";
export * from "./description-form"; export * from "./description-form";
export * from "./sub-issue-list";
export * from "./form"; export * from "./form";
export * from "./list-view";
export * from "./modal"; export * from "./modal";
export * from "./my-issues-list-item";
export * from "./parent-issues-list-modal";
export * from "./sidebar";
export * from "./sub-issues-list";
export * from "./sub-issues-list-modal";

View File

@ -31,7 +31,7 @@ type Props = {
userAuth: UserAuth; userAuth: UserAuth;
}; };
const ListView: React.FC<Props> = ({ issues, handleEditIssue, userAuth }) => { export const IssuesListView: React.FC<Props> = ({ issues, handleEditIssue, userAuth }) => {
const [isCreateIssuesModalOpen, setIsCreateIssuesModalOpen] = useState(false); const [isCreateIssuesModalOpen, setIsCreateIssuesModalOpen] = useState(false);
const [preloadedData, setPreloadedData] = useState< const [preloadedData, setPreloadedData] = useState<
(Partial<IIssue> & { actionType: "createIssue" | "edit" | "delete" }) | undefined (Partial<IIssue> & { actionType: "createIssue" | "edit" | "delete" }) | undefined
@ -180,5 +180,3 @@ const ListView: React.FC<Props> = ({ issues, handleEditIssue, userAuth }) => {
</> </>
); );
}; };
export default ListView;

View File

@ -16,7 +16,7 @@ import issuesService from "services/issues.service";
import useUser from "hooks/use-user"; import useUser from "hooks/use-user";
import useToast from "hooks/use-toast"; import useToast from "hooks/use-toast";
// components // components
import CreateUpdateStateModal from "components/project/issues/BoardView/state/create-update-state-modal"; import { CreateUpdateStateModal } from "components/states";
import CreateUpdateCycleModal from "components/project/cycles/create-update-cycle-modal"; import CreateUpdateCycleModal from "components/project/cycles/create-update-cycle-modal";
import { IssueForm } from "components/issues"; import { IssueForm } from "components/issues";
// common // common

View File

@ -24,10 +24,7 @@ type Props = {
removeIssue?: () => void; removeIssue?: () => void;
}; };
export const IssueListItem: React.FC<Props> = (props) => { export const MyIssuesListItem: React.FC<Props> = ({ issue, properties }) => {
// const { type, issue, properties, editIssue, handleDeleteIssue, removeIssue } = props;
const { issue, properties } = props;
// router
const router = useRouter(); const router = useRouter();
const { workspaceSlug } = router.query; const { workspaceSlug } = router.query;

View File

@ -21,7 +21,7 @@ type Props = {
customDisplay?: JSX.Element; customDisplay?: JSX.Element;
}; };
const IssuesListModal: React.FC<Props> = ({ export const ParentIssuesListModal: React.FC<Props> = ({
isOpen, isOpen,
handleClose: onClose, handleClose: onClose,
value, value,
@ -227,5 +227,3 @@ const IssuesListModal: React.FC<Props> = ({
</> </>
); );
}; };
export default IssuesListModal;

View File

@ -1,6 +1,6 @@
export * from "./assignee"; export * from "./assignee";
export * from "./label"; export * from "./label";
export * from "./parent-issue"; export * from "./parent";
export * from "./priority"; export * from "./priority";
export * from "./project"; export * from "./project";
export * from "./state"; export * from "./state";

View File

@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import { Controller, Control } from "react-hook-form"; import { Controller, Control } from "react-hook-form";
// components // components
import IssuesListModal from "components/project/issues/issues-list-modal"; import { ParentIssuesListModal } from "components/issues";
// types // types
import type { IIssue } from "types"; import type { IIssue } from "types";
@ -17,7 +17,7 @@ export const IssueParentSelect: React.FC<Props> = ({ control, isOpen, setIsOpen,
control={control} control={control}
name="parent" name="parent"
render={({ field: { onChange } }) => ( render={({ field: { onChange } }) => (
<IssuesListModal <ParentIssuesListModal
isOpen={isOpen} isOpen={isOpen}
handleClose={() => setIsOpen(false)} handleClose={() => setIsOpen(false)}
onChange={onChange} onChange={onChange}

View File

@ -27,7 +27,7 @@ type Props = {
userAuth: UserAuth; userAuth: UserAuth;
}; };
const SelectAssignee: React.FC<Props> = ({ control, submitChanges, userAuth }) => { export const SidebarAssigneeSelect: React.FC<Props> = ({ control, submitChanges, userAuth }) => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug } = router.query; const { workspaceSlug } = router.query;
@ -143,5 +143,3 @@ const SelectAssignee: React.FC<Props> = ({ control, submitChanges, userAuth }) =
</div> </div>
); );
}; };
export default SelectAssignee;

View File

@ -16,7 +16,7 @@ import issuesService from "services/issues.service";
// ui // ui
import { Button } from "components/ui"; import { Button } from "components/ui";
// icons // icons
import { FolderIcon, MagnifyingGlassIcon, XMarkIcon } from "@heroicons/react/24/outline"; import { MagnifyingGlassIcon, XMarkIcon } from "@heroicons/react/24/outline";
import { BlockedIcon, LayerDiagonalIcon } from "components/icons"; import { BlockedIcon, LayerDiagonalIcon } from "components/icons";
// types // types
import { IIssue, UserAuth } from "types"; import { IIssue, UserAuth } from "types";
@ -34,7 +34,12 @@ type Props = {
userAuth: UserAuth; userAuth: UserAuth;
}; };
const SelectBlocked: React.FC<Props> = ({ submitChanges, issuesList, watch, userAuth }) => { export const SidebarBlockedSelect: React.FC<Props> = ({
submitChanges,
issuesList,
watch,
userAuth,
}) => {
const [query, setQuery] = useState(""); const [query, setQuery] = useState("");
const [isBlockedModalOpen, setIsBlockedModalOpen] = useState(false); const [isBlockedModalOpen, setIsBlockedModalOpen] = useState(false);
@ -301,5 +306,3 @@ const SelectBlocked: React.FC<Props> = ({ submitChanges, issuesList, watch, user
</div> </div>
); );
}; };
export default SelectBlocked;

View File

@ -34,7 +34,12 @@ type Props = {
userAuth: UserAuth; userAuth: UserAuth;
}; };
const SelectBlocker: React.FC<Props> = ({ submitChanges, issuesList, watch, userAuth }) => { export const SidebarBlockerSelect: React.FC<Props> = ({
submitChanges,
issuesList,
watch,
userAuth,
}) => {
const [query, setQuery] = useState(""); const [query, setQuery] = useState("");
const [isBlockerModalOpen, setIsBlockerModalOpen] = useState(false); const [isBlockerModalOpen, setIsBlockerModalOpen] = useState(false);
@ -299,5 +304,3 @@ const SelectBlocker: React.FC<Props> = ({ submitChanges, issuesList, watch, user
</div> </div>
); );
}; };
export default SelectBlocker;

View File

@ -22,7 +22,11 @@ type Props = {
userAuth: UserAuth; userAuth: UserAuth;
}; };
const SelectCycle: React.FC<Props> = ({ issueDetail, handleCycleChange, userAuth }) => { export const SidebarCycleSelect: React.FC<Props> = ({
issueDetail,
handleCycleChange,
userAuth,
}) => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId, issueId } = router.query; const { workspaceSlug, projectId, issueId } = router.query;
@ -98,5 +102,3 @@ const SelectCycle: React.FC<Props> = ({ issueDetail, handleCycleChange, userAuth
</div> </div>
); );
}; };
export default SelectCycle;

View File

@ -0,0 +1,8 @@
export * from "./assignee";
export * from "./blocked";
export * from "./blocker";
export * from "./cycle";
export * from "./module";
export * from "./parent";
export * from "./priority";
export * from "./state";

View File

@ -21,7 +21,7 @@ type Props = {
handleModuleChange: (module: IModule) => void; handleModuleChange: (module: IModule) => void;
}; };
const SelectModule: React.FC<Props> = ({ control, handleModuleChange }) => { export const SidebarModuleSelect: React.FC<Props> = ({ control, handleModuleChange }) => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId } = router.query; const { workspaceSlug, projectId } = router.query;
@ -76,5 +76,3 @@ const SelectModule: React.FC<Props> = ({ control, handleModuleChange }) => {
</div> </div>
); );
}; };
export default SelectModule;

View File

@ -10,7 +10,7 @@ import { UserIcon } from "@heroicons/react/24/outline";
// services // services
import issuesServices from "services/issues.service"; import issuesServices from "services/issues.service";
// components // components
import IssuesListModal from "components/project/issues/issues-list-modal"; import { ParentIssuesListModal } from "components/issues";
// icons // icons
// types // types
import { IIssue, UserAuth } from "types"; import { IIssue, UserAuth } from "types";
@ -26,7 +26,7 @@ type Props = {
userAuth: UserAuth; userAuth: UserAuth;
}; };
const SelectParent: React.FC<Props> = ({ export const SidebarParentSelect: React.FC<Props> = ({
control, control,
submitChanges, submitChanges,
issuesList, issuesList,
@ -61,7 +61,7 @@ const SelectParent: React.FC<Props> = ({
control={control} control={control}
name="parent" name="parent"
render={({ field: { value, onChange } }) => ( render={({ field: { value, onChange } }) => (
<IssuesListModal <ParentIssuesListModal
isOpen={isParentModalOpen} isOpen={isParentModalOpen}
handleClose={() => setIsParentModalOpen(false)} handleClose={() => setIsParentModalOpen(false)}
onChange={(val) => { onChange={(val) => {
@ -93,5 +93,3 @@ const SelectParent: React.FC<Props> = ({
</div> </div>
); );
}; };
export default SelectParent;

View File

@ -19,7 +19,7 @@ type Props = {
userAuth: UserAuth; userAuth: UserAuth;
}; };
const SelectPriority: React.FC<Props> = ({ control, submitChanges, userAuth }) => { export const SidebarPrioritySelect: React.FC<Props> = ({ control, submitChanges, userAuth }) => {
const isNotAllowed = userAuth.isGuest || userAuth.isViewer; const isNotAllowed = userAuth.isGuest || userAuth.isViewer;
return ( return (
@ -65,5 +65,3 @@ const SelectPriority: React.FC<Props> = ({ control, submitChanges, userAuth }) =
</div> </div>
); );
}; };
export default SelectPriority;

View File

@ -22,7 +22,7 @@ type Props = {
userAuth: UserAuth; userAuth: UserAuth;
}; };
const SelectState: React.FC<Props> = ({ control, submitChanges, userAuth }) => { export const SidebarStateSelect: React.FC<Props> = ({ control, submitChanges, userAuth }) => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId } = router.query; const { workspaceSlug, projectId } = router.query;
@ -100,5 +100,3 @@ const SelectState: React.FC<Props> = ({ control, submitChanges, userAuth }) => {
</div> </div>
); );
}; };
export default SelectState;

View File

@ -15,17 +15,18 @@ import useToast from "hooks/use-toast";
// services // services
import issuesServices from "services/issues.service"; import issuesServices from "services/issues.service";
// components // components
import ConfirmIssueDeletion from "components/project/issues/confirm-issue-deletion"; import {
import SelectState from "components/project/issues/issue-detail/issue-detail-sidebar/select-state"; SidebarAssigneeSelect,
import SelectPriority from "components/project/issues/issue-detail/issue-detail-sidebar/select-priority"; SidebarBlockedSelect,
import SelectParent from "components/project/issues/issue-detail/issue-detail-sidebar/select-parent"; SidebarBlockerSelect,
import SelectCycle from "components/project/issues/issue-detail/issue-detail-sidebar/select-cycle"; SidebarCycleSelect,
import SelectAssignee from "components/project/issues/issue-detail/issue-detail-sidebar/select-assignee"; SidebarParentSelect,
import SelectBlocker from "components/project/issues/issue-detail/issue-detail-sidebar/select-blocker"; SidebarPrioritySelect,
import SelectBlocked from "components/project/issues/issue-detail/issue-detail-sidebar/select-blocked"; SidebarStateSelect,
} from "components/issues/sidebar-select";
import { DeleteIssueModal } from "components/issues";
// ui // ui
import { Input, Button, Spinner, CustomDatePicker } from "components/ui"; import { Input, Button, Spinner, CustomDatePicker } from "components/ui";
import DatePicker from "react-datepicker";
// icons // icons
import { import {
TagIcon, TagIcon,
@ -43,8 +44,6 @@ import type { ICycle, IIssue, IIssueLabels, UserAuth } from "types";
// fetch-keys // fetch-keys
import { PROJECT_ISSUE_LABELS, PROJECT_ISSUES_LIST, ISSUE_DETAILS } from "constants/fetch-keys"; import { PROJECT_ISSUE_LABELS, PROJECT_ISSUES_LIST, ISSUE_DETAILS } from "constants/fetch-keys";
import "react-datepicker/dist/react-datepicker.css";
type Props = { type Props = {
control: Control<IIssue, any>; control: Control<IIssue, any>;
submitChanges: (formData: Partial<IIssue>) => void; submitChanges: (formData: Partial<IIssue>) => void;
@ -58,7 +57,7 @@ const defaultValues: Partial<IIssueLabels> = {
colour: "#ff0000", colour: "#ff0000",
}; };
const IssueDetailSidebar: React.FC<Props> = ({ export const IssueDetailsSidebar: React.FC<Props> = ({
control, control,
submitChanges, submitChanges,
issueDetail, issueDetail,
@ -128,7 +127,7 @@ const IssueDetailSidebar: React.FC<Props> = ({
return ( return (
<> <>
<ConfirmIssueDeletion <DeleteIssueModal
handleClose={() => setDeleteIssueModal(false)} handleClose={() => setDeleteIssueModal(false)}
isOpen={deleteIssueModal} isOpen={deleteIssueModal}
data={issueDetail} data={issueDetail}
@ -175,12 +174,24 @@ const IssueDetailSidebar: React.FC<Props> = ({
</div> </div>
<div className="divide-y-2 divide-gray-100"> <div className="divide-y-2 divide-gray-100">
<div className="py-1"> <div className="py-1">
<SelectState control={control} submitChanges={submitChanges} userAuth={userAuth} /> <SidebarStateSelect
<SelectAssignee control={control} submitChanges={submitChanges} userAuth={userAuth} /> control={control}
<SelectPriority control={control} submitChanges={submitChanges} userAuth={userAuth} /> submitChanges={submitChanges}
userAuth={userAuth}
/>
<SidebarAssigneeSelect
control={control}
submitChanges={submitChanges}
userAuth={userAuth}
/>
<SidebarPrioritySelect
control={control}
submitChanges={submitChanges}
userAuth={userAuth}
/>
</div> </div>
<div className="py-1"> <div className="py-1">
<SelectParent <SidebarParentSelect
control={control} control={control}
submitChanges={submitChanges} submitChanges={submitChanges}
issuesList={ issuesList={
@ -210,13 +221,13 @@ const IssueDetailSidebar: React.FC<Props> = ({
watch={watchIssue} watch={watchIssue}
userAuth={userAuth} userAuth={userAuth}
/> />
<SelectBlocker <SidebarBlockerSelect
submitChanges={submitChanges} submitChanges={submitChanges}
issuesList={issues?.results.filter((i) => i.id !== issueDetail?.id) ?? []} issuesList={issues?.results.filter((i) => i.id !== issueDetail?.id) ?? []}
watch={watchIssue} watch={watchIssue}
userAuth={userAuth} userAuth={userAuth}
/> />
<SelectBlocked <SidebarBlockedSelect
submitChanges={submitChanges} submitChanges={submitChanges}
issuesList={issues?.results.filter((i) => i.id !== issueDetail?.id) ?? []} issuesList={issues?.results.filter((i) => i.id !== issueDetail?.id) ?? []}
watch={watchIssue} watch={watchIssue}
@ -247,7 +258,7 @@ const IssueDetailSidebar: React.FC<Props> = ({
</div> </div>
</div> </div>
<div className="py-1"> <div className="py-1">
<SelectCycle <SidebarCycleSelect
issueDetail={issueDetail} issueDetail={issueDetail}
handleCycleChange={handleCycleChange} handleCycleChange={handleCycleChange}
userAuth={userAuth} userAuth={userAuth}
@ -446,5 +457,3 @@ const IssueDetailSidebar: React.FC<Props> = ({
</> </>
); );
}; };
export default IssueDetailSidebar;

View File

@ -17,11 +17,11 @@ import { PROJECT_ISSUES_LIST, SUB_ISSUES } from "constants/fetch-keys";
type Props = { type Props = {
isOpen: boolean; isOpen: boolean;
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>; handleClose: () => void;
parent: IIssue | undefined; parent: IIssue | undefined;
}; };
const AddAsSubIssue: React.FC<Props> = ({ isOpen, setIsOpen, parent }) => { export const SubIssuesListModal: React.FC<Props> = ({ isOpen, handleClose, parent }) => {
const [query, setQuery] = useState(""); const [query, setQuery] = useState("");
const router = useRouter(); const router = useRouter();
@ -43,7 +43,7 @@ const AddAsSubIssue: React.FC<Props> = ({ isOpen, setIsOpen, parent }) => {
[]; [];
const handleCommandPaletteClose = () => { const handleCommandPaletteClose = () => {
setIsOpen(false); handleClose();
setQuery(""); setQuery("");
}; };
@ -147,7 +147,7 @@ const AddAsSubIssue: React.FC<Props> = ({ isOpen, setIsOpen, parent }) => {
} }
onClick={() => { onClick={() => {
addAsSubIssue(issue.id); addAsSubIssue(issue.id);
setIsOpen(false); handleClose();
}} }}
> >
<span <span
@ -188,5 +188,3 @@ const AddAsSubIssue: React.FC<Props> = ({ isOpen, setIsOpen, parent }) => {
</Transition.Root> </Transition.Root>
); );
}; };
export default AddAsSubIssue;

View File

@ -4,8 +4,7 @@ import { Disclosure, Transition } from "@headlessui/react";
import { ChevronRightIcon, PlusIcon } from "@heroicons/react/24/outline"; import { ChevronRightIcon, PlusIcon } from "@heroicons/react/24/outline";
// components // components
import { CustomMenu } from "components/ui"; import { CustomMenu } from "components/ui";
import { CreateUpdateIssueModal } from "components/issues"; import { CreateUpdateIssueModal, SubIssuesListModal } from "components/issues";
import AddAsSubIssue from "components/project/issues/issue-detail/add-as-sub-issue";
// types // types
import { IIssue, UserAuth } from "types"; import { IIssue, UserAuth } from "types";
@ -18,7 +17,7 @@ export interface SubIssueListProps {
userAuth: UserAuth; userAuth: UserAuth;
} }
export const SubIssueList: FC<SubIssueListProps> = ({ export const SubIssuesList: FC<SubIssueListProps> = ({
issues = [], issues = [],
handleSubIssueRemove, handleSubIssueRemove,
parentIssue, parentIssue,
@ -28,7 +27,7 @@ export const SubIssueList: FC<SubIssueListProps> = ({
}) => { }) => {
// states // states
const [isIssueModalActive, setIssueModalActive] = useState(false); const [isIssueModalActive, setIssueModalActive] = useState(false);
const [isSubIssueModalActive, setSubIssueModalActive] = useState(false); const [subIssuesListModal, setSubIssuesListModal] = useState(false);
const [preloadedData, setPreloadedData] = useState<Partial<IIssue> | null>(null); const [preloadedData, setPreloadedData] = useState<Partial<IIssue> | null>(null);
const openIssueModal = () => { const openIssueModal = () => {
@ -40,11 +39,11 @@ export const SubIssueList: FC<SubIssueListProps> = ({
}; };
const openSubIssueModal = () => { const openSubIssueModal = () => {
setSubIssueModalActive(true); setSubIssuesListModal(true);
}; };
const closeSubIssueModal = () => { const closeSubIssueModal = () => {
setSubIssueModalActive(false); setSubIssuesListModal(false);
}; };
const isNotAllowed = userAuth.isGuest || userAuth.isViewer; const isNotAllowed = userAuth.isGuest || userAuth.isViewer;
@ -56,9 +55,9 @@ export const SubIssueList: FC<SubIssueListProps> = ({
prePopulateData={{ ...preloadedData }} prePopulateData={{ ...preloadedData }}
handleClose={closeIssueModal} handleClose={closeIssueModal}
/> />
<AddAsSubIssue <SubIssuesListModal
isOpen={isSubIssueModalActive} isOpen={subIssuesListModal}
setIsOpen={setSubIssueModalActive} handleClose={() => setSubIssuesListModal(false)}
parent={parentIssue} parent={parentIssue}
/> />
<Disclosure defaultOpen={true}> <Disclosure defaultOpen={true}>
@ -88,7 +87,7 @@ export const SubIssueList: FC<SubIssueListProps> = ({
<CustomMenu ellipsis> <CustomMenu ellipsis>
<CustomMenu.MenuItem <CustomMenu.MenuItem
onClick={() => { onClick={() => {
setSubIssueModalActive(true); setSubIssuesListModal(true);
}} }}
> >
Add an existing issue Add an existing issue

View File

@ -15,7 +15,7 @@ import cyclesService from "services/cycles.service";
import useToast from "hooks/use-toast"; import useToast from "hooks/use-toast";
// ui // ui
import { Loader, CustomDatePicker } from "components/ui"; import { Loader, CustomDatePicker } from "components/ui";
//progress-bar // progress-bar
import { CircularProgressbar } from "react-circular-progressbar"; import { CircularProgressbar } from "react-circular-progressbar";
import "react-circular-progressbar/dist/styles.css"; import "react-circular-progressbar/dist/styles.css";
// helpers // helpers
@ -24,7 +24,7 @@ import { groupBy } from "helpers/array.helper";
// types // types
import { CycleIssueResponse, ICycle } from "types"; import { CycleIssueResponse, ICycle } from "types";
// fetch-keys // fetch-keys
import { CYCLE_LIST } from "constants/fetch-keys"; import { CYCLE_DETAILS } from "constants/fetch-keys";
type Props = { type Props = {
cycle: ICycle | undefined; cycle: ICycle | undefined;
@ -57,23 +57,19 @@ const CycleDetailSidebar: React.FC<Props> = ({ cycle, isOpen, cycleIssues }) =>
}; };
const submitChanges = (data: Partial<ICycle>) => { const submitChanges = (data: Partial<ICycle>) => {
if (!workspaceSlug || !projectId || !module) return; if (!workspaceSlug || !projectId || !cycleId) return;
mutate<ICycle[]>( mutate<ICycle>(
projectId && CYCLE_LIST(projectId as string), CYCLE_DETAILS(cycleId as string),
(prevData) => (prevData) => ({ ...(prevData as ICycle), ...data }),
(prevData ?? []).map((tempCycle) => {
if (tempCycle.id === cycleId) return { ...tempCycle, ...data };
return tempCycle;
}),
false false
); );
cyclesService cyclesService
.patchCycle(workspaceSlug as string, projectId as string, cycle?.id ?? "", data) .patchCycle(workspaceSlug as string, projectId as string, cycleId as string, data)
.then((res) => { .then((res) => {
console.log(res); console.log(res);
mutate(CYCLE_LIST(projectId as string)); mutate(CYCLE_DETAILS(cycleId as string));
}) })
.catch((e) => { .catch((e) => {
console.log(e); console.log(e);

View File

@ -1,101 +0,0 @@
import React from "react";
import { useRouter } from "next/router";
import useSWR from "swr";
// headless ui
import { Listbox, Transition } from "@headlessui/react";
// services
import stateServices from "services/state.service";
// helpers
import { addSpaceIfCamelCase } from "helpers/string.helper";
// types
import { IIssue, IState } from "types";
// fetch-keys
import { STATE_LIST } from "constants/fetch-keys";
type Props = {
issue: IIssue;
updateIssues: (
workspaceSlug: string,
projectId: string,
issueId: string,
issue: Partial<IIssue>
) => void;
};
const ChangeStateDropdown: React.FC<Props> = ({ issue, updateIssues }) => {
const router = useRouter();
const { workspaceSlug } = router.query;
const { data: states } = useSWR<IState[]>(
workspaceSlug ? STATE_LIST(issue.project) : null,
workspaceSlug ? () => stateServices.getStates(workspaceSlug as string, issue.project) : null
);
return (
<>
<Listbox
as="div"
value={issue.state}
onChange={(data: string) => {
if (!workspaceSlug) return;
updateIssues(workspaceSlug as string, issue.project, issue.id, {
state: data,
state_detail: states?.find((state) => state.id === data),
});
}}
className="flex-shrink-0"
>
{({ open }) => (
<>
<div>
<Listbox.Button
className="inline-flex items-center whitespace-nowrap rounded-full border bg-gray-50 px-2 py-1 text-xs font-medium text-gray-500 hover:bg-gray-100"
style={{
border: `2px solid ${issue.state_detail.color}`,
backgroundColor: `${issue.state_detail.color}20`,
}}
>
<span
className={`hidden w-16 capitalize sm:block ${
issue.state ? "" : "text-gray-900"
}`}
>
{addSpaceIfCamelCase(issue.state_detail.name)}
</span>
</Listbox.Button>
<Transition
show={open}
as={React.Fragment}
leave="transition ease-in duration-100"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<Listbox.Options className="fixed z-10 mt-1 max-h-28 overflow-auto rounded-md bg-white py-1 text-xs shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none">
{states?.map((state) => (
<Listbox.Option
key={state.id}
className={({ active }) =>
`cursor-pointer select-none px-3 py-2 ${
active ? "bg-indigo-50" : "bg-white"
}`
}
value={state.id}
>
{addSpaceIfCamelCase(state.name)}
</Listbox.Option>
))}
</Listbox.Options>
</Transition>
</div>
</>
)}
</Listbox>
</>
);
};
export default ChangeStateDropdown;

View File

@ -8,13 +8,6 @@ import { mutate } from "swr";
// react-hook-form // react-hook-form
import { Controller, useForm } from "react-hook-form"; import { Controller, useForm } from "react-hook-form";
// services // services
import {
CalendarDaysIcon,
ChartPieIcon,
LinkIcon,
PlusIcon,
TrashIcon,
} from "@heroicons/react/24/outline";
import modulesService from "services/modules.service"; import modulesService from "services/modules.service";
// hooks // hooks
import useToast from "hooks/use-toast"; import useToast from "hooks/use-toast";
@ -23,12 +16,19 @@ import SelectLead from "components/project/modules/module-detail-sidebar/select-
import SelectMembers from "components/project/modules/module-detail-sidebar/select-members"; import SelectMembers from "components/project/modules/module-detail-sidebar/select-members";
import SelectStatus from "components/project/modules/module-detail-sidebar/select-status"; import SelectStatus from "components/project/modules/module-detail-sidebar/select-status";
import ModuleLinkModal from "components/project/modules/module-link-modal"; import ModuleLinkModal from "components/project/modules/module-link-modal";
//progress-bar // progress-bar
import { CircularProgressbar } from "react-circular-progressbar"; import { CircularProgressbar } from "react-circular-progressbar";
import "react-circular-progressbar/dist/styles.css"; import "react-circular-progressbar/dist/styles.css";
// ui // ui
import { CustomDatePicker, Loader } from "components/ui"; import { CustomDatePicker, Loader } from "components/ui";
// icons // icons
import {
CalendarDaysIcon,
ChartPieIcon,
LinkIcon,
PlusIcon,
TrashIcon,
} from "@heroicons/react/24/outline";
// helpers // helpers
import { timeAgo } from "helpers/date-time.helper"; import { timeAgo } from "helpers/date-time.helper";
import { copyTextToClipboard } from "helpers/string.helper"; import { copyTextToClipboard } from "helpers/string.helper";
@ -36,9 +36,10 @@ import { groupBy } from "helpers/array.helper";
// types // types
import { IModule, ModuleIssueResponse } from "types"; import { IModule, ModuleIssueResponse } from "types";
// fetch-keys // fetch-keys
import { MODULE_LIST } from "constants/fetch-keys"; import { MODULE_DETAILS } from "constants/fetch-keys";
const defaultValues: Partial<IModule> = { const defaultValues: Partial<IModule> = {
lead: "",
members_list: [], members_list: [],
start_date: null, start_date: null,
target_date: null, target_date: null,
@ -69,14 +70,6 @@ const ModuleDetailSidebar: React.FC<Props> = ({
defaultValues, defaultValues,
}); });
useEffect(() => {
if (module)
reset({
...module,
members_list: module.members_list ?? module.members_detail?.map((m) => m.id),
});
}, [module, reset]);
const groupedIssues = { const groupedIssues = {
backlog: [], backlog: [],
unstarted: [], unstarted: [],
@ -87,29 +80,36 @@ const ModuleDetailSidebar: React.FC<Props> = ({
}; };
const submitChanges = (data: Partial<IModule>) => { const submitChanges = (data: Partial<IModule>) => {
if (!workspaceSlug || !projectId || !module) return; if (!workspaceSlug || !projectId || !moduleId) return;
mutate<IModule[]>( mutate<IModule>(
projectId && MODULE_LIST(projectId as string), MODULE_DETAILS(moduleId as string),
(prevData) => (prevData) => ({
(prevData ?? []).map((module) => { ...(prevData as IModule),
if (module.id === moduleId) return { ...module, ...data }; ...data,
return module;
}), }),
false false
); );
modulesService modulesService
.patchModule(workspaceSlug as string, projectId as string, module.id, data) .patchModule(workspaceSlug as string, projectId as string, moduleId as string, data)
.then((res) => { .then((res) => {
console.log(res); console.log(res);
mutate(MODULE_LIST(projectId as string)); mutate(MODULE_DETAILS(moduleId as string));
}) })
.catch((e) => { .catch((e) => {
console.log(e); console.log(e);
}); });
}; };
useEffect(() => {
if (module)
reset({
...module,
members_list: module.members_list ?? module.members_detail?.map((m) => m.id),
});
}, [module, reset]);
return ( return (
<> <>
<ModuleLinkModal <ModuleLinkModal

View File

@ -4,18 +4,18 @@ import { useRouter } from "next/router";
import { mutate } from "swr"; import { mutate } from "swr";
// react-hook-form
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
// headless ui
import { Dialog, Transition } from "@headlessui/react"; import { Dialog, Transition } from "@headlessui/react";
// hooks
// types
import type { IModule, ModuleLink } from "types";
// services // services
import modulesService from "services/modules.service"; import modulesService from "services/modules.service";
// ui // ui
import { Button, Input } from "components/ui"; import { Button, Input } from "components/ui";
// types
import type { IModule, ModuleLink } from "types";
// fetch-keys // fetch-keys
import { MODULE_LIST } from "constants/fetch-keys"; import { MODULE_DETAILS } from "constants/fetch-keys";
type Props = { type Props = {
isOpen: boolean; isOpen: boolean;
@ -43,23 +43,18 @@ const ModuleLinkModal: React.FC<Props> = ({ isOpen, module, handleClose }) => {
}); });
const onSubmit = async (formData: ModuleLink) => { const onSubmit = async (formData: ModuleLink) => {
if (!workspaceSlug || !projectId || !module) return; if (!workspaceSlug || !projectId || !moduleId) return;
const previousLinks = module.link_module.map((l) => ({ title: l.title, url: l.url })); const previousLinks = module?.link_module.map((l) => ({ title: l.title, url: l.url }));
const payload: Partial<IModule> = { const payload: Partial<IModule> = {
links_list: [...previousLinks, formData], links_list: [...(previousLinks ?? []), formData],
}; };
await modulesService await modulesService
.patchModule(workspaceSlug as string, projectId as string, module.id, payload) .patchModule(workspaceSlug as string, projectId as string, moduleId as string, payload)
.then(() => { .then((res) => {
mutate<IModule[]>(projectId && MODULE_LIST(projectId as string), (prevData) => mutate(MODULE_DETAILS(moduleId as string));
(prevData ?? []).map((module) => {
if (module.id === moduleId) return { ...module, ...payload };
return module;
})
);
onClose(); onClose();
}) })
.catch((err) => { .catch((err) => {

View File

@ -4,22 +4,24 @@ import { useRouter } from "next/router";
import { mutate } from "swr"; import { mutate } from "swr";
// react-hook-form
import { Controller, useForm } from "react-hook-form"; import { Controller, useForm } from "react-hook-form";
// react-color
import { TwitterPicker } from "react-color"; import { TwitterPicker } from "react-color";
// headless ui
import { Dialog, Popover, Transition } from "@headlessui/react"; import { Dialog, Popover, Transition } from "@headlessui/react";
// services // services
import { ChevronDownIcon } from "@heroicons/react/24/outline";
import type { IState } from "types";
import stateService from "services/state.service"; import stateService from "services/state.service";
// ui
import { Button, Input, Select, TextArea } from "components/ui";
// icons
import { ChevronDownIcon } from "@heroicons/react/24/outline";
// types
import type { IState } from "types";
// fetch keys // fetch keys
import { STATE_LIST } from "constants/fetch-keys"; import { STATE_LIST } from "constants/fetch-keys";
// constants // constants
import { GROUP_CHOICES } from "constants/"; import { GROUP_CHOICES } from "constants/";
// ui
import { Button, Input, Select, TextArea } from "components/ui";
// icons
// types // types
type Props = { type Props = {
@ -36,7 +38,12 @@ const defaultValues: Partial<IState> = {
group: "backlog", group: "backlog",
}; };
const CreateUpdateStateModal: React.FC<Props> = ({ isOpen, data, projectId, handleClose }) => { export const CreateUpdateStateModal: React.FC<Props> = ({
isOpen,
data,
projectId,
handleClose,
}) => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug } = router.query; const { workspaceSlug } = router.query;
@ -266,5 +273,3 @@ const CreateUpdateStateModal: React.FC<Props> = ({ isOpen, data, projectId, hand
</Transition.Root> </Transition.Root>
); );
}; };
export default CreateUpdateStateModal;

View File

@ -28,7 +28,7 @@ type Props = {
data: IState | null; data: IState | null;
}; };
const ConfirmStateDeletion: React.FC<Props> = ({ isOpen, onClose, data }) => { export const DeleteStateModal: React.FC<Props> = ({ isOpen, onClose, data }) => {
const [isDeleteLoading, setIsDeleteLoading] = useState(false); const [isDeleteLoading, setIsDeleteLoading] = useState(false);
const [issuesWithThisStateExist, setIssuesWithThisStateExist] = useState(true); const [issuesWithThisStateExist, setIssuesWithThisStateExist] = useState(true);
@ -175,5 +175,3 @@ const ConfirmStateDeletion: React.FC<Props> = ({ isOpen, onClose, data }) => {
</Transition.Root> </Transition.Root>
); );
}; };
export default ConfirmStateDeletion;

View File

@ -0,0 +1,3 @@
export * from "./create-update-state-inline";
export * from "./create-update-state-modal";
export * from "./delete-state-modal";

View File

@ -29,7 +29,7 @@ export const PROJECT_ISSUE_LABELS = (projectId: string) => `PROJECT_ISSUE_LABELS
export const CYCLE_LIST = (projectId: string) => `CYCLE_LIST_${projectId}`; export const CYCLE_LIST = (projectId: string) => `CYCLE_LIST_${projectId}`;
export const CYCLE_ISSUES = (cycleId: string) => `CYCLE_ISSUES_${cycleId}`; export const CYCLE_ISSUES = (cycleId: string) => `CYCLE_ISSUES_${cycleId}`;
export const CYCLE_DETAIL = "CYCLE_DETAIL"; export const CYCLE_DETAILS = (cycleId: string) => `CYCLE_DETAIL_${cycleId}`;
export const STATE_LIST = (projectId: string) => `STATE_LIST_${projectId}`; export const STATE_LIST = (projectId: string) => `STATE_LIST_${projectId}`;
export const STATE_DETAIL = "STATE_DETAIL"; export const STATE_DETAIL = "STATE_DETAIL";
@ -39,7 +39,7 @@ export const USER_PROJECT_VIEW = (projectId: string) => `USER_PROJECT_VIEW_${pro
export const MODULE_LIST = (projectId: string) => `MODULE_LIST_${projectId}`; export const MODULE_LIST = (projectId: string) => `MODULE_LIST_${projectId}`;
export const MODULE_ISSUES = (moduleId: string) => `MODULE_ISSUES_${moduleId}`; export const MODULE_ISSUES = (moduleId: string) => `MODULE_ISSUES_${moduleId}`;
export const MODULE_DETAIL = "MODULE_DETAIL"; export const MODULE_DETAILS = (moduleId: string) => `MODULE_DETAIL_${moduleId}`;
// Issues // Issues
export const ISSUE_DETAILS = (issueId: string) => `ISSUE_DETAILS_${issueId}`; export const ISSUE_DETAILS = (issueId: string) => `ISSUE_DETAILS_${issueId}`;

View File

@ -17,7 +17,7 @@ import useIssuesProperties from "hooks/use-issue-properties";
// types // types
import { IIssue, Properties } from "types"; import { IIssue, Properties } from "types";
// components // components
import { IssueListItem } from "components/issues"; import { MyIssuesListItem } from "components/issues";
// helpers // helpers
import { replaceUnderscoreIfSnakeCase } from "helpers/string.helper"; import { replaceUnderscoreIfSnakeCase } from "helpers/string.helper";
// types // types
@ -142,7 +142,11 @@ const MyIssuesPage: NextPage = () => {
<Disclosure.Panel> <Disclosure.Panel>
<div className="divide-y-2"> <div className="divide-y-2">
{myIssues.map((issue: IIssue) => ( {myIssues.map((issue: IIssue) => (
<IssueListItem key={issue.id} issue={issue} properties={properties} /> <MyIssuesListItem
key={issue.id}
issue={issue}
properties={properties}
/>
))} ))}
</div> </div>
</Disclosure.Panel> </Disclosure.Panel>

View File

@ -13,8 +13,7 @@ import { IssueViewContextProvider } from "contexts/issue-view.context";
// components // components
import CyclesListView from "components/project/cycles/list-view"; import CyclesListView from "components/project/cycles/list-view";
import CyclesBoardView from "components/project/cycles/board-view"; import CyclesBoardView from "components/project/cycles/board-view";
import { CreateUpdateIssueModal } from "components/issues"; import { CreateUpdateIssueModal, DeleteIssueModal } from "components/issues";
import ConfirmIssueDeletion from "components/project/issues/confirm-issue-deletion";
import ExistingIssuesListModal from "components/common/existing-issues-list-modal"; import ExistingIssuesListModal from "components/common/existing-issues-list-modal";
import CycleDetailSidebar from "components/project/cycles/cycle-detail-sidebar"; import CycleDetailSidebar from "components/project/cycles/cycle-detail-sidebar";
import View from "components/core/view"; import View from "components/core/view";
@ -38,6 +37,7 @@ import {
PROJECT_ISSUES_LIST, PROJECT_ISSUES_LIST,
PROJECT_MEMBERS, PROJECT_MEMBERS,
PROJECT_DETAILS, PROJECT_DETAILS,
CYCLE_DETAILS,
} from "constants/fetch-keys"; } from "constants/fetch-keys";
const SingleCycle: React.FC<UserAuth> = (props) => { const SingleCycle: React.FC<UserAuth> = (props) => {
@ -77,6 +77,18 @@ const SingleCycle: React.FC<UserAuth> = (props) => {
: null : null
); );
const { data: cycleDetails } = useSWR(
cycleId ? CYCLE_DETAILS(cycleId as string) : null,
workspaceSlug && projectId && cycleId
? () =>
cycleServices.getCycleDetails(
workspaceSlug as string,
projectId as string,
cycleId as string
)
: null
);
const { data: cycleIssues } = useSWR<CycleIssueResponse[]>( const { data: cycleIssues } = useSWR<CycleIssueResponse[]>(
workspaceSlug && projectId && cycleId ? CYCLE_ISSUES(cycleId as string) : null, workspaceSlug && projectId && cycleId ? CYCLE_ISSUES(cycleId as string) : null,
workspaceSlug && projectId && cycleId workspaceSlug && projectId && cycleId
@ -181,7 +193,7 @@ const SingleCycle: React.FC<UserAuth> = (props) => {
issues={issues?.results.filter((i) => !i.issue_cycle) ?? []} issues={issues?.results.filter((i) => !i.issue_cycle) ?? []}
handleOnSubmit={handleAddIssuesToCycle} handleOnSubmit={handleAddIssuesToCycle}
/> />
<ConfirmIssueDeletion <DeleteIssueModal
handleClose={() => setDeleteIssue(undefined)} handleClose={() => setDeleteIssue(undefined)}
isOpen={!!deleteIssue} isOpen={!!deleteIssue}
data={issues?.results.find((issue) => issue.id === deleteIssue)} data={issues?.results.find((issue) => issue.id === deleteIssue)}
@ -200,7 +212,7 @@ const SingleCycle: React.FC<UserAuth> = (props) => {
label={ label={
<> <>
<CyclesIcon className="h-3 w-3" /> <CyclesIcon className="h-3 w-3" />
{cycles?.find((c) => c.id === cycleId)?.name} {cycleDetails?.name}
</> </>
} }
className="ml-1.5" className="ml-1.5"
@ -287,7 +299,7 @@ const SingleCycle: React.FC<UserAuth> = (props) => {
</div> </div>
)} )}
<CycleDetailSidebar <CycleDetailSidebar
cycle={cycles?.find((c) => c.id === (cycleId as string))} cycle={cycleDetails}
isOpen={cycleSidebar} isOpen={cycleSidebar}
cycleIssues={cycleIssues ?? []} cycleIssues={cycleIssues ?? []}
/> />

View File

@ -14,11 +14,15 @@ import { requiredAdmin, requiredAuth } from "lib/auth";
// layouts // layouts
import AppLayout from "layouts/app-layout"; import AppLayout from "layouts/app-layout";
// components // components
import AddAsSubIssue from "components/project/issues/issue-detail/add-as-sub-issue"; import {
import IssueDetailSidebar from "components/project/issues/issue-detail/issue-detail-sidebar"; IssueDescriptionForm,
import AddIssueComment from "components/project/issues/issue-detail/comment/issue-comment-section"; SubIssuesList,
import IssueActivitySection from "components/project/issues/issue-detail/activity"; CreateUpdateIssueModal,
import { IssueDescriptionForm, SubIssueList, CreateUpdateIssueModal } from "components/issues"; IssueDetailsSidebar,
IssueActivitySection,
AddComment,
SubIssuesListModal,
} from "components/issues";
// ui // ui
import { Loader, CustomMenu } from "components/ui"; import { Loader, CustomMenu } from "components/ui";
import { Breadcrumbs } from "components/breadcrumbs"; import { Breadcrumbs } from "components/breadcrumbs";
@ -52,7 +56,7 @@ const defaultValues = {
const IssueDetailsPage: NextPage<UserAuth> = (props) => { const IssueDetailsPage: NextPage<UserAuth> = (props) => {
// states // states
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);
const [isAddAsSubIssueOpen, setIsAddAsSubIssueOpen] = useState(false); const [subIssuesListModal, setSubIssuesListModal] = useState(false);
const [preloadedData, setPreloadedData] = useState< const [preloadedData, setPreloadedData] = useState<
(Partial<IIssue> & { actionType: "createIssue" | "edit" | "delete" }) | undefined (Partial<IIssue> & { actionType: "createIssue" | "edit" | "delete" }) | undefined
>(undefined); >(undefined);
@ -211,10 +215,10 @@ const IssueDetailsPage: NextPage<UserAuth> = (props) => {
}} }}
/> />
)} )}
{isAddAsSubIssueOpen && ( {subIssuesListModal && (
<AddAsSubIssue <SubIssuesListModal
isOpen={isAddAsSubIssueOpen} isOpen={subIssuesListModal}
setIsOpen={setIsAddAsSubIssueOpen} handleClose={() => setSubIssuesListModal(false)}
parent={issueDetails} parent={issueDetails}
/> />
)} )}
@ -276,7 +280,7 @@ const IssueDetailsPage: NextPage<UserAuth> = (props) => {
/> />
<div className="mt-2"> <div className="mt-2">
{issueId && workspaceSlug && projectId && subIssues?.length > 0 ? ( {issueId && workspaceSlug && projectId && subIssues?.length > 0 ? (
<SubIssueList <SubIssuesList
issues={subIssues} issues={subIssues}
parentIssue={issueDetails} parentIssue={issueDetails}
projectId={projectId?.toString()} projectId={projectId?.toString()}
@ -309,7 +313,7 @@ const IssueDetailsPage: NextPage<UserAuth> = (props) => {
</CustomMenu.MenuItem> </CustomMenu.MenuItem>
<CustomMenu.MenuItem <CustomMenu.MenuItem
onClick={() => { onClick={() => {
setIsAddAsSubIssueOpen(true); setSubIssuesListModal(true);
setPreloadedData({ setPreloadedData({
parent: issueDetails.id, parent: issueDetails.id,
actionType: "createIssue", actionType: "createIssue",
@ -329,11 +333,11 @@ const IssueDetailsPage: NextPage<UserAuth> = (props) => {
issueActivities={issueActivities || []} issueActivities={issueActivities || []}
mutate={mutateIssueActivities} mutate={mutateIssueActivities}
/> />
<AddIssueComment mutate={mutateIssueActivities} /> <AddComment mutate={mutateIssueActivities} />
</div> </div>
</div> </div>
<div className="basis-1/3 space-y-5 border-l p-5"> <div className="basis-1/3 space-y-5 border-l p-5">
<IssueDetailSidebar <IssueDetailsSidebar
control={control} control={control}
issueDetail={issueDetails} issueDetail={issueDetails}
submitChanges={submitChanges} submitChanges={submitChanges}

View File

@ -13,10 +13,8 @@ import AppLayout from "layouts/app-layout";
// contexts // contexts
import { IssueViewContextProvider } from "contexts/issue-view.context"; import { IssueViewContextProvider } from "contexts/issue-view.context";
// components // components
import ListView from "components/project/issues/list-view"; import BoardView from "components/issues/board-view";
import BoardView from "components/project/issues/BoardView"; import { CreateUpdateIssueModal, DeleteIssueModal, IssuesListView } from "components/issues";
import ConfirmIssueDeletion from "components/project/issues/confirm-issue-deletion";
import { CreateUpdateIssueModal } from "components/issues";
import View from "components/core/view"; import View from "components/core/view";
// ui // ui
import { Spinner, EmptySpace, EmptySpaceItem, HeaderButton } from "components/ui"; import { Spinner, EmptySpace, EmptySpaceItem, HeaderButton } from "components/ui";
@ -99,7 +97,7 @@ const ProjectIssues: NextPage<UserAuth> = (props) => {
handleClose={() => setIsOpen(false)} handleClose={() => setIsOpen(false)}
data={selectedIssue} data={selectedIssue}
/> />
<ConfirmIssueDeletion <DeleteIssueModal
handleClose={() => setDeleteIssue(undefined)} handleClose={() => setDeleteIssue(undefined)}
isOpen={!!deleteIssue} isOpen={!!deleteIssue}
data={projectIssues?.results.find((issue) => issue.id === deleteIssue)} data={projectIssues?.results.find((issue) => issue.id === deleteIssue)}
@ -110,7 +108,7 @@ const ProjectIssues: NextPage<UserAuth> = (props) => {
</div> </div>
) : projectIssues.count > 0 ? ( ) : projectIssues.count > 0 ? (
<> <>
<ListView <IssuesListView
issues={projectIssues?.results.filter((p) => p.parent === null) ?? []} issues={projectIssues?.results.filter((p) => p.parent === null) ?? []}
handleEditIssue={handleEditIssue} handleEditIssue={handleEditIssue}
userAuth={props} userAuth={props}

View File

@ -18,10 +18,9 @@ import { IssueViewContextProvider } from "contexts/issue-view.context";
import ExistingIssuesListModal from "components/common/existing-issues-list-modal"; import ExistingIssuesListModal from "components/common/existing-issues-list-modal";
import ModulesBoardView from "components/project/modules/board-view"; import ModulesBoardView from "components/project/modules/board-view";
import ModulesListView from "components/project/modules/list-view"; import ModulesListView from "components/project/modules/list-view";
import ConfirmIssueDeletion from "components/project/issues/confirm-issue-deletion";
import ModuleDetailSidebar from "components/project/modules/module-detail-sidebar"; import ModuleDetailSidebar from "components/project/modules/module-detail-sidebar";
import ConfirmModuleDeletion from "components/project/modules/confirm-module-deletion"; import ConfirmModuleDeletion from "components/project/modules/confirm-module-deletion";
import { CreateUpdateIssueModal } from "components/issues"; import { CreateUpdateIssueModal, DeleteIssueModal } from "components/issues";
import View from "components/core/view"; import View from "components/core/view";
// ui // ui
import { CustomMenu, EmptySpace, EmptySpaceItem, Spinner } from "components/ui"; import { CustomMenu, EmptySpace, EmptySpaceItem, Spinner } from "components/ui";
@ -46,7 +45,7 @@ import {
import { NextPageContext } from "next"; import { NextPageContext } from "next";
// fetch-keys // fetch-keys
import { import {
MODULE_DETAIL, MODULE_DETAILS,
MODULE_ISSUES, MODULE_ISSUES,
MODULE_LIST, MODULE_LIST,
PROJECT_ISSUES_LIST, PROJECT_ISSUES_LIST,
@ -96,8 +95,8 @@ const SingleModule: React.FC<UserAuth> = (props) => {
: null : null
); );
const { data: moduleDetail } = useSWR<IModule>( const { data: moduleDetails } = useSWR<IModule>(
MODULE_DETAIL, moduleId ? MODULE_DETAILS(moduleId as string) : null,
workspaceSlug && projectId workspaceSlug && projectId
? () => ? () =>
modulesService.getModuleDetails( modulesService.getModuleDetails(
@ -181,9 +180,9 @@ const SingleModule: React.FC<UserAuth> = (props) => {
}; };
const handleDeleteModule = () => { const handleDeleteModule = () => {
if (!moduleDetail) return; if (!moduleDetails) return;
setSelectedModuleForDelete({ ...moduleDetail, actionType: "delete" }); setSelectedModuleForDelete({ ...moduleDetails, actionType: "delete" });
setModuleDeleteModal(true); setModuleDeleteModal(true);
}; };
@ -208,7 +207,7 @@ const SingleModule: React.FC<UserAuth> = (props) => {
issues={issues?.results.filter((i) => !i.issue_module) ?? []} issues={issues?.results.filter((i) => !i.issue_module) ?? []}
handleOnSubmit={handleAddIssuesToModule} handleOnSubmit={handleAddIssuesToModule}
/> />
<ConfirmIssueDeletion <DeleteIssueModal
handleClose={() => setDeleteIssue(undefined)} handleClose={() => setDeleteIssue(undefined)}
isOpen={!!deleteIssue} isOpen={!!deleteIssue}
data={moduleIssuesArray?.find((issue) => issue.id === deleteIssue)} data={moduleIssuesArray?.find((issue) => issue.id === deleteIssue)}
@ -226,7 +225,7 @@ const SingleModule: React.FC<UserAuth> = (props) => {
breadcrumbs={ breadcrumbs={
<Breadcrumbs> <Breadcrumbs>
<BreadcrumbItem <BreadcrumbItem
title={`${moduleDetail?.project_detail.name ?? "Project"} Modules`} title={`${moduleDetails?.project_detail.name ?? "Project"} Modules`}
link={`/${workspaceSlug}/projects/${projectId}/modules`} link={`/${workspaceSlug}/projects/${projectId}/modules`}
/> />
</Breadcrumbs> </Breadcrumbs>
@ -236,7 +235,7 @@ const SingleModule: React.FC<UserAuth> = (props) => {
label={ label={
<> <>
<RectangleGroupIcon className="h-3 w-3" /> <RectangleGroupIcon className="h-3 w-3" />
{modules?.find((c) => c.id === moduleId)?.name} {moduleDetails?.name}
</> </>
} }
className="ml-1.5" className="ml-1.5"
@ -323,7 +322,7 @@ const SingleModule: React.FC<UserAuth> = (props) => {
</div> </div>
)} )}
<ModuleDetailSidebar <ModuleDetailSidebar
module={modules?.find((m) => m.id === moduleId)} module={moduleDetails}
isOpen={moduleSidebar} isOpen={moduleSidebar}
moduleIssues={moduleIssues} moduleIssues={moduleIssues}
handleDeleteModule={handleDeleteModule} handleDeleteModule={handleDeleteModule}

View File

@ -13,11 +13,7 @@ import { requiredAdmin } from "lib/auth";
// layouts // layouts
import SettingsLayout from "layouts/settings-layout"; import SettingsLayout from "layouts/settings-layout";
// components // components
import ConfirmStateDeletion from "components/project/issues/BoardView/state/confirm-state-delete"; import { CreateUpdateStateInline, DeleteStateModal, StateGroup } from "components/states";
import {
CreateUpdateStateInline,
StateGroup,
} from "components/project/issues/BoardView/state/create-update-state-inline";
// ui // ui
import { Loader } from "components/ui"; import { Loader } from "components/ui";
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
@ -67,7 +63,7 @@ const StatesSettings: NextPage<TStateSettingsProps> = (props) => {
return ( return (
<> <>
<ConfirmStateDeletion <DeleteStateModal
isOpen={!!selectDeleteState} isOpen={!!selectDeleteState}
data={states?.find((state) => state.id === selectDeleteState) ?? null} data={states?.find((state) => state.id === selectDeleteState) ?? null}
onClose={() => setSelectDeleteState(null)} onClose={() => setSelectDeleteState(null)}

View File

@ -26,6 +26,18 @@ class ProjectCycleServices extends APIService {
}); });
} }
async getCycleDetails(
workspaceSlug: string,
projectId: string,
cycleId: string
): Promise<ICycle> {
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/cycles/${cycleId}/`)
.then((res) => res?.data)
.catch((err) => {
throw err?.response?.data;
});
}
async getCycleIssues(workspaceSlug: string, projectId: string, cycleId: string): Promise<any> { async getCycleIssues(workspaceSlug: string, projectId: string, cycleId: string): Promise<any> {
return this.get( return this.get(
`/api/workspaces/${workspaceSlug}/projects/${projectId}/cycles/${cycleId}/cycle-issues/` `/api/workspaces/${workspaceSlug}/projects/${projectId}/cycles/${cycleId}/cycle-issues/`