diff --git a/apps/app/components/issues/comment/add-comment.tsx b/apps/app/components/issues/comment/add-comment.tsx index 4d64a90ba..33d7f2289 100644 --- a/apps/app/components/issues/comment/add-comment.tsx +++ b/apps/app/components/issues/comment/add-comment.tsx @@ -3,38 +3,55 @@ import { useRouter } from "next/router"; // react-hook-form import { useForm, Controller } from "react-hook-form"; // components -import { SecondaryButton } from "components/ui"; import { TipTapEditor } from "components/tiptap"; +// ui +import { Icon, SecondaryButton, Tooltip } from "components/ui"; // types import type { IIssueComment } from "types"; const defaultValues: Partial = { - comment_json: "", + access: "INTERNAL", comment_html: "", }; type Props = { disabled?: boolean; onSubmit: (data: IIssueComment) => Promise; + showAccessSpecifier?: boolean; }; -export const AddComment: React.FC = ({ disabled = false, onSubmit }) => { - const { - control, - formState: { isSubmitting }, - handleSubmit, - reset, - setValue, - watch, - } = useForm({ defaultValues }); +const commentAccess = [ + { + icon: "lock", + key: "INTERNAL", + label: "Private", + }, + { + icon: "public", + key: "EXTERNAL", + label: "Public", + }, +]; +export const AddComment: React.FC = ({ + disabled = false, + onSubmit, + showAccessSpecifier = false, +}) => { const editorRef = React.useRef(null); const router = useRouter(); const { workspaceSlug } = router.query; + const { + control, + formState: { isSubmitting }, + handleSubmit, + reset, + } = useForm({ defaultValues }); + const handleAddComment = async (formData: IIssueComment) => { - if (!formData.comment_html || !formData.comment_json || isSubmitting) return; + if (!formData.comment_html || isSubmitting) return; await onSubmit(formData).then(() => { reset(defaultValues); @@ -45,30 +62,55 @@ export const AddComment: React.FC = ({ disabled = false, onSubmit }) => { return (
-
- ( - { - onChange(comment_html); - setValue("comment_json", comment_json); - }} - /> +
+
+ {showAccessSpecifier && ( +
+ ( +
+ {commentAccess.map((access) => ( + + + + ))} +
+ )} + /> +
)} - /> + ( +

" : value} + customClassName="p-3 min-h-[100px] shadow-sm" + debouncedUpdatesEnabled={false} + onChange={(comment_json: Object, comment_html: string) => onChange(comment_html)} + /> + )} + /> +
{isSubmitting ? "Adding..." : "Comment"} diff --git a/apps/app/components/issues/main-content.tsx b/apps/app/components/issues/main-content.tsx index ed559beb7..bab384523 100644 --- a/apps/app/components/issues/main-content.tsx +++ b/apps/app/components/issues/main-content.tsx @@ -8,6 +8,7 @@ import issuesService from "services/issues.service"; // hooks import useUserAuth from "hooks/use-user-auth"; import useToast from "hooks/use-toast"; +import useProjectDetails from "hooks/use-project-details"; // contexts import { useProjectMyMembership } from "contexts/project-member.context"; // components @@ -49,6 +50,8 @@ export const IssueMainContent: React.FC = ({ const { user } = useUserAuth(); const { memberRole } = useProjectMyMembership(); + const { projectDetails } = useProjectDetails(); + const { data: siblingIssues } = useSWR( workspaceSlug && projectId && issueDetails?.parent ? SUB_ISSUES(issueDetails.parent) : null, workspaceSlug && projectId && issueDetails?.parent @@ -220,7 +223,11 @@ export const IssueMainContent: React.FC = ({ handleCommentUpdate={handleCommentUpdate} handleCommentDelete={handleCommentDelete} /> - +
); diff --git a/apps/app/services/issues.service.ts b/apps/app/services/issues.service.ts index 53c6c1a2d..b8875e6c5 100644 --- a/apps/app/services/issues.service.ts +++ b/apps/app/services/issues.service.ts @@ -182,7 +182,7 @@ class ProjectIssuesServices extends APIService { workspaceSlug: string, projectId: string, issueId: string, - data: any, + data: Partial, user: ICurrentUserResponse | undefined ): Promise { return this.post( @@ -468,20 +468,18 @@ class ProjectIssuesServices extends APIService { metadata: any; title: string; url: string; - }, - + } ): Promise { return this.patch( `/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/issue-links/${linkId}/`, data ) - .then((response) => response?.data) - .catch((error) => { - throw error?.response; - }); + .then((response) => response?.data) + .catch((error) => { + throw error?.response; + }); } - async deleteIssueLink( workspaceSlug: string, projectId: string, diff --git a/apps/app/types/issues.d.ts b/apps/app/types/issues.d.ts index 98d72041a..93e1598f3 100644 --- a/apps/app/types/issues.d.ts +++ b/apps/app/types/issues.d.ts @@ -198,6 +198,7 @@ export interface IIssueActivity { } export interface IIssueComment extends IIssueActivity { + access: "EXTERNAL" | "INTERNAL"; comment_html: string; comment_json: any; comment_stripped: string; diff --git a/apps/app/types/projects.d.ts b/apps/app/types/projects.d.ts index a3d8b997a..78ef4d953 100644 --- a/apps/app/types/projects.d.ts +++ b/apps/app/types/projects.d.ts @@ -39,6 +39,7 @@ export interface IProject { } | null; id: string; identifier: string; + is_deployed: boolean; is_favorite: boolean; is_member: boolean; member_role: 5 | 10 | 15 | 20 | null; @@ -57,7 +58,6 @@ export interface IProject { updated_by: string; workspace: IWorkspace | string; workspace_detail: IWorkspaceLite; - is_deployed: boolean; } export interface IProjectLite {