Skip to content

Commit

Permalink
fix: create issue modal bugs (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaryan610 authored Feb 8, 2023
1 parent 8e3541b commit 4ffa31f
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 66 deletions.
7 changes: 1 addition & 6 deletions apps/app/components/core/bulk-delete-issues-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,7 @@ export const BulkDeleteIssuesModal: React.FC<Props> = ({ isOpen, setIsOpen }) =>
"delete_issue_ids",
selectedIssues.filter((i) => i !== val)
);
else {
const newToDelete = selectedIssues;
newToDelete.push(val);

setValue("delete_issue_ids", newToDelete);
}
else setValue("delete_issue_ids", [...selectedIssues, val]);
}}
>
<div className="relative m-1">
Expand Down
21 changes: 13 additions & 8 deletions apps/app/components/core/sidebar/sidebar-progress-stats.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import React from "react";
import { Tab } from "@headlessui/react";

import Image from "next/image";
import { useRouter } from "next/router";

import useSWR from "swr";
import Image from "next/image";

// headless ui
import { Tab } from "@headlessui/react";
// services
import issuesServices from "services/issues.service";
import projectService from "services/project.service";
// components
import SingleProgressStats from "components/core/sidebar/single-progress-stats";
// ui
import SingleProgressStats from "./single-progress-stats";
import { Avatar } from "components/ui";
// icons
import User from "public/user.png";
// types
import { IIssue, IIssueLabels } from "types";
// constants
// fetch-keys
import { PROJECT_ISSUE_LABELS, PROJECT_MEMBERS } from "constants/fetch-keys";
// services
import issuesServices from "services/issues.service";
import projectService from "services/project.service";

// types
type Props = {
groupedIssues: any;
issues: IIssue[];
Expand Down
7 changes: 1 addition & 6 deletions apps/app/components/issues/sidebar-select/blocked.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,7 @@ export const SidebarBlockedSelect: React.FC<Props> = ({
"blocked_issue_ids",
selectedIssues.filter((i) => i !== val)
);
else {
const newBlocked = selectedIssues;
newBlocked.push(val);

setValue("blocked_issue_ids", newBlocked);
}
else setValue("blocked_issue_ids", [...selectedIssues, val]);
}}
>
<div className="relative m-1">
Expand Down
7 changes: 1 addition & 6 deletions apps/app/components/issues/sidebar-select/blocker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,7 @@ export const SidebarBlockerSelect: React.FC<Props> = ({
"blocker_issue_ids",
selectedIssues.filter((i) => i !== val)
);
else {
const newBlockers = selectedIssues;
newBlockers.push(val);

setValue("blocker_issue_ids", newBlockers);
}
else setValue("blocker_issue_ids", [...selectedIssues, val]);
}}
>
<div className="relative m-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ import { mutate } from "swr";

// react-hook-form
import { Controller, useForm } from "react-hook-form";
// icons
import { CalendarDaysIcon, ChartPieIcon, LinkIcon, UserIcon } from "@heroicons/react/24/outline";

// progress-bar
// react-circular-progressbar
import { CircularProgressbar } from "react-circular-progressbar";
import "react-circular-progressbar/dist/styles.css";
// ui
import { Loader, CustomDatePicker } from "components/ui";
import "react-circular-progressbar/dist/styles.css";
// hooks
import useToast from "hooks/use-toast";
// services
import cyclesService from "services/cycles.service";
// components
import SidebarProgressStats from "components/core/sidebar/sidebar-progress-stats";
// icons
import { CalendarDaysIcon, ChartPieIcon, LinkIcon, UserIcon } from "@heroicons/react/24/outline";
// helpers
import { copyTextToClipboard } from "helpers/string.helper";
import { groupBy } from "helpers/array.helper";
// types
import { CycleIssueResponse, ICycle, IIssue } from "types";
// fetch-keys
import { CYCLE_DETAILS } from "constants/fetch-keys";
import SidebarProgressStats from "components/core/sidebar/sidebar-progress-stats";

