From 259213851f0e325253f00f426aaac1161ad3285a Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal Date: Tue, 6 Dec 2022 20:08:28 +0530 Subject: [PATCH] feat: all functionalities in cycle, crud for labels in settings --- .../command-palette/addAsSubIssue.tsx | 11 +- apps/app/components/command-palette/index.tsx | 165 ++---- apps/app/components/lexical/editor.tsx | 1 + .../project/cycles/CycleIssuesListModal.tsx | 208 ++++++++ .../components/project/cycles/CycleView.tsx | 500 ++++++++++-------- .../project/issues/BoardView/SingleBoard.tsx | 5 +- .../SelectParentIssue.tsx | 34 +- .../CreateUpdateIssueModal/SelectState.tsx | 62 ++- .../issues/CreateUpdateIssueModal/index.tsx | 82 +-- .../project/issues/IssuesListModal.tsx | 6 + .../project/issues/ListView/index.tsx | 30 +- .../issues/issue-detail/activity/index.tsx | 1 - .../issues/my-issues/ChangeStateDropdown.tsx | 2 +- .../project/settings/ControlSettings.tsx | 197 +++++++ .../project/settings/GeneralSettings.tsx | 119 +++++ .../project/settings/LabelsSettings.tsx | 275 ++++++++++ .../project/settings/StatesSettings.tsx | 78 +++ apps/app/constants/api-routes.ts | 9 + apps/app/contexts/toast.context.tsx | 2 +- apps/app/layouts/Navbar/Sidebar.tsx | 54 +- apps/app/lib/services/cycles.services.ts | 32 +- apps/app/lib/services/issues.services.ts | 42 ++ apps/app/pages/editor.tsx | 26 - apps/app/pages/me/my-issues.tsx | 140 +++-- .../app/pages/projects/[projectId]/cycles.tsx | 100 +++- .../projects/[projectId]/issues/[issueId].tsx | 172 ++++-- .../pages/projects/[projectId]/settings.tsx | 474 ++--------------- apps/app/types/sprints.d.ts | 6 +- apps/app/ui/CustomListbox/index.tsx | 2 - apps/app/ui/Select/index.tsx | 4 +- 30 files changed, 1784 insertions(+), 1055 deletions(-) create mode 100644 apps/app/components/project/cycles/CycleIssuesListModal.tsx create mode 100644 apps/app/components/project/settings/ControlSettings.tsx create mode 100644 apps/app/components/project/settings/GeneralSettings.tsx create mode 100644 apps/app/components/project/settings/LabelsSettings.tsx create mode 100644 apps/app/components/project/settings/StatesSettings.tsx delete mode 100644 apps/app/pages/editor.tsx diff --git a/apps/app/components/command-palette/addAsSubIssue.tsx b/apps/app/components/command-palette/addAsSubIssue.tsx index 11cfcc907..e8c585e45 100644 --- a/apps/app/components/command-palette/addAsSubIssue.tsx +++ b/apps/app/components/command-palette/addAsSubIssue.tsx @@ -22,7 +22,7 @@ import { PROJECT_ISSUES_LIST } from "constants/fetch-keys"; type Props = { isOpen: boolean; setIsOpen: React.Dispatch>; - parentId: string; + parent: IIssue | undefined; }; type FormInput = { @@ -30,7 +30,7 @@ type FormInput = { cycleId: string; }; -const AddAsSubIssue: React.FC = ({ isOpen, setIsOpen, parentId }) => { +const AddAsSubIssue: React.FC = ({ isOpen, setIsOpen, parent }) => { const [query, setQuery] = useState(""); const { activeWorkspace, activeProject, issues } = useUser(); @@ -54,7 +54,7 @@ const AddAsSubIssue: React.FC = ({ isOpen, setIsOpen, parentId }) => { const addAsSubIssue = (issueId: string) => { if (activeWorkspace && activeProject) { issuesServices - .patchIssue(activeWorkspace.slug, activeProject.id, issueId, { parent: parentId }) + .patchIssue(activeWorkspace.slug, activeProject.id, issueId, { parent: parent?.id }) .then((res) => { mutate( PROJECT_ISSUES_LIST(activeWorkspace.slug, activeProject.id), @@ -127,8 +127,9 @@ const AddAsSubIssue: React.FC = ({ isOpen, setIsOpen, parentId }) => {
    {filteredIssues.map((issue) => { if ( - (issue.parent === "" || issue.parent === null) && - issue.id !== parentId + (issue.parent === "" || issue.parent === null) && // issue does not have any other parent + issue.id !== parent?.id && // issue is not itself + issue.id !== parent?.parent // issue is not it's parent ) return ( void; -}; +import { PROJECT_ISSUES_LIST } from "constants/fetch-keys"; +// constants +import { classNames, copyTextToClipboard } from "constants/common"; type FormInput = { issue_ids: string[]; @@ -45,8 +40,6 @@ type FormInput = { }; const CommandPalette: React.FC = () => { - const router = useRouter(); - const [query, setQuery] = useState(""); const [isPaletteOpen, setIsPaletteOpen] = useState(false); @@ -55,7 +48,9 @@ const CommandPalette: React.FC = () => { const [isShortcutsModalOpen, setIsShortcutsModalOpen] = useState(false); const [isCreateCycleModalOpen, setIsCreateCycleModalOpen] = useState(false); - const { activeWorkspace, activeProject, issues, cycles } = useUser(); + const { activeWorkspace, activeProject, issues } = useUser(); + + const router = useRouter(); const { toggleCollapsed } = useTheme(); @@ -67,14 +62,7 @@ const CommandPalette: React.FC = () => { : issues?.results.filter((issue) => issue.name.toLowerCase().includes(query.toLowerCase())) ?? []; - const { - register, - formState: { errors, isSubmitting }, - handleSubmit, - control, - reset, - setError, - } = useForm(); + const { register, handleSubmit, reset } = useForm(); const quickActions = [ { @@ -186,37 +174,6 @@ const CommandPalette: React.FC = () => { } }; - const handleAddToCycle: SubmitHandler = (data) => { - if (!data.issue_ids || data.issue_ids.length === 0) { - setToastAlert({ - title: "Error", - type: "error", - message: "Please select atleast one issue", - }); - return; - } - - if (!data.cycleId) { - setToastAlert({ - title: "Error", - type: "error", - message: "Please select a cycle", - }); - return; - } - - if (activeWorkspace && activeProject) { - issuesServices - .bulkAddIssuesToCycle(activeWorkspace.slug, activeProject.id, data.cycleId, data) - .then((res) => { - console.log(res); - }) - .catch((e) => { - console.log(e); - }); - } - }; - useEffect(() => { document.addEventListener("keydown", handleKeyDown); return () => document.removeEventListener("keydown", handleKeyDown); @@ -269,14 +226,7 @@ const CommandPalette: React.FC = () => { >
    - { - // const { url, onClick } = item; - // if (url) router.push(url); - // else if (onClick) onClick(); - // handleCommandPaletteClose(); - // }} - > +
    { {filteredIssues.map((issue) => ( classNames( - "flex cursor-pointer select-none items-center rounded-md px-3 py-2", + "flex items-center justify-between cursor-pointer select-none rounded-md px-3 py-2", active ? "bg-gray-900 bg-opacity-5 text-gray-900" : "" ) } > {({ active }) => ( <> - {/*