From eaa77a25524d3a1d2cb2db27ca1135680fc685f4 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Tue, 31 Jan 2023 19:24:45 +0530 Subject: [PATCH] fix: consistent icons and modal fixes (#216) * fix: consistent icons and modal fixes * fix: total worspace members * fix: sub issue mutation --- .../components/account/email-signin-form.tsx | 4 +- .../common/bulk-delete-issues-modal.tsx | 94 +++++++++---------- apps/app/components/cycles/select.tsx | 5 +- apps/app/components/issues/form.tsx | 7 +- .../project/cycles/stats-view/single-stat.tsx | 12 +-- .../issues/issue-detail/add-as-sub-issue.tsx | 18 +++- .../comment/issue-comment-card.tsx | 9 +- .../comment/issue-comment-section.tsx | 8 +- .../issue-detail-sidebar/select-cycle.tsx | 8 +- .../rich-text-editor/toolbar/index.tsx | 7 +- .../components/workspace/sidebar-dropdown.tsx | 3 +- apps/app/layouts/app-layout/app-header.tsx | 40 ++++---- apps/app/layouts/app-layout/app-sidebar.tsx | 2 - .../projects/[projectId]/cycles/[cycleId].tsx | 13 +-- .../projects/[projectId]/issues/[issueId].tsx | 19 +++- .../pages/[workspaceSlug]/settings/index.tsx | 1 + apps/app/styles/editor.css | 4 + 17 files changed, 137 insertions(+), 117 deletions(-) diff --git a/apps/app/components/account/email-signin-form.tsx b/apps/app/components/account/email-signin-form.tsx index 3d13ca5a1..5e47f36d3 100644 --- a/apps/app/components/account/email-signin-form.tsx +++ b/apps/app/components/account/email-signin-form.tsx @@ -28,7 +28,7 @@ export const EmailSignInForm: FC = (props) => { or -
+ {/*
-
+
*/} ); diff --git a/apps/app/components/common/bulk-delete-issues-modal.tsx b/apps/app/components/common/bulk-delete-issues-modal.tsx index 8b8125b48..64a65c22a 100644 --- a/apps/app/components/common/bulk-delete-issues-modal.tsx +++ b/apps/app/components/common/bulk-delete-issues-modal.tsx @@ -24,8 +24,7 @@ import { IIssue, IssueResponse } from "types"; import { PROJECT_ISSUES_LIST, PROJECT_DETAILS } from "constants/fetch-keys"; type FormInput = { - issue_ids: string[]; - cycleId: string; + delete_issue_ids: string[]; }; type Props = { @@ -61,17 +60,27 @@ const BulkDeleteIssuesModal: React.FC = ({ isOpen, setIsOpen }) => { const { setToastAlert } = useToast(); const { - register, handleSubmit, + watch, reset, + setValue, formState: { isSubmitting }, - } = useForm(); + } = useForm({ + defaultValues: { + delete_issue_ids: [], + }, + }); const filteredIssues: IIssue[] = query === "" ? issues?.results ?? [] - : issues?.results.filter((issue) => issue.name.toLowerCase().includes(query.toLowerCase())) ?? - []; + : issues?.results.filter( + (issue) => + issue.name.toLowerCase().includes(query.toLowerCase()) || + `${issue.project_detail.identifier}-${issue.sequence_id}` + .toLowerCase() + .includes(query.toLowerCase()) + ) ?? []; const handleClose = () => { setIsOpen(false); @@ -80,7 +89,7 @@ const BulkDeleteIssuesModal: React.FC = ({ isOpen, setIsOpen }) => { }; const handleDelete: SubmitHandler = async (data) => { - if (!data.issue_ids || data.issue_ids.length === 0) { + if (!data.delete_issue_ids || data.delete_issue_ids.length === 0) { setToastAlert({ title: "Error", type: "error", @@ -89,30 +98,34 @@ const BulkDeleteIssuesModal: React.FC = ({ isOpen, setIsOpen }) => { return; } - if (!Array.isArray(data.issue_ids)) data.issue_ids = [data.issue_ids]; + if (!Array.isArray(data.delete_issue_ids)) data.delete_issue_ids = [data.delete_issue_ids]; if (workspaceSlug && projectId) { await issuesServices - .bulkDeleteIssues(workspaceSlug as string, projectId as string, data) + .bulkDeleteIssues(workspaceSlug as string, projectId as string, { + issue_ids: data.delete_issue_ids, + }) .then((res) => { setToastAlert({ title: "Success", type: "success", message: res.message, }); + mutate( PROJECT_ISSUES_LIST(workspaceSlug as string, projectId as string), (prevData) => ({ ...(prevData as IssueResponse), count: (prevData?.results ?? []).filter( - (p) => !data.issue_ids.some((id) => p.id === id) + (p) => !data.delete_issue_ids.some((id) => p.id === id) ).length, results: (prevData?.results ?? []).filter( - (p) => !data.issue_ids.some((id) => p.id === id) + (p) => !data.delete_issue_ids.some((id) => p.id === id) ), }), false ); + handleClose(); }) .catch((e) => { console.log(e); @@ -123,18 +136,6 @@ const BulkDeleteIssuesModal: React.FC = ({ isOpen, setIsOpen }) => { return ( setQuery("")} appear> - -
- -
= ({ isOpen, setIsOpen }) => { leaveFrom="opacity-100 scale-100" leaveTo="opacity-0 scale-95" > - +
- + { + const selectedIssues = watch("delete_issue_ids"); + if (selectedIssues.includes(val)) + setValue( + "delete_issue_ids", + selectedIssues.filter((i) => i !== val) + ); + else { + const newToDelete = selectedIssues; + newToDelete.push(val); + + setValue("delete_issue_ids", newToDelete); + } + }} + >
-
diff --git a/apps/app/components/project/issues/issue-detail/add-as-sub-issue.tsx b/apps/app/components/project/issues/issue-detail/add-as-sub-issue.tsx index 46dc55594..95eae4555 100644 --- a/apps/app/components/project/issues/issue-detail/add-as-sub-issue.tsx +++ b/apps/app/components/project/issues/issue-detail/add-as-sub-issue.tsx @@ -11,7 +11,7 @@ import { RectangleStackIcon, MagnifyingGlassIcon } from "@heroicons/react/24/out // services import issuesServices from "services/issues.service"; // types -import { IIssue } from "types"; +import { IIssue, IssueResponse } from "types"; // constants import { PROJECT_ISSUES_LIST, SUB_ISSUES } from "constants/fetch-keys"; @@ -54,6 +54,22 @@ const AddAsSubIssue: React.FC = ({ isOpen, setIsOpen, parent }) => { .patchIssue(workspaceSlug as string, projectId as string, issueId, { parent: parent?.id }) .then((res) => { mutate(SUB_ISSUES(parent?.id ?? "")); + mutate( + PROJECT_ISSUES_LIST(workspaceSlug as string, projectId as string), + (prevData) => ({ + ...(prevData as IssueResponse), + results: (prevData?.results ?? []).map((p) => { + if (p.id === res.id) + return { + ...p, + ...res, + }; + + return p; + }), + }), + false + ); }) .catch((e) => { console.log(e); diff --git a/apps/app/components/project/issues/issue-detail/comment/issue-comment-card.tsx b/apps/app/components/project/issues/issue-detail/comment/issue-comment-card.tsx index e2b17ea00..ec270ff25 100644 --- a/apps/app/components/project/issues/issue-detail/comment/issue-comment-card.tsx +++ b/apps/app/components/project/issues/issue-detail/comment/issue-comment-card.tsx @@ -1,6 +1,5 @@ -// react import React, { useEffect, useState } from "react"; -// next + import Image from "next/image"; import dynamic from "next/dynamic"; @@ -8,14 +7,14 @@ import dynamic from "next/dynamic"; import { useForm } from "react-hook-form"; // icons import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline"; -// types -import type { IIssueComment } from "types"; // hooks import useUser from "hooks/use-user"; // ui import { CustomMenu } from "components/ui"; // helpers import { timeAgo } from "helpers/date-time.helper"; +// types +import type { IIssueComment } from "types"; const RemirrorRichTextEditor = dynamic(() => import("components/rich-text-editor"), { ssr: false }); @@ -76,7 +75,7 @@ const CommentCard: React.FC = ({ comment, onSubmit, handleCommentDeletion {timeAgo(comment.created_at)}

-
+
{isEditing ? ( import("components/rich-text-editor"), { ssr: false, @@ -83,7 +83,7 @@ const AddIssueComment: React.FC<{ return (
-
+
= ({ issueDetail, handleCycleChange }) => { return (
- +

Cycle

diff --git a/apps/app/components/rich-text-editor/toolbar/index.tsx b/apps/app/components/rich-text-editor/toolbar/index.tsx index 3a3292eeb..f5ff2db70 100644 --- a/apps/app/components/rich-text-editor/toolbar/index.tsx +++ b/apps/app/components/rich-text-editor/toolbar/index.tsx @@ -32,11 +32,8 @@ export const RichTextToolbar: React.FC = () => (
- {/*
- -
*/} -
+ {/*
-
+
*/}
); diff --git a/apps/app/components/workspace/sidebar-dropdown.tsx b/apps/app/components/workspace/sidebar-dropdown.tsx index fef4a8fee..5a892e069 100644 --- a/apps/app/components/workspace/sidebar-dropdown.tsx +++ b/apps/app/components/workspace/sidebar-dropdown.tsx @@ -155,7 +155,8 @@ export const WorkspaceSidebarDropdown = () => {
{workspace.name}
- {workspace.total_members} members + {workspace.total_members}{" "} + {workspace.total_members > 1 ? "members" : "member"}
diff --git a/apps/app/layouts/app-layout/app-header.tsx b/apps/app/layouts/app-layout/app-header.tsx index 4bafcc544..439db92ba 100644 --- a/apps/app/layouts/app-layout/app-header.tsx +++ b/apps/app/layouts/app-layout/app-header.tsx @@ -10,28 +10,24 @@ type Props = { setToggleSidebar: React.Dispatch>; }; -const Header: React.FC = ({ breadcrumbs, left, right, setToggleSidebar }) => { - return ( - <> -
-
-
- -
- {breadcrumbs} - {left} -
- {right} +const Header: React.FC = ({ breadcrumbs, left, right, setToggleSidebar }) => ( +
+
+
+
- - ); -}; + {breadcrumbs} + {left} +
+ {right} +
+); export default Header; diff --git a/apps/app/layouts/app-layout/app-sidebar.tsx b/apps/app/layouts/app-layout/app-sidebar.tsx index 48370636e..5a58384a6 100644 --- a/apps/app/layouts/app-layout/app-sidebar.tsx +++ b/apps/app/layouts/app-layout/app-sidebar.tsx @@ -1,5 +1,3 @@ -import { Dispatch, SetStateAction } from "react"; - // hooks import useTheme from "hooks/use-theme"; // components diff --git a/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx b/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx index f4512a985..1438a6831 100644 --- a/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx +++ b/apps/app/pages/[workspaceSlug]/projects/[projectId]/cycles/[cycleId].tsx @@ -10,13 +10,6 @@ import { requiredAdmin, requiredAuth } from "lib/auth"; import AppLayout from "layouts/app-layout"; // contexts import { IssueViewContextProvider } from "contexts/issue-view.context"; -// icons -import { - ArrowLeftIcon, - ArrowPathIcon, - ListBulletIcon, - PlusIcon, -} from "@heroicons/react/24/outline"; // components import CyclesListView from "components/project/cycles/list-view"; import CyclesBoardView from "components/project/cycles/board-view"; @@ -33,6 +26,8 @@ import projectService from "services/project.service"; import { CustomMenu, EmptySpace, EmptySpaceItem, Spinner } from "components/ui"; import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs"; // icons +import { ArrowLeftIcon, ListBulletIcon, PlusIcon } from "@heroicons/react/24/outline"; +import { CyclesIcon } from "components/icons"; // types import { CycleIssueResponse, IIssue, SelectIssue, UserAuth } from "types"; import { NextPageContext } from "next"; @@ -203,7 +198,7 @@ const SingleCycle: React.FC = (props) => { - + {cycles?.find((c) => c.id === cycleId)?.name} } @@ -268,7 +263,7 @@ const SingleCycle: React.FC = (props) => { { .then((res) => { mutate(SUB_ISSUES(issueDetails?.id ?? "")); mutateIssueActivities(); + + mutate( + PROJECT_ISSUES_LIST(workspaceSlug as string, projectId as string), + (prevData) => ({ + ...(prevData as IssueResponse), + results: (prevData?.results ?? []).map((p) => { + if (p.id === res.id) + return { + ...p, + ...res, + }; + + return p; + }), + }), + false + ); }) .catch((e) => { console.error(e); diff --git a/apps/app/pages/[workspaceSlug]/settings/index.tsx b/apps/app/pages/[workspaceSlug]/settings/index.tsx index 4d7c53dce..a3cc32903 100644 --- a/apps/app/pages/[workspaceSlug]/settings/index.tsx +++ b/apps/app/pages/[workspaceSlug]/settings/index.tsx @@ -3,6 +3,7 @@ import React, { useEffect, useState } from "react"; import Image from "next/image"; import { useRouter } from "next/router"; import useSWR, { mutate } from "swr"; + // react-hook-form import { Controller, useForm } from "react-hook-form"; // react-dropzone diff --git a/apps/app/styles/editor.css b/apps/app/styles/editor.css index 07fcec355..45deb0dc6 100644 --- a/apps/app/styles/editor.css +++ b/apps/app/styles/editor.css @@ -354,6 +354,10 @@ img.ProseMirror-separator { margin-bottom: 1em; } +.remirror-editor-wrapper .remirror-editor { + min-height: 150px; +} + .issue-comments-section .remirror-editor-wrapper .remirror-editor { min-height: 50px; }