type Props = {
issues: IIssue[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import AppLayout from "layouts/app-layout";
// contexts
import { IssueViewContextProvider } from "contexts/issue-view.context";
// components
import { CreateUpdateIssueModal } from "components/issues";
import { ExistingIssuesListModal, IssuesFilterView, IssuesView } from "components/core";
import CycleDetailSidebar from "components/project/cycles/cycle-detail-sidebar";
// services
Expand All @@ -25,28 +24,20 @@ import projectService from "services/project.service";
import { CustomMenu, EmptySpace, EmptySpaceItem, Spinner } from "components/ui";
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
// types
import { CycleIssueResponse, IIssue, IIssueLabels, SelectIssue, UserAuth } from "types";
import { CycleIssueResponse, UserAuth } from "types";
// fetch-keys
import {
CYCLE_ISSUES,
CYCLE_LIST,
PROJECT_ISSUES_LIST,
PROJECT_DETAILS,
PROJECT_ISSUE_LABELS,
CYCLE_DETAILS,
PROJECT_MEMBERS,
} from "constants/fetch-keys";

const SingleCycle: React.FC<UserAuth> = (props) => {
const [isIssueModalOpen, setIsIssueModalOpen] = useState(false);
const [selectedIssues, setSelectedIssues] = useState<SelectIssue>();
const [cycleIssuesListModal, setCycleIssuesListModal] = useState(false);
const [cycleSidebar, setCycleSidebar] = useState(true);

const [preloadedData, setPreloadedData] = useState<
(Partial<IIssue> & { actionType: "createIssue" | "edit" | "delete" }) | null
>(null);

const router = useRouter();
const { workspaceSlug, projectId, cycleId } = router.query;

Expand Down Expand Up @@ -104,18 +95,6 @@ const SingleCycle: React.FC<UserAuth> = (props) => {
cycle: cycleId as string,
}));

const openCreateIssueModal = (
issue?: IIssue,
actionType: "create" | "edit" | "delete" = "create"
) => {
if (issue) {
setPreloadedData(null);
setSelectedIssues({ ...issue, actionType });
} else setSelectedIssues(null);

setIsIssueModalOpen(true);
};

const openIssuesListModal = () => {
setCycleIssuesListModal(true);
};
Expand All @@ -136,16 +115,6 @@ const SingleCycle: React.FC<UserAuth> = (props) => {

return (
<IssueViewContextProvider>
<CreateUpdateIssueModal
isOpen={isIssueModalOpen && selectedIssues?.actionType !== "delete"}
data={selectedIssues}
prePopulateData={
preloadedData
? { cycle: cycleId as string, ...preloadedData }
: { cycle: cycleId as string, ...selectedIssues }
}
handleClose={() => setIsIssueModalOpen(false)}
/>
<ExistingIssuesListModal
isOpen={cycleIssuesListModal}
handleClose={() => setCycleIssuesListModal(false)}
Expand Down Expand Up @@ -226,7 +195,12 @@ const SingleCycle: React.FC<UserAuth> = (props) => {
title="Create a new issue"
description="Click to create a new issue inside the cycle."
Icon={PlusIcon}
action={openCreateIssueModal}
action={() => {
const e = new KeyboardEvent("keydown", {
key: "c",
});
document.dispatchEvent(e);
}}
/>
<EmptySpaceItem
title="Add an existing issue"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,12 @@ const SingleModule: React.FC<UserAuth> = (props) => {
title="Create a new issue"
description="Click to create a new issue inside the module."
Icon={PlusIcon}
action={openCreateIssueModal}
action={() => {
const e = new KeyboardEvent("keydown", {
key: "c",
});
document.dispatchEvent(e);
}}
/>
<EmptySpaceItem
title="Add an existing issue"
Expand Down

1 comment on commit 4ffa31f

@vercel
Copy link

@vercel vercel bot commented on 4ffa31f Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

plane-dev – ./apps/app

plane-dev.vercel.app
plane-dev-git-develop-caravel.vercel.app
plane-dev-caravel.vercel.app

Please sign in to comment.