From fa01dfc652fcc7ea7767e6c850f99da2a37b4255 Mon Sep 17 00:00:00 2001 From: Palanikannan1437 <73993394+Palanikannan1437@users.noreply.github.com> Date: Fri, 22 Sep 2023 16:45:09 +0530 Subject: [PATCH] migrated all components to use the common package --- .../issues/peek-overview/comment/add-comment.tsx | 8 ++++++-- .../peek-overview/comment/comment-detail-card.tsx | 13 ++++++++++--- .../issues/peek-overview/issue-details.tsx | 8 ++++++-- space/package.json | 3 ++- space/services/file.service.ts | 8 +++++--- .../core/modals/gpt-assistant-modal.tsx | 15 +++++++++++---- web/components/core/modals/image-upload-modal.tsx | 10 +++++----- web/components/issues/comment/add-comment.tsx | 8 ++++++-- web/components/issues/comment/comment-card.tsx | 12 +++++++++--- web/components/issues/draft-issue-form.tsx | 9 +++++++-- web/components/issues/form.tsx | 10 ++++++++-- .../pages/create-update-block-inline.tsx | 12 +++++++++--- web/components/pages/single-page-block.tsx | 7 +++++-- web/components/tiptap/index.tsx | 2 +- web/components/web-view/issue-web-view-form.tsx | 8 ++++++-- web/pages/[workspaceSlug]/editor.tsx | 7 +++++-- web/pages/[workspaceSlug]/me/profile/activity.tsx | 2 +- web/pages/m/[workspaceSlug]/editor.tsx | 8 ++++++-- web/services/file.service.ts | 6 ++++-- 19 files changed, 112 insertions(+), 44 deletions(-) diff --git a/space/components/issues/peek-overview/comment/add-comment.tsx b/space/components/issues/peek-overview/comment/add-comment.tsx index 3ea4308d7..7869667d2 100644 --- a/space/components/issues/peek-overview/comment/add-comment.tsx +++ b/space/components/issues/peek-overview/comment/add-comment.tsx @@ -11,7 +11,9 @@ import { SecondaryButton } from "components/ui"; // types import { Comment } from "types/issue"; // components -import { TipTapEditor } from "components/tiptap"; +import { TiptapEditorWithRef } from "@plane/editor"; +// service +import fileService from "@/services/file.service"; const defaultValues: Partial = { comment_html: "", @@ -69,7 +71,9 @@ export const AddComment: React.FC = observer((props) => { name="comment_html" control={control} render={({ field: { value, onChange } }) => ( - = observer((props) => { control={control} name="comment_html" render={({ field: { onChange, value } }) => ( - = observer((props) => {
- = ({ issueDetails }) => {

{issueDetails.name}

{issueDetails.description_html !== "" && issueDetails.description_html !== "

" && ( - { @@ -94,6 +96,6 @@ class FileServices extends APIService { } } -const fileServices = new FileServices(); +const fileService = new FileService(); -export default fileServices; +export default fileService; diff --git a/web/components/core/modals/gpt-assistant-modal.tsx b/web/components/core/modals/gpt-assistant-modal.tsx index 81c9b7d71..8c5895f39 100644 --- a/web/components/core/modals/gpt-assistant-modal.tsx +++ b/web/components/core/modals/gpt-assistant-modal.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState, forwardRef, useRef } from "react"; +import React, { useEffect, useState, useRef } from "react"; import { useRouter } from "next/router"; // react-hook-form import { useForm } from "react-hook-form"; @@ -10,9 +10,12 @@ import useToast from "hooks/use-toast"; import useUserAuth from "hooks/use-user-auth"; // ui import { Input, PrimaryButton, SecondaryButton } from "components/ui"; -import { TipTapEditor } from "components/tiptap"; +// components +import { TiptapEditor, TiptapEditorWithRef } from "@plane/editor"; // types import { IIssue, IPageBlock } from "types"; +// services +import fileService from "@/services/file.service"; type Props = { isOpen: boolean; @@ -140,7 +143,9 @@ export const GptAssistantModal: React.FC = ({ {((content && content !== "") || (htmlContent && htmlContent !== "

")) && (
Content: - ${content}

`} customClassName="-m-3" @@ -154,7 +159,9 @@ export const GptAssistantModal: React.FC = ({ {response !== "" && (
Response: - ${response}

`} customClassName="-mx-3 -my-3" diff --git a/web/components/core/modals/image-upload-modal.tsx b/web/components/core/modals/image-upload-modal.tsx index df4f21e12..e1795ed04 100644 --- a/web/components/core/modals/image-upload-modal.tsx +++ b/web/components/core/modals/image-upload-modal.tsx @@ -7,7 +7,7 @@ import { useDropzone } from "react-dropzone"; // headless ui import { Transition, Dialog } from "@headlessui/react"; // services -import fileServices from "services/file.service"; +import fileService from "services/file.service"; // hooks import useWorkspaceDetails from "hooks/use-workspace-details"; // ui @@ -64,7 +64,7 @@ export const ImageUploadModal: React.FC = ({ formData.append("attributes", JSON.stringify({})); if (userImage) { - fileServices + fileService .uploadUserFile(formData) .then((res) => { const imageUrl = res.asset; @@ -73,13 +73,13 @@ export const ImageUploadModal: React.FC = ({ setIsImageUploading(false); setImage(null); - if (value) fileServices.deleteUserFile(value); + if (value) fileService.deleteUserFile(value); }) .catch((err) => { console.error(err); }); } else - fileServices + fileService .uploadFile(workspaceSlug as string, formData) .then((res) => { const imageUrl = res.asset; @@ -87,7 +87,7 @@ export const ImageUploadModal: React.FC = ({ setIsImageUploading(false); setImage(null); - if (value && workspaceDetails) fileServices.deleteFile(workspaceDetails.id, value); + if (value && workspaceDetails) fileService.deleteFile(workspaceDetails.id, value); }) .catch((err) => { console.error(err); diff --git a/web/components/issues/comment/add-comment.tsx b/web/components/issues/comment/add-comment.tsx index 33d7f2289..ef1d4cec7 100644 --- a/web/components/issues/comment/add-comment.tsx +++ b/web/components/issues/comment/add-comment.tsx @@ -3,11 +3,13 @@ import { useRouter } from "next/router"; // react-hook-form import { useForm, Controller } from "react-hook-form"; // components -import { TipTapEditor } from "components/tiptap"; +import { TiptapEditorWithRef } from "@plane/editor"; // ui import { Icon, SecondaryButton, Tooltip } from "components/ui"; // types import type { IIssueComment } from "types"; +// services +import fileService from "@/services/file.service"; const defaultValues: Partial = { access: "INTERNAL", @@ -100,7 +102,9 @@ export const AddComment: React.FC = ({ name="comment_html" control={control} render={({ field: { value, onChange } }) => ( -

" : value} diff --git a/web/components/issues/comment/comment-card.tsx b/web/components/issues/comment/comment-card.tsx index 3d3e43b39..19cc0fe7e 100644 --- a/web/components/issues/comment/comment-card.tsx +++ b/web/components/issues/comment/comment-card.tsx @@ -9,11 +9,13 @@ import useUser from "hooks/use-user"; // ui import { CustomMenu, Icon } from "components/ui"; import { CommentReaction } from "components/issues"; -import { TipTapEditor } from "components/tiptap"; +import { TiptapEditorWithRef } from "@plane/editor"; // helpers import { timeAgo } from "helpers/date-time.helper"; // types import type { IIssueComment } from "types"; +// services +import fileService from "@/services/file.service"; type Props = { comment: IIssueComment; @@ -110,7 +112,9 @@ export const CommentCard: React.FC = ({ onSubmit={handleSubmit(onEnter)} >
- = ({ />
)} - = { project: "", @@ -381,7 +384,9 @@ export const DraftIssueForm: FC = (props) => { if (!value && !watch("description_html")) return <>; return ( - = { project: "", @@ -380,7 +384,9 @@ export const IssueForm: FC = (props) => { if (!value && !watch("description_html")) return <>; return ( - void; @@ -279,7 +281,9 @@ export const CreateUpdateBlockInline: React.FC = ({ render={({ field: { value, onChange } }) => { if (!data) return ( -

"} @@ -299,7 +303,9 @@ export const CreateUpdateBlockInline: React.FC = ({ ); return ( - = ({ {showBlockDetails ? block.description_html.length > 7 && ( - = (props) => { if (!value) return <>; return ( - { const [user, setUser] = useState(); @@ -134,7 +135,9 @@ const Editor: NextPage = () => { name="description_html" control={control} render={({ field: { value, onChange } }) => ( - { diff --git a/web/pages/m/[workspaceSlug]/editor.tsx b/web/pages/m/[workspaceSlug]/editor.tsx index 2bfac63b8..abf681f1a 100644 --- a/web/pages/m/[workspaceSlug]/editor.tsx +++ b/web/pages/m/[workspaceSlug]/editor.tsx @@ -14,8 +14,10 @@ import { Controller, useForm } from "react-hook-form"; import WebViewLayout from "layouts/web-view-layout"; // components -import { TipTapEditor } from "components/tiptap"; +import { TiptapEditor } from "@plane/editor"; import { PrimaryButton, Spinner } from "components/ui"; +// services +import fileService from "@/services/file.service"; const Editor: NextPage = () => { const [isLoading, setIsLoading] = useState(false); @@ -52,7 +54,9 @@ const Editor: NextPage = () => { name="data_html" control={control} render={({ field: { value, onChange } }) => ( -