From f93803ace8065aba18467f8b607bc413fb2fe67a Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Mon, 10 Jun 2024 14:18:30 +0530 Subject: [PATCH] Fix app directory migration bugs (#4745) Co-authored-by: Satish Gandham --- .../projects/[projectId]/inbox/page.tsx | 6 +- web/components/headers/page-details.tsx | 169 ------------------ .../properties/all-properties.tsx | 9 +- web/components/issues/issue-modal/form.tsx | 15 -- 4 files changed, 8 insertions(+), 191 deletions(-) delete mode 100644 web/components/headers/page-details.tsx diff --git a/web/app/[workspaceSlug]/projects/[projectId]/inbox/page.tsx b/web/app/[workspaceSlug]/projects/[projectId]/inbox/page.tsx index 596de85b2..0a2ecd17d 100644 --- a/web/app/[workspaceSlug]/projects/[projectId]/inbox/page.tsx +++ b/web/app/[workspaceSlug]/projects/[projectId]/inbox/page.tsx @@ -1,8 +1,7 @@ "use client"; - import { observer } from "mobx-react"; -import { useParams, useSearchParams } from "next/navigation"; // components +import { useParams, useSearchParams } from "next/navigation"; import { PageHead } from "@/components/core"; import { EmptyState } from "@/components/empty-state"; import { InboxIssueRoot } from "@/components/inbox"; @@ -16,9 +15,12 @@ import { useProject } from "@/hooks/store"; const ProjectInboxPage = observer(() => { /// router const { workspaceSlug, projectId } = useParams(); + const searchParams = useSearchParams(); + const navigationTab = searchParams.get("currentTab"); const inboxIssueId = searchParams.get("inboxIssueId"); + // hooks const { currentProjectDetails } = useProject(); diff --git a/web/components/headers/page-details.tsx b/web/components/headers/page-details.tsx deleted file mode 100644 index 94ecd9957..000000000 --- a/web/components/headers/page-details.tsx +++ /dev/null @@ -1,169 +0,0 @@ -import { useState } from "react"; -import { observer } from "mobx-react"; -import { useRouter } from "next/router"; -import { FileText } from "lucide-react"; -// types -import { TLogoProps } from "@plane/types"; -// ui -import { Breadcrumbs, Button, EmojiIconPicker, EmojiIconPickerTypes, TOAST_TYPE, setToast } from "@plane/ui"; -// components -import { BreadcrumbLink, Logo } from "@/components/common"; -// helper -import { convertHexEmojiToDecimal } from "@/helpers/emoji.helper"; -// hooks -import { usePage, useProject } from "@/hooks/store"; -import { usePlatformOS } from "@/hooks/use-platform-os"; - -export interface IPagesHeaderProps { - showButton?: boolean; -} - -export const PageDetailsHeader = observer(() => { - // router - const router = useRouter(); - const { workspaceSlug, pageId } = router.query; - // state - const [isOpen, setIsOpen] = useState(false); - // store hooks - const { currentProjectDetails } = useProject(); - const { isContentEditable, isSubmitting, name, logo_props, updatePageLogo } = usePage(pageId?.toString() ?? ""); - - const handlePageLogoUpdate = async (data: TLogoProps) => { - if (data) { - updatePageLogo(data) - .then(() => { - setToast({ - type: TOAST_TYPE.SUCCESS, - title: "Success!", - message: "Logo Updated successfully.", - }); - }) - .catch(() => { - setToast({ - type: TOAST_TYPE.ERROR, - title: "Error!", - message: "Something went wrong. Please try again.", - }); - }); - } - }; - // use platform - const { platform } = usePlatformOS(); - // derived values - const isMac = platform === "MacOS"; - - return ( -
-
-
- - - - - - - ) - } - /> - - - - - - } - /> - - } - /> - } - /> - setIsOpen(val)} - className="flex items-center justify-center" - buttonClassName="flex items-center justify-center" - label={ - <> - {logo_props?.in_use ? ( - - ) : ( - - )} - - } - onChange={(val) => { - let logoValue = {}; - - if (val?.type === "emoji") - logoValue = { - value: convertHexEmojiToDecimal(val.value.unified), - url: val.value.imageUrl, - }; - else if (val?.type === "icon") logoValue = val.value; - - handlePageLogoUpdate({ - in_use: val?.type, - [val?.type]: logoValue, - }).finally(() => setIsOpen(false)); - }} - defaultIconColor={ - logo_props?.in_use && logo_props.in_use === "icon" ? logo_props?.icon?.color : undefined - } - defaultOpen={ - logo_props?.in_use && logo_props?.in_use === "emoji" - ? EmojiIconPickerTypes.EMOJI - : EmojiIconPickerTypes.ICON - } - /> - } - /> - } - /> - -
-
- {isContentEditable && ( - - )} -
- ); -}); diff --git a/web/components/issues/issue-layouts/properties/all-properties.tsx b/web/components/issues/issue-layouts/properties/all-properties.tsx index d79161ea6..ce72c7647 100644 --- a/web/components/issues/issue-layouts/properties/all-properties.tsx +++ b/web/components/issues/issue-layouts/properties/all-properties.tsx @@ -44,7 +44,9 @@ export interface IIssueProperties { export const IssueProperties: React.FC = observer((props) => { // router const router = useRouter(); - const { workspaceSlug, projectId } = router.query; + const { workspaceSlug, projectId } = useParams(); + const pathname = usePathname(); + const { issue, updateIssue, displayProperties, activeLayout, isReadOnly, className } = props; // store hooks const { getProjectById } = useProject(); @@ -60,10 +62,7 @@ export const IssueProperties: React.FC = observer((props) => { const { getStateById } = useProjectState(); const { isMobile } = usePlatformOS(); const projectDetails = getProjectById(issue.project_id); - // router - const router = useRouter(); - const { workspaceSlug } = useParams(); - const pathname = usePathname(); + const currentLayout = `${activeLayout} layout`; // derived values const stateDetails = getStateById(issue.state_id); diff --git a/web/components/issues/issue-modal/form.tsx b/web/components/issues/issue-modal/form.tsx index 0fe6f1610..9b0f1deab 100644 --- a/web/components/issues/issue-modal/form.tsx +++ b/web/components/issues/issue-modal/form.tsx @@ -145,21 +145,6 @@ export const IssueFormRoot: FC = observer((props) => { useKeypress("Escape", handleKeyDown); - const handleKeyDown = (event: KeyboardEvent) => { - if (editorRef.current?.isEditorReadyToDiscard()) { - onClose(); - } else { - setToast({ - type: TOAST_TYPE.ERROR, - title: "Error!", - message: "Editor is still processing changes. Please wait before proceeding.", - }); - event.preventDefault(); // Prevent default action if editor is not ready to discard - } - }; - - useKeypress("Escape", handleKeyDown); - const { issue: { getIssueById }, } = useIssueDetail();