refactor: issue peek overview (#3001)
* refactor: peek overview components * fix: issue reactions * chore: update comment types * fix: access sepcifier value * chore: remove unused vars * fix: build errors * build-error: build error resolved --------- Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com>
This commit is contained in:
parent
c455f03ced
commit
539c7a3455
55 changed files with 526 additions and 455 deletions
|
|
@ -11,12 +11,12 @@ import { Loader, Tooltip } from "@plane/ui";
|
|||
// helpers
|
||||
import { render24HourFormatTime, renderLongDateFormat, timeAgo } from "helpers/date-time.helper";
|
||||
// types
|
||||
import { IIssueActivity, IIssueComment } from "types";
|
||||
import { IIssueActivity } from "types";
|
||||
import { History } from "lucide-react";
|
||||
|
||||
type Props = {
|
||||
activity: IIssueActivity[] | undefined;
|
||||
handleCommentUpdate: (commentId: string, data: Partial<IIssueComment>) => Promise<void>;
|
||||
handleCommentUpdate: (commentId: string, data: Partial<IIssueActivity>) => Promise<void>;
|
||||
handleCommentDelete: (commentId: string) => Promise<void>;
|
||||
showAccessSpecifier?: boolean;
|
||||
};
|
||||
|
|
@ -130,7 +130,7 @@ export const IssueActivitySection: React.FC<Props> = ({
|
|||
return (
|
||||
<div key={activityItem.id} className="mt-4">
|
||||
<CommentCard
|
||||
comment={activityItem as IIssueComment}
|
||||
comment={activityItem as IIssueActivity}
|
||||
handleCommentDeletion={handleCommentDelete}
|
||||
onSubmit={handleCommentUpdate}
|
||||
showAccessSpecifier={showAccessSpecifier}
|
||||
|
|
|
|||
|
|
@ -11,17 +11,17 @@ import { Button } from "@plane/ui";
|
|||
import { Globe2, Lock } from "lucide-react";
|
||||
|
||||
// types
|
||||
import type { IIssueComment } from "types";
|
||||
import type { IIssueActivity } from "types";
|
||||
import useEditorSuggestions from "hooks/use-editor-suggestions";
|
||||
|
||||
const defaultValues: Partial<IIssueComment> = {
|
||||
const defaultValues: Partial<IIssueActivity> = {
|
||||
access: "INTERNAL",
|
||||
comment_html: "",
|
||||
};
|
||||
|
||||
type Props = {
|
||||
disabled?: boolean;
|
||||
onSubmit: (data: IIssueComment) => Promise<void>;
|
||||
onSubmit: (data: IIssueActivity) => Promise<void>;
|
||||
showAccessSpecifier?: boolean;
|
||||
};
|
||||
|
||||
|
|
@ -59,9 +59,9 @@ export const AddComment: React.FC<Props> = ({ disabled = false, onSubmit, showAc
|
|||
formState: { isSubmitting },
|
||||
handleSubmit,
|
||||
reset,
|
||||
} = useForm<IIssueComment>({ defaultValues });
|
||||
} = useForm<IIssueActivity>({ defaultValues });
|
||||
|
||||
const handleAddComment = async (formData: IIssueComment) => {
|
||||
const handleAddComment = async (formData: IIssueActivity) => {
|
||||
if (!formData.comment_html || isSubmitting) return;
|
||||
|
||||
await onSubmit(formData).then(() => {
|
||||
|
|
@ -96,7 +96,7 @@ export const AddComment: React.FC<Props> = ({ disabled = false, onSubmit, showAc
|
|||
onChange={(comment_json: Object, comment_html: string) => onCommentChange(comment_html)}
|
||||
commentAccessSpecifier={
|
||||
showAccessSpecifier
|
||||
? { accessValue, onAccessChange, showAccessSpecifier, commentAccess }
|
||||
? { accessValue: accessValue ?? "INTERNAL", onAccessChange, showAccessSpecifier, commentAccess }
|
||||
: undefined
|
||||
}
|
||||
mentionSuggestions={editorSuggestions.mentionSuggestions}
|
||||
|
|
|
|||
|
|
@ -14,16 +14,16 @@ import { LiteTextEditorWithRef, LiteReadOnlyEditorWithRef } from "@plane/lite-te
|
|||
// helpers
|
||||
import { timeAgo } from "helpers/date-time.helper";
|
||||
// types
|
||||
import type { IIssueComment } from "types";
|
||||
import type { IIssueActivity } from "types";
|
||||
import useEditorSuggestions from "hooks/use-editor-suggestions";
|
||||
|
||||
// services
|
||||
const fileService = new FileService();
|
||||
|
||||
type Props = {
|
||||
comment: IIssueComment;
|
||||
comment: IIssueActivity;
|
||||
handleCommentDeletion: (comment: string) => void;
|
||||
onSubmit: (commentId: string, data: Partial<IIssueComment>) => void;
|
||||
onSubmit: (commentId: string, data: Partial<IIssueActivity>) => void;
|
||||
showAccessSpecifier?: boolean;
|
||||
workspaceSlug: string;
|
||||
};
|
||||
|
|
@ -50,11 +50,11 @@ export const CommentCard: React.FC<Props> = ({
|
|||
setFocus,
|
||||
watch,
|
||||
setValue,
|
||||
} = useForm<IIssueComment>({
|
||||
} = useForm<IIssueActivity>({
|
||||
defaultValues: comment,
|
||||
});
|
||||
|
||||
const onEnter = (formData: Partial<IIssueComment>) => {
|
||||
const onEnter = (formData: Partial<IIssueActivity>) => {
|
||||
if (isSubmitting) return;
|
||||
setIsEditing(false);
|
||||
|
||||
|
|
@ -110,13 +110,10 @@ export const CommentCard: React.FC<Props> = ({
|
|||
deleteFile={fileService.deleteImage}
|
||||
restoreFile={fileService.restoreImage}
|
||||
ref={editorRef}
|
||||
value={watch("comment_html")}
|
||||
value={watch("comment_html") ?? ""}
|
||||
debouncedUpdatesEnabled={false}
|
||||
customClassName="min-h-[50px] p-3 shadow-sm"
|
||||
onChange={(comment_json: Object, comment_html: string) => {
|
||||
setValue("comment_json", comment_json);
|
||||
setValue("comment_html", comment_html);
|
||||
}}
|
||||
onChange={(comment_json: Object, comment_html: string) => setValue("comment_html", comment_html)}
|
||||
mentionSuggestions={editorSuggestions.mentionSuggestions}
|
||||
mentionHighlights={editorSuggestions.mentionHighlights}
|
||||
/>
|
||||
|
|
@ -147,7 +144,7 @@ export const CommentCard: React.FC<Props> = ({
|
|||
)}
|
||||
<LiteReadOnlyEditorWithRef
|
||||
ref={showEditorRef}
|
||||
value={comment.comment_html}
|
||||
value={comment.comment_html ?? ""}
|
||||
customClassName="text-xs border border-custom-border-200 bg-custom-background-100"
|
||||
mentionHighlights={editorSuggestions.mentionHighlights}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { Dialog, Transition } from "@headlessui/react";
|
|||
// mobx store
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
// services
|
||||
import { IssueService, IssueDraftService } from "services/issue";
|
||||
import { IssueService } from "services/issue";
|
||||
import { ModuleService } from "services/module.service";
|
||||
// hooks
|
||||
import useToast from "hooks/use-toast";
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export * from "./delete-issue-modal";
|
|||
export * from "./description-form";
|
||||
export * from "./form";
|
||||
export * from "./issue-layouts";
|
||||
export * from "./issue-peek-overview";
|
||||
export * from "./peek-overview";
|
||||
export * from "./main-content";
|
||||
export * from "./modal";
|
||||
export * from "./parent-issues-list-modal";
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ interface IBaseCalendarRoot {
|
|||
calendarViewStore: IIssueCalendarViewStore;
|
||||
QuickActions: FC<IQuickActionProps>;
|
||||
issueActions: {
|
||||
[EIssueActions.DELETE]: (issue: IIssue) => void;
|
||||
[EIssueActions.UPDATE]?: (issue: IIssue) => void;
|
||||
[EIssueActions.REMOVE]?: (issue: IIssue) => void;
|
||||
[EIssueActions.DELETE]: (issue: IIssue) => Promise<void>;
|
||||
[EIssueActions.UPDATE]?: (issue: IIssue) => Promise<void>;
|
||||
[EIssueActions.REMOVE]?: (issue: IIssue) => Promise<void>;
|
||||
};
|
||||
viewId?: string;
|
||||
handleDragDrop: (source: any, destination: any, issues: any, issueWithIds: any) => void;
|
||||
|
|
@ -64,9 +64,9 @@ export const BaseCalendarRoot = observer((props: IBaseCalendarRoot) => {
|
|||
};
|
||||
|
||||
const handleIssues = useCallback(
|
||||
(date: string, issue: IIssue, action: EIssueActions) => {
|
||||
async (date: string, issue: IIssue, action: EIssueActions) => {
|
||||
if (issueActions[action]) {
|
||||
issueActions[action]!(issue);
|
||||
await issueActions[action]!(issue);
|
||||
}
|
||||
},
|
||||
[issueActions]
|
||||
|
|
@ -108,8 +108,8 @@ export const BaseCalendarRoot = observer((props: IBaseCalendarRoot) => {
|
|||
workspaceSlug={workspaceSlug.toString()}
|
||||
projectId={peekProjectId.toString()}
|
||||
issueId={peekIssueId.toString()}
|
||||
handleIssue={(issueToUpdate) =>
|
||||
handleIssues(issueToUpdate.target_date ?? "", issueToUpdate as IIssue, EIssueActions.UPDATE)
|
||||
handleIssue={async (issueToUpdate) =>
|
||||
await handleIssues(issueToUpdate.target_date ?? "", issueToUpdate as IIssue, EIssueActions.UPDATE)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -14,46 +14,50 @@ export const CycleCalendarLayout: React.FC = observer(() => {
|
|||
cycleIssues: cycleIssueStore,
|
||||
cycleIssuesFilter: cycleIssueFilterStore,
|
||||
cycleIssueCalendarView: cycleIssueCalendarViewStore,
|
||||
calendarHelpers: calendarHelperStore,
|
||||
calendarHelpers: { handleDragDrop: handleCalenderDragDrop },
|
||||
} = useMobxStore();
|
||||
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId, cycleId } = router.query as {
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
cycleId: string;
|
||||
};
|
||||
const { workspaceSlug, projectId, cycleId } = router.query;
|
||||
|
||||
const issueActions = {
|
||||
[EIssueActions.UPDATE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug || !cycleId) return;
|
||||
|
||||
cycleIssueStore.updateIssue(workspaceSlug, issue.project, issue.id, issue, cycleId);
|
||||
await cycleIssueStore.updateIssue(workspaceSlug.toString(), issue.project, issue.id, issue, cycleId.toString());
|
||||
},
|
||||
[EIssueActions.DELETE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug || !cycleId) return;
|
||||
cycleIssueStore.removeIssue(workspaceSlug, issue.project, issue.id, cycleId);
|
||||
await cycleIssueStore.removeIssue(workspaceSlug.toString(), issue.project, issue.id, cycleId.toString());
|
||||
},
|
||||
[EIssueActions.REMOVE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug || !cycleId || !issue.bridge_id) return;
|
||||
cycleIssueStore.removeIssueFromCycle(workspaceSlug, issue.project, cycleId, issue.id, issue.bridge_id);
|
||||
if (!workspaceSlug || !cycleId || !projectId || !issue.bridge_id) return;
|
||||
await cycleIssueStore.removeIssueFromCycle(
|
||||
workspaceSlug.toString(),
|
||||
issue.project,
|
||||
cycleId.toString(),
|
||||
issue.id,
|
||||
issue.bridge_id
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
const handleDragDrop = (source: any, destination: any, issues: IIssue[], issueWithIds: any) => {
|
||||
if (calendarHelperStore.handleDragDrop)
|
||||
calendarHelperStore.handleDragDrop(
|
||||
if (workspaceSlug && projectId && cycleId)
|
||||
handleCalenderDragDrop(
|
||||
source,
|
||||
destination,
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
cycleIssueStore,
|
||||
issues,
|
||||
issueWithIds,
|
||||
cycleId
|
||||
cycleId.toString()
|
||||
);
|
||||
};
|
||||
|
||||
if (!cycleId) return null;
|
||||
|
||||
return (
|
||||
<BaseCalendarRoot
|
||||
issueStore={cycleIssueStore}
|
||||
|
|
@ -61,7 +65,7 @@ export const CycleCalendarLayout: React.FC = observer(() => {
|
|||
calendarViewStore={cycleIssueCalendarViewStore}
|
||||
QuickActions={CycleIssueQuickActions}
|
||||
issueActions={issueActions}
|
||||
viewId={cycleId}
|
||||
viewId={cycleId.toString()}
|
||||
handleDragDrop={handleDragDrop}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export const ModuleCalendarLayout: React.FC = observer(() => {
|
|||
moduleIssues: moduleIssueStore,
|
||||
moduleIssuesFilter: moduleIssueFilterStore,
|
||||
moduleIssueCalendarView: moduleIssueCalendarViewStore,
|
||||
calendarHelpers: calendarHelperStore,
|
||||
calendarHelpers: { handleDragDrop: handleCalenderDragDrop },
|
||||
} = useMobxStore();
|
||||
|
||||
const router = useRouter();
|
||||
|
|
@ -25,32 +25,31 @@ export const ModuleCalendarLayout: React.FC = observer(() => {
|
|||
};
|
||||
|
||||
const issueActions = {
|
||||
[EIssueActions.UPDATE]: (issue: IIssue) => {
|
||||
[EIssueActions.UPDATE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug || !moduleId) return;
|
||||
moduleIssueStore.updateIssue(workspaceSlug, issue.project, issue.id, issue, moduleId);
|
||||
await moduleIssueStore.updateIssue(workspaceSlug, issue.project, issue.id, issue, moduleId);
|
||||
},
|
||||
[EIssueActions.DELETE]: (issue: IIssue) => {
|
||||
[EIssueActions.DELETE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug || !moduleId) return;
|
||||
moduleIssueStore.removeIssue(workspaceSlug, issue.project, issue.id, moduleId);
|
||||
await moduleIssueStore.removeIssue(workspaceSlug, issue.project, issue.id, moduleId);
|
||||
},
|
||||
[EIssueActions.REMOVE]: (issue: IIssue) => {
|
||||
[EIssueActions.REMOVE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug || !moduleId || !issue.bridge_id) return;
|
||||
moduleIssueStore.removeIssueFromModule(workspaceSlug, issue.project, moduleId, issue.id, issue.bridge_id);
|
||||
await moduleIssueStore.removeIssueFromModule(workspaceSlug, issue.project, moduleId, issue.id, issue.bridge_id);
|
||||
},
|
||||
};
|
||||
|
||||
const handleDragDrop = (source: any, destination: any, issues: IIssue[], issueWithIds: any) => {
|
||||
if (calendarHelperStore.handleDragDrop)
|
||||
calendarHelperStore.handleDragDrop(
|
||||
source,
|
||||
destination,
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
moduleIssueStore,
|
||||
issues,
|
||||
issueWithIds,
|
||||
moduleId
|
||||
);
|
||||
handleCalenderDragDrop(
|
||||
source,
|
||||
destination,
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
moduleIssueStore,
|
||||
issues,
|
||||
issueWithIds,
|
||||
moduleId
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -10,35 +10,35 @@ import { useRouter } from "next/router";
|
|||
|
||||
export const CalendarLayout: React.FC = observer(() => {
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId } = router.query as { workspaceSlug: string; projectId: string };
|
||||
const { workspaceSlug, projectId } = router.query;
|
||||
|
||||
const {
|
||||
projectIssues: issueStore,
|
||||
issueCalendarView: issueCalendarViewStore,
|
||||
projectIssuesFilter: projectIssueFiltersStore,
|
||||
calendarHelpers: calendarHelperStore,
|
||||
calendarHelpers: { handleDragDrop: handleCalenderDragDrop },
|
||||
} = useMobxStore();
|
||||
|
||||
const issueActions = {
|
||||
[EIssueActions.UPDATE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug) return;
|
||||
|
||||
issueStore.updateIssue(workspaceSlug, issue.project, issue.id, issue);
|
||||
await issueStore.updateIssue(workspaceSlug.toString(), issue.project, issue.id, issue);
|
||||
},
|
||||
[EIssueActions.DELETE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug) return;
|
||||
|
||||
issueStore.removeIssue(workspaceSlug, issue.project, issue.id);
|
||||
await issueStore.removeIssue(workspaceSlug.toString(), issue.project, issue.id);
|
||||
},
|
||||
};
|
||||
|
||||
const handleDragDrop = (source: any, destination: any, issues: IIssue[], issueWithIds: any) => {
|
||||
if (calendarHelperStore.handleDragDrop)
|
||||
calendarHelperStore.handleDragDrop(
|
||||
if (workspaceSlug && projectId)
|
||||
handleCalenderDragDrop(
|
||||
source,
|
||||
destination,
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
issueStore,
|
||||
issues,
|
||||
issueWithIds
|
||||
|
|
|
|||
|
|
@ -14,32 +14,32 @@ export const ProjectViewCalendarLayout: React.FC = observer(() => {
|
|||
viewIssues: projectViewIssuesStore,
|
||||
viewIssuesFilter: projectIssueViewFiltersStore,
|
||||
projectViewIssueCalendarView: projectViewIssueCalendarViewStore,
|
||||
calendarHelpers: calendarHelperStore,
|
||||
calendarHelpers: { handleDragDrop: handleCalenderDragDrop },
|
||||
} = useMobxStore();
|
||||
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId } = router.query as { workspaceSlug: string; projectId: string };
|
||||
const { workspaceSlug, projectId } = router.query;
|
||||
|
||||
const issueActions = {
|
||||
[EIssueActions.UPDATE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug) return;
|
||||
|
||||
projectViewIssuesStore.updateIssue(workspaceSlug.toString(), issue.project, issue.id, issue);
|
||||
await projectViewIssuesStore.updateIssue(workspaceSlug.toString(), issue.project, issue.id, issue);
|
||||
},
|
||||
[EIssueActions.DELETE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug) return;
|
||||
|
||||
projectViewIssuesStore.removeIssue(workspaceSlug.toString(), issue.project, issue.id);
|
||||
await projectViewIssuesStore.removeIssue(workspaceSlug.toString(), issue.project, issue.id);
|
||||
},
|
||||
};
|
||||
|
||||
const handleDragDrop = (source: any, destination: any, issues: IIssue[], issueWithIds: any) => {
|
||||
if (calendarHelperStore.handleDragDrop)
|
||||
calendarHelperStore.handleDragDrop(
|
||||
if (workspaceSlug && projectId)
|
||||
handleCalenderDragDrop(
|
||||
source,
|
||||
destination,
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
projectViewIssuesStore,
|
||||
issues,
|
||||
issueWithIds
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { useRouter } from "next/router";
|
||||
import { observer } from "mobx-react-lite";
|
||||
|
||||
// mobx store
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
// components
|
||||
|
|
@ -26,7 +25,6 @@ export const ProjectViewAppliedFiltersRoot: React.FC = observer(() => {
|
|||
projectState: projectStateStore,
|
||||
projectMember: { projectMembers },
|
||||
projectViews: projectViewsStore,
|
||||
projectViewFilters: projectViewFiltersStore,
|
||||
viewIssuesFilter: { issueFilters, updateFilters },
|
||||
} = useMobxStore();
|
||||
|
||||
|
|
|
|||
|
|
@ -54,11 +54,11 @@ export const BaseGanttRoot: React.FC<IBaseGanttRoot> = observer((props: IBaseGan
|
|||
|
||||
const issues = issueIds.map((id) => issuesResponse?.[id]);
|
||||
|
||||
const updateIssue = (issue: IIssue, payload: IBlockUpdateData) => {
|
||||
const updateIssue = async (issue: IIssue, payload: IBlockUpdateData) => {
|
||||
if (!workspaceSlug) return;
|
||||
|
||||
//Todo fix sort order in the structure
|
||||
issueStore.updateIssue(
|
||||
await issueStore.updateIssue(
|
||||
workspaceSlug.toString(),
|
||||
issue.project,
|
||||
issue.id,
|
||||
|
|
@ -101,9 +101,9 @@ export const BaseGanttRoot: React.FC<IBaseGanttRoot> = observer((props: IBaseGan
|
|||
workspaceSlug={workspaceSlug.toString()}
|
||||
projectId={peekProjectId.toString()}
|
||||
issueId={peekIssueId.toString()}
|
||||
handleIssue={(issueToUpdate) => {
|
||||
handleIssue={async (issueToUpdate) => {
|
||||
// TODO: update the logic here
|
||||
updateIssue(issueToUpdate as IIssue, {});
|
||||
await updateIssue(issueToUpdate as IIssue, {});
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ export interface IBaseKanBanLayout {
|
|||
kanbanViewStore: IIssueKanBanViewStore;
|
||||
QuickActions: FC<IQuickActionProps>;
|
||||
issueActions: {
|
||||
[EIssueActions.DELETE]: (issue: IIssue) => void;
|
||||
[EIssueActions.UPDATE]?: (issue: IIssue) => void;
|
||||
[EIssueActions.REMOVE]?: (issue: IIssue) => void;
|
||||
[EIssueActions.DELETE]: (issue: IIssue) => Promise<void>;
|
||||
[EIssueActions.UPDATE]?: (issue: IIssue) => Promise<void>;
|
||||
[EIssueActions.REMOVE]?: (issue: IIssue) => Promise<void>;
|
||||
};
|
||||
showLoader?: boolean;
|
||||
viewId?: string;
|
||||
|
|
@ -169,7 +169,7 @@ export const BaseKanBanRoot: React.FC<IBaseKanBanLayout> = observer((props: IBas
|
|||
const handleIssues = useCallback(
|
||||
async (sub_group_by: string | null, group_by: string | null, issue: IIssue, action: EIssueActions) => {
|
||||
if (issueActions[action]) {
|
||||
issueActions[action]!(issue);
|
||||
await issueActions[action]!(issue);
|
||||
}
|
||||
},
|
||||
[issueActions]
|
||||
|
|
@ -345,8 +345,8 @@ export const BaseKanBanRoot: React.FC<IBaseKanBanLayout> = observer((props: IBas
|
|||
workspaceSlug={workspaceSlug.toString()}
|
||||
projectId={peekProjectId.toString()}
|
||||
issueId={peekIssueId.toString()}
|
||||
handleIssue={(issueToUpdate) =>
|
||||
handleIssues(sub_group_by, group_by, issueToUpdate as IIssue, EIssueActions.UPDATE)
|
||||
handleIssue={async (issueToUpdate) =>
|
||||
await handleIssues(sub_group_by, group_by, issueToUpdate as IIssue, EIssueActions.UPDATE)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,7 @@ export interface ICycleKanBanLayout {}
|
|||
|
||||
export const CycleKanBanLayout: React.FC = observer(() => {
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId, cycleId } = router.query as {
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
cycleId: string;
|
||||
};
|
||||
const { workspaceSlug, projectId, cycleId } = router.query;
|
||||
|
||||
// store
|
||||
const {
|
||||
|
|
@ -35,15 +31,23 @@ export const CycleKanBanLayout: React.FC = observer(() => {
|
|||
[EIssueActions.UPDATE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug || !cycleId) return;
|
||||
|
||||
cycleIssueStore.updateIssue(workspaceSlug, issue.project, issue.id, issue, cycleId);
|
||||
await cycleIssueStore.updateIssue(workspaceSlug.toString(), issue.project, issue.id, issue, cycleId.toString());
|
||||
},
|
||||
[EIssueActions.DELETE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug || !cycleId) return;
|
||||
cycleIssueStore.removeIssue(workspaceSlug, issue.project, issue.id, cycleId);
|
||||
|
||||
await cycleIssueStore.removeIssue(workspaceSlug.toString(), issue.project, issue.id, cycleId.toString());
|
||||
},
|
||||
[EIssueActions.REMOVE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug || !cycleId || !issue.bridge_id) return;
|
||||
cycleIssueStore.removeIssueFromCycle(workspaceSlug, issue.project, cycleId, issue.id, issue.bridge_id);
|
||||
|
||||
await cycleIssueStore.removeIssueFromCycle(
|
||||
workspaceSlug.toString(),
|
||||
issue.project,
|
||||
cycleId.toString(),
|
||||
issue.id,
|
||||
issue.bridge_id
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -55,18 +59,18 @@ export const CycleKanBanLayout: React.FC = observer(() => {
|
|||
issues: IIssueResponse | undefined,
|
||||
issueWithIds: IGroupedIssues | ISubGroupedIssues | TUnGroupedIssues | undefined
|
||||
) => {
|
||||
if (kanBanHelperStore.handleDragDrop)
|
||||
if (workspaceSlug && projectId && cycleId)
|
||||
return await kanBanHelperStore.handleDragDrop(
|
||||
source,
|
||||
destination,
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
cycleIssueStore,
|
||||
subGroupBy,
|
||||
groupBy,
|
||||
issues,
|
||||
issueWithIds,
|
||||
cycleId
|
||||
cycleId.toString()
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -78,10 +82,12 @@ export const CycleKanBanLayout: React.FC = observer(() => {
|
|||
kanbanViewStore={cycleIssueKanBanViewStore}
|
||||
showLoader={true}
|
||||
QuickActions={CycleIssueQuickActions}
|
||||
viewId={cycleId}
|
||||
viewId={cycleId?.toString() ?? ""}
|
||||
currentStore={EProjectStore.CYCLE}
|
||||
handleDragDrop={handleDragDrop}
|
||||
addIssuesToView={(issues: string[]) => cycleIssueStore.addIssueToCycle(workspaceSlug, cycleId, issues)}
|
||||
addIssuesToView={(issues: string[]) =>
|
||||
cycleIssueStore.addIssueToCycle(workspaceSlug?.toString() ?? "", cycleId?.toString() ?? "", issues)
|
||||
}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ export interface IKanBanLayout {}
|
|||
|
||||
export const DraftKanBanLayout: React.FC = observer(() => {
|
||||
const router = useRouter();
|
||||
const { workspaceSlug } = router.query as { workspaceSlug: string };
|
||||
const { workspaceSlug } = router.query;
|
||||
|
||||
const {
|
||||
projectDraftIssues: issueStore,
|
||||
|
|
@ -26,12 +26,12 @@ export const DraftKanBanLayout: React.FC = observer(() => {
|
|||
[EIssueActions.UPDATE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug) return;
|
||||
|
||||
await issueStore.updateIssue(workspaceSlug, issue.project, issue.id, issue);
|
||||
await issueStore.updateIssue(workspaceSlug.toString(), issue.project, issue.id, issue);
|
||||
},
|
||||
[EIssueActions.DELETE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug) return;
|
||||
|
||||
await issueStore.removeIssue(workspaceSlug, issue.project, issue.id);
|
||||
await issueStore.removeIssue(workspaceSlug.toString(), issue.project, issue.id);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -17,11 +17,7 @@ export interface IModuleKanBanLayout {}
|
|||
|
||||
export const ModuleKanBanLayout: React.FC = observer(() => {
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId, moduleId } = router.query as {
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
moduleId: string;
|
||||
};
|
||||
const { workspaceSlug, projectId, moduleId } = router.query;
|
||||
|
||||
// store
|
||||
const {
|
||||
|
|
@ -35,15 +31,23 @@ export const ModuleKanBanLayout: React.FC = observer(() => {
|
|||
[EIssueActions.UPDATE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug || !moduleId) return;
|
||||
|
||||
moduleIssueStore.updateIssue(workspaceSlug.toString(), issue.project, issue.id, issue, moduleId);
|
||||
await moduleIssueStore.updateIssue(workspaceSlug.toString(), issue.project, issue.id, issue, moduleId.toString());
|
||||
},
|
||||
[EIssueActions.DELETE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug || !moduleId) return;
|
||||
moduleIssueStore.removeIssue(workspaceSlug, issue.project, issue.id, moduleId);
|
||||
|
||||
await moduleIssueStore.removeIssue(workspaceSlug.toString(), issue.project, issue.id, moduleId.toString());
|
||||
},
|
||||
[EIssueActions.REMOVE]: async (issue: IIssue) => {
|
||||
if (!workspaceSlug || !moduleId || !issue.bridge_id) return;
|
||||
moduleIssueStore.removeIssueFromModule(workspaceSlug, issue.project, moduleId, issue.id, issue.bridge_id);
|
||||
|
||||
await moduleIssueStore.removeIssueFromModule(
|
||||
workspaceSlug.toString(),
|
||||
issue.project,
|
||||
moduleId.toString(),
|
||||
issue.id,
|
||||
issue.bridge_id
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -55,18 +59,18 @@ export const ModuleKanBanLayout: React.FC = observer(() => {
|
|||
issues: IIssueResponse | undefined,
|
||||
issueWithIds: IGroupedIssues | ISubGroupedIssues | TUnGroupedIssues | undefined
|
||||
) => {
|
||||
if (kanBanHelperStore.handleDragDrop)
|
||||
if (workspaceSlug && projectId && moduleId)
|
||||
return await kanBanHelperStore.handleDragDrop(
|
||||
source,
|
||||
destination,
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
moduleIssueStore,
|
||||
subGroupBy,
|
||||
groupBy,
|
||||
issues,
|
||||
issueWithIds,
|
||||
moduleId
|
||||
moduleId.toString()
|
||||
);
|
||||
};
|
||||
return (
|
||||
|
|
@ -77,10 +81,12 @@ export const ModuleKanBanLayout: React.FC = observer(() => {
|
|||
kanbanViewStore={moduleIssueKanBanViewStore}
|
||||
showLoader={true}
|
||||
QuickActions={ModuleIssueQuickActions}
|
||||
viewId={moduleId}
|
||||
viewId={moduleId?.toString() ?? ""}
|
||||
currentStore={EProjectStore.MODULE}
|
||||
handleDragDrop={handleDragDrop}
|
||||
addIssuesToView={(issues: string[]) => moduleIssueStore.addIssueToModule(workspaceSlug, moduleId, issues)}
|
||||
addIssuesToView={(issues: string[]) =>
|
||||
moduleIssueStore.addIssueToModule(workspaceSlug?.toString() ?? "", moduleId?.toString() ?? "", issues)
|
||||
}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -45,20 +45,18 @@ export const KanBanLayout: React.FC = observer(() => {
|
|||
groupBy: string | null,
|
||||
issues: IIssueResponse | undefined,
|
||||
issueWithIds: IGroupedIssues | ISubGroupedIssues | TUnGroupedIssues | undefined
|
||||
) => {
|
||||
if (kanBanHelperStore.handleDragDrop)
|
||||
return await kanBanHelperStore.handleDragDrop(
|
||||
source,
|
||||
destination,
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
issueStore,
|
||||
subGroupBy,
|
||||
groupBy,
|
||||
issues,
|
||||
issueWithIds
|
||||
);
|
||||
};
|
||||
) =>
|
||||
await kanBanHelperStore.handleDragDrop(
|
||||
source,
|
||||
destination,
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
issueStore,
|
||||
subGroupBy,
|
||||
groupBy,
|
||||
issues,
|
||||
issueWithIds
|
||||
);
|
||||
|
||||
return (
|
||||
<BaseKanBanRoot
|
||||
|
|
|
|||
|
|
@ -45,20 +45,18 @@ export const ProjectViewKanBanLayout: React.FC = observer(() => {
|
|||
groupBy: string | null,
|
||||
issues: IIssueResponse | undefined,
|
||||
issueWithIds: IGroupedIssues | ISubGroupedIssues | TUnGroupedIssues | undefined
|
||||
) => {
|
||||
if (kanBanHelperStore.handleDragDrop)
|
||||
return await kanBanHelperStore.handleDragDrop(
|
||||
source,
|
||||
destination,
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
projectViewIssuesStore,
|
||||
subGroupBy,
|
||||
groupBy,
|
||||
issues,
|
||||
issueWithIds
|
||||
);
|
||||
};
|
||||
) =>
|
||||
await kanBanHelperStore.handleDragDrop(
|
||||
source,
|
||||
destination,
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
projectViewIssuesStore,
|
||||
subGroupBy,
|
||||
groupBy,
|
||||
issues,
|
||||
issueWithIds
|
||||
);
|
||||
|
||||
return (
|
||||
<BaseKanBanRoot
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ interface IBaseListRoot {
|
|||
| IProfileIssuesStore;
|
||||
QuickActions: FC<IQuickActionProps>;
|
||||
issueActions: {
|
||||
[EIssueActions.DELETE]: (group_by: string | null, issue: IIssue) => void;
|
||||
[EIssueActions.UPDATE]?: (group_by: string | null, issue: IIssue) => void;
|
||||
[EIssueActions.REMOVE]?: (group_by: string | null, issue: IIssue) => void;
|
||||
[EIssueActions.DELETE]: (group_by: string | null, issue: IIssue) => Promise<void>;
|
||||
[EIssueActions.UPDATE]?: (group_by: string | null, issue: IIssue) => Promise<void>;
|
||||
[EIssueActions.REMOVE]?: (group_by: string | null, issue: IIssue) => Promise<void>;
|
||||
};
|
||||
getProjects: (projectStore: IProjectStore) => IProject[] | null;
|
||||
viewId?: string;
|
||||
|
|
@ -105,7 +105,7 @@ export const BaseListRoot = observer((props: IBaseListRoot) => {
|
|||
const members = projectMembers?.map((m) => m.member) ?? null;
|
||||
const handleIssues = async (issue: IIssue, action: EIssueActions) => {
|
||||
if (issueActions[action]) {
|
||||
issueActions[action]!(group_by, issue);
|
||||
await issueActions[action]!(group_by, issue);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ export const BaseListRoot = observer((props: IBaseListRoot) => {
|
|||
workspaceSlug={workspaceSlug.toString()}
|
||||
projectId={peekProjectId.toString()}
|
||||
issueId={peekIssueId.toString()}
|
||||
handleIssue={(issueToUpdate) => handleIssues(issueToUpdate as IIssue, EIssueActions.UPDATE)}
|
||||
handleIssue={async (issueToUpdate) => await handleIssues(issueToUpdate as IIssue, EIssueActions.UPDATE)}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ export const ArchivedIssueListLayout: FC = observer(() => {
|
|||
useMobxStore();
|
||||
|
||||
const issueActions = {
|
||||
[EIssueActions.DELETE]: (group_by: string | null, issue: IIssue) => {
|
||||
[EIssueActions.DELETE]: async (group_by: string | null, issue: IIssue) => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
|
||||
archivedIssueStore.removeIssue(workspaceSlug, projectId, issue.id);
|
||||
await archivedIssueStore.removeIssue(workspaceSlug, projectId, issue.id);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -22,17 +22,20 @@ export const CycleListLayout: React.FC = observer(() => {
|
|||
const { cycleIssues: cycleIssueStore, cycleIssuesFilter: cycleIssueFilterStore } = useMobxStore();
|
||||
|
||||
const issueActions = {
|
||||
[EIssueActions.UPDATE]: (group_by: string | null, issue: IIssue) => {
|
||||
[EIssueActions.UPDATE]: async (group_by: string | null, issue: IIssue) => {
|
||||
if (!workspaceSlug || !cycleId) return;
|
||||
cycleIssueStore.updateIssue(workspaceSlug, issue.project, issue.id, issue, cycleId);
|
||||
|
||||
await cycleIssueStore.updateIssue(workspaceSlug, issue.project, issue.id, issue, cycleId);
|
||||
},
|
||||
[EIssueActions.DELETE]: (group_by: string | null, issue: IIssue) => {
|
||||
[EIssueActions.DELETE]: async (group_by: string | null, issue: IIssue) => {
|
||||
if (!workspaceSlug || !cycleId) return;
|
||||
cycleIssueStore.removeIssue(workspaceSlug, issue.project, issue.id, cycleId);
|
||||
|
||||
await cycleIssueStore.removeIssue(workspaceSlug, issue.project, issue.id, cycleId);
|
||||
},
|
||||
[EIssueActions.REMOVE]: (group_by: string | null, issue: IIssue) => {
|
||||
[EIssueActions.REMOVE]: async (group_by: string | null, issue: IIssue) => {
|
||||
if (!workspaceSlug || !cycleId || !issue.bridge_id) return;
|
||||
cycleIssueStore.removeIssueFromCycle(workspaceSlug, issue.project, cycleId, issue.id, issue.bridge_id);
|
||||
|
||||
await cycleIssueStore.removeIssueFromCycle(workspaceSlug, issue.project, cycleId, issue.id, issue.bridge_id);
|
||||
},
|
||||
};
|
||||
const getProjects = (projectStore: IProjectStore) => {
|
||||
|
|
|
|||
|
|
@ -23,13 +23,15 @@ export const DraftIssueListLayout: FC = observer(() => {
|
|||
const { projectDraftIssuesFilter: projectIssuesFilterStore, projectDraftIssues: projectIssuesStore } = useMobxStore();
|
||||
|
||||
const issueActions = {
|
||||
[EIssueActions.UPDATE]: (group_by: string | null, issue: IIssue) => {
|
||||
[EIssueActions.UPDATE]: async (group_by: string | null, issue: IIssue) => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
projectIssuesStore.updateIssue(workspaceSlug, projectId, issue.id, issue);
|
||||
|
||||
await projectIssuesStore.updateIssue(workspaceSlug, projectId, issue.id, issue);
|
||||
},
|
||||
[EIssueActions.DELETE]: (group_by: string | null, issue: IIssue) => {
|
||||
[EIssueActions.DELETE]: async (group_by: string | null, issue: IIssue) => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
projectIssuesStore.removeIssue(workspaceSlug, projectId, issue.id);
|
||||
|
||||
await projectIssuesStore.removeIssue(workspaceSlug, projectId, issue.id);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -22,17 +22,20 @@ export const ModuleListLayout: React.FC = observer(() => {
|
|||
const { moduleIssues: moduleIssueStore, moduleIssuesFilter: moduleIssueFilterStore } = useMobxStore();
|
||||
|
||||
const issueActions = {
|
||||
[EIssueActions.UPDATE]: (group_by: string | null, issue: IIssue) => {
|
||||
[EIssueActions.UPDATE]: async (group_by: string | null, issue: IIssue) => {
|
||||
if (!workspaceSlug || !moduleId) return;
|
||||
moduleIssueStore.updateIssue(workspaceSlug, issue.project, issue.id, issue, moduleId);
|
||||
|
||||
await moduleIssueStore.updateIssue(workspaceSlug, issue.project, issue.id, issue, moduleId);
|
||||
},
|
||||
[EIssueActions.DELETE]: (group_by: string | null, issue: IIssue) => {
|
||||
[EIssueActions.DELETE]: async (group_by: string | null, issue: IIssue) => {
|
||||
if (!workspaceSlug || !moduleId) return;
|
||||
moduleIssueStore.removeIssue(workspaceSlug, issue.project, issue.id, moduleId);
|
||||
|
||||
await moduleIssueStore.removeIssue(workspaceSlug, issue.project, issue.id, moduleId);
|
||||
},
|
||||
[EIssueActions.REMOVE]: (group_by: string | null, issue: IIssue) => {
|
||||
[EIssueActions.REMOVE]: async (group_by: string | null, issue: IIssue) => {
|
||||
if (!workspaceSlug || !moduleId || !issue.bridge_id) return;
|
||||
moduleIssueStore.removeIssueFromModule(workspaceSlug, issue.project, moduleId, issue.id, issue.bridge_id);
|
||||
|
||||
await moduleIssueStore.removeIssueFromModule(workspaceSlug, issue.project, moduleId, issue.id, issue.bridge_id);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -23,13 +23,15 @@ export const ListLayout: FC = observer(() => {
|
|||
const { projectIssuesFilter: projectIssuesFilterStore, projectIssues: projectIssuesStore } = useMobxStore();
|
||||
|
||||
const issueActions = {
|
||||
[EIssueActions.UPDATE]: (group_by: string | null, issue: IIssue) => {
|
||||
[EIssueActions.UPDATE]: async (group_by: string | null, issue: IIssue) => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
projectIssuesStore.updateIssue(workspaceSlug, projectId, issue.id, issue);
|
||||
|
||||
await projectIssuesStore.updateIssue(workspaceSlug, projectId, issue.id, issue);
|
||||
},
|
||||
[EIssueActions.DELETE]: (group_by: string | null, issue: IIssue) => {
|
||||
[EIssueActions.DELETE]: async (group_by: string | null, issue: IIssue) => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
projectIssuesStore.removeIssue(workspaceSlug, projectId, issue.id);
|
||||
|
||||
await projectIssuesStore.removeIssue(workspaceSlug, projectId, issue.id);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -26,13 +26,15 @@ export const ProjectViewListLayout: React.FC = observer(() => {
|
|||
if (!workspaceSlug || !projectId) return null;
|
||||
|
||||
const issueActions = {
|
||||
[EIssueActions.UPDATE]: (group_by: string | null, issue: IIssue) => {
|
||||
[EIssueActions.UPDATE]: async (group_by: string | null, issue: IIssue) => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
projectViewIssueStore.updateIssue(workspaceSlug, projectId, issue.id, issue);
|
||||
|
||||
await projectViewIssueStore.updateIssue(workspaceSlug, projectId, issue.id, issue);
|
||||
},
|
||||
[EIssueActions.DELETE]: (group_by: string | null, issue: IIssue) => {
|
||||
[EIssueActions.DELETE]: async (group_by: string | null, issue: IIssue) => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
projectViewIssueStore.removeIssue(workspaceSlug, projectId, issue.id);
|
||||
|
||||
await projectViewIssueStore.removeIssue(workspaceSlug, projectId, issue.id);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ type Props = {
|
|||
members?: IUserLite[] | undefined;
|
||||
labels?: IIssueLabel[] | undefined;
|
||||
states?: IState[] | undefined;
|
||||
quickActions: (issue: IIssue,customActionButton?: React.ReactElement) => React.ReactNode;
|
||||
handleIssues: (issue: IIssue, action: EIssueActions) => void;
|
||||
quickActions: (issue: IIssue, customActionButton: any) => React.ReactNode; // TODO: replace any with type
|
||||
handleIssues: (issue: IIssue, action: EIssueActions) => Promise<void>;
|
||||
openIssuesListModal?: (() => void) | null;
|
||||
quickAddCallback?: (
|
||||
workspaceSlug: string,
|
||||
|
|
@ -189,7 +189,7 @@ export const SpreadsheetView: React.FC<Props> = observer((props) => {
|
|||
workspaceSlug={workspaceSlug.toString()}
|
||||
projectId={peekProjectId.toString()}
|
||||
issueId={peekIssueId.toString()}
|
||||
handleIssue={(issueToUpdate: any) => handleIssues(issueToUpdate, EIssueActions.UPDATE)}
|
||||
handleIssue={async (issueToUpdate: any) => await handleIssues(issueToUpdate, EIssueActions.UPDATE)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
export * from "./root";
|
||||
|
|
@ -1,22 +1,25 @@
|
|||
// hooks
|
||||
import useUserAuth from "hooks/use-user-auth";
|
||||
import useIssueReaction from "hooks/use-issue-reaction";
|
||||
// components
|
||||
import { ReactionSelector } from "components/core";
|
||||
// string helpers
|
||||
import { renderEmoji } from "helpers/emoji.helper";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
|
||||
// types
|
||||
type Props = {
|
||||
workspaceSlug?: string | string[];
|
||||
projectId?: string | string[];
|
||||
issueId?: string | string[];
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
issueId: string;
|
||||
};
|
||||
|
||||
export const IssueReaction: React.FC<Props> = (props) => {
|
||||
export const IssueReaction: React.FC<Props> = observer((props) => {
|
||||
const { workspaceSlug, projectId, issueId } = props;
|
||||
|
||||
const { user } = useUserAuth();
|
||||
const {
|
||||
user: { currentUser },
|
||||
} = useMobxStore();
|
||||
|
||||
const { reactions, groupedReactions, handleReactionCreate, handleReactionDelete } = useIssueReaction(
|
||||
workspaceSlug,
|
||||
|
|
@ -27,7 +30,7 @@ export const IssueReaction: React.FC<Props> = (props) => {
|
|||
const handleReactionClick = (reaction: string) => {
|
||||
if (!workspaceSlug || !projectId || !issueId) return;
|
||||
|
||||
const isSelected = reactions?.some((r) => r.actor === user?.id && r.reaction === reaction);
|
||||
const isSelected = reactions?.some((r) => r.actor === currentUser?.id && r.reaction === reaction);
|
||||
|
||||
if (isSelected) {
|
||||
handleReactionDelete(reaction);
|
||||
|
|
@ -41,7 +44,7 @@ export const IssueReaction: React.FC<Props> = (props) => {
|
|||
<ReactionSelector
|
||||
size="md"
|
||||
position="top"
|
||||
value={reactions?.filter((reaction) => reaction.actor === user?.id).map((r) => r.reaction) || []}
|
||||
value={reactions?.filter((reaction) => reaction.actor === currentUser?.id).map((r) => r.reaction) || []}
|
||||
onSelect={handleReactionClick}
|
||||
/>
|
||||
|
||||
|
|
@ -56,7 +59,7 @@ export const IssueReaction: React.FC<Props> = (props) => {
|
|||
}}
|
||||
key={reaction}
|
||||
className={`flex items-center gap-1 text-custom-text-100 text-sm h-full px-2 py-1 rounded-md ${
|
||||
reactions?.some((r) => r.actor === user?.id && r.reaction === reaction)
|
||||
reactions?.some((r) => r.actor === currentUser?.id && r.reaction === reaction)
|
||||
? "bg-custom-primary-100/10"
|
||||
: "bg-custom-background-80"
|
||||
}`}
|
||||
|
|
@ -64,7 +67,7 @@ export const IssueReaction: React.FC<Props> = (props) => {
|
|||
<span>{renderEmoji(reaction)}</span>
|
||||
<span
|
||||
className={
|
||||
reactions?.some((r) => r.actor === user?.id && r.reaction === reaction)
|
||||
reactions?.some((r) => r.actor === currentUser?.id && r.reaction === reaction)
|
||||
? "text-custom-primary-100"
|
||||
: ""
|
||||
}
|
||||
|
|
@ -76,4 +79,4 @@ export const IssueReaction: React.FC<Props> = (props) => {
|
|||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -24,9 +24,10 @@ import { SubIssuesRoot } from "./sub-issues";
|
|||
// ui
|
||||
import { CustomMenu, LayersIcon, StateGroupIcon } from "@plane/ui";
|
||||
// types
|
||||
import { IIssue, IIssueComment } from "types";
|
||||
import { IIssue, IIssueActivity } from "types";
|
||||
// fetch-keys
|
||||
import { PROJECT_ISSUES_ACTIVITY, SUB_ISSUES } from "constants/fetch-keys";
|
||||
// constants
|
||||
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||
|
||||
type Props = {
|
||||
|
|
@ -41,24 +42,22 @@ const issueCommentService = new IssueCommentService();
|
|||
|
||||
export const IssueMainContent: React.FC<Props> = observer((props) => {
|
||||
const { issueDetails, submitChanges, uneditable = false } = props;
|
||||
|
||||
// states
|
||||
const [isSubmitting, setIsSubmitting] = useState<"submitting" | "submitted" | "saved">("saved");
|
||||
|
||||
// router
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId, issueId } = router.query;
|
||||
|
||||
// toast alert
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
// mobx store
|
||||
const {
|
||||
user: userStore,
|
||||
user: { currentUser, currentProjectRole },
|
||||
project: projectStore,
|
||||
projectState: { states },
|
||||
trackEvent: { postHogEventTracker },
|
||||
workspace: { currentWorkspace }
|
||||
} = useMobxStore();
|
||||
const user = userStore.currentUser ?? undefined;
|
||||
const userRole = userStore.currentProjectRole;
|
||||
|
||||
const projectDetails = projectId ? projectStore.project_details[projectId.toString()] : undefined;
|
||||
const currentIssueState = projectId
|
||||
? states[projectId.toString()]?.find((s) => s.id === issueDetails.state)
|
||||
|
|
@ -67,7 +66,7 @@ export const IssueMainContent: React.FC<Props> = observer((props) => {
|
|||
const { data: siblingIssues } = useSWR(
|
||||
workspaceSlug && projectId && issueDetails?.parent ? SUB_ISSUES(issueDetails.parent) : null,
|
||||
workspaceSlug && projectId && issueDetails?.parent
|
||||
? () => issueService.subIssues(workspaceSlug as string, projectId as string, issueDetails.parent ?? "")
|
||||
? () => issueService.subIssues(workspaceSlug.toString(), projectId.toString(), issueDetails.parent ?? "")
|
||||
: null
|
||||
);
|
||||
const siblingIssuesList = siblingIssues?.sub_issues.filter((i) => i.id !== issueDetails.id);
|
||||
|
|
@ -79,7 +78,7 @@ export const IssueMainContent: React.FC<Props> = observer((props) => {
|
|||
: null
|
||||
);
|
||||
|
||||
const handleCommentUpdate = async (commentId: string, data: Partial<IIssueComment>) => {
|
||||
const handleCommentUpdate = async (commentId: string, data: Partial<IIssueActivity>) => {
|
||||
if (!workspaceSlug || !projectId || !issueId) return;
|
||||
|
||||
await issueCommentService
|
||||
|
|
@ -103,7 +102,7 @@ export const IssueMainContent: React.FC<Props> = observer((props) => {
|
|||
};
|
||||
|
||||
const handleCommentDelete = async (commentId: string) => {
|
||||
if (!workspaceSlug || !projectId || !issueId || !user) return;
|
||||
if (!workspaceSlug || !projectId || !issueId || !currentUser) return;
|
||||
|
||||
mutateIssueActivity((prevData: any) => prevData?.filter((p: any) => p.id !== commentId), false);
|
||||
|
||||
|
|
@ -126,8 +125,8 @@ export const IssueMainContent: React.FC<Props> = observer((props) => {
|
|||
);
|
||||
};
|
||||
|
||||
const handleAddComment = async (formData: IIssueComment) => {
|
||||
if (!workspaceSlug || !issueDetails || !user) return;
|
||||
const handleAddComment = async (formData: IIssueActivity) => {
|
||||
if (!workspaceSlug || !issueDetails || !currentUser) return;
|
||||
|
||||
await issueCommentService
|
||||
.createIssueComment(workspaceSlug.toString(), issueDetails.project, issueDetails.id, formData)
|
||||
|
|
@ -155,7 +154,7 @@ export const IssueMainContent: React.FC<Props> = observer((props) => {
|
|||
);
|
||||
};
|
||||
|
||||
const isAllowed = !!userRole && userRole >= EUserWorkspaceRoles.MEMBER;
|
||||
const isAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -238,10 +237,16 @@ export const IssueMainContent: React.FC<Props> = observer((props) => {
|
|||
isAllowed={isAllowed || !uneditable}
|
||||
/>
|
||||
|
||||
<IssueReaction workspaceSlug={workspaceSlug} issueId={issueId} projectId={projectId} />
|
||||
{workspaceSlug && projectId && (
|
||||
<IssueReaction
|
||||
workspaceSlug={workspaceSlug.toString()}
|
||||
projectId={projectId.toString()}
|
||||
issueId={issueDetails.id}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="mt-2 space-y-2">
|
||||
<SubIssuesRoot parentIssue={issueDetails} user={user} />
|
||||
<SubIssuesRoot parentIssue={issueDetails} user={currentUser ?? undefined} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-3 py-3">
|
||||
|
|
|
|||
|
|
@ -2,32 +2,34 @@ import { FC } from "react";
|
|||
import Link from "next/link";
|
||||
import { History } from "lucide-react";
|
||||
// packages
|
||||
import { Tooltip } from "@plane/ui";
|
||||
import { Loader, Tooltip } from "@plane/ui";
|
||||
// components
|
||||
import { ActivityIcon, ActivityMessage } from "components/core";
|
||||
import { IssueCommentCard } from "./comment-card";
|
||||
// helpers
|
||||
import { render24HourFormatTime, renderLongDateFormat, timeAgo } from "helpers/date-time.helper";
|
||||
// types
|
||||
import { IIssueActivity, IUser } from "types";
|
||||
|
||||
interface IssueActivityCard {
|
||||
interface IIssueActivityCard {
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
issueId: string;
|
||||
user: any;
|
||||
issueComments: any;
|
||||
user: IUser | null;
|
||||
issueActivity: IIssueActivity[] | null;
|
||||
issueCommentUpdate: (comment: any) => void;
|
||||
issueCommentRemove: (commentId: string) => void;
|
||||
issueCommentReactionCreate: (commentId: string, reaction: string) => void;
|
||||
issueCommentReactionRemove: (commentId: string, reaction: string) => void;
|
||||
}
|
||||
|
||||
export const IssueActivityCard: FC<IssueActivityCard> = (props) => {
|
||||
export const IssueActivityCard: FC<IIssueActivityCard> = (props) => {
|
||||
const {
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
issueId,
|
||||
user,
|
||||
issueComments,
|
||||
issueActivity,
|
||||
issueCommentUpdate,
|
||||
issueCommentRemove,
|
||||
issueCommentReactionCreate,
|
||||
|
|
@ -37,9 +39,9 @@ export const IssueActivityCard: FC<IssueActivityCard> = (props) => {
|
|||
return (
|
||||
<div className="flow-root">
|
||||
<ul role="list" className="-mb-4">
|
||||
{issueComments &&
|
||||
issueComments.length > 0 &&
|
||||
issueComments.map((activityItem: any, index: any) => {
|
||||
{issueActivity ? (
|
||||
issueActivity.length > 0 &&
|
||||
issueActivity.map((activityItem, index) => {
|
||||
// determines what type of action is performed
|
||||
const message = activityItem.field ? <ActivityMessage activity={activityItem} /> : "created the issue.";
|
||||
|
||||
|
|
@ -47,7 +49,7 @@ export const IssueActivityCard: FC<IssueActivityCard> = (props) => {
|
|||
return (
|
||||
<li key={activityItem.id}>
|
||||
<div className="relative pb-1">
|
||||
{issueComments.length > 1 && index !== issueComments.length - 1 ? (
|
||||
{issueActivity.length > 1 && index !== issueActivity.length - 1 ? (
|
||||
<span
|
||||
className="absolute top-5 left-5 -ml-[1.5px] h-full w-0.5 bg-custom-background-100"
|
||||
aria-hidden="true"
|
||||
|
|
@ -114,7 +116,7 @@ export const IssueActivityCard: FC<IssueActivityCard> = (props) => {
|
|||
</div>
|
||||
</li>
|
||||
);
|
||||
} else if ("comment_json" in activityItem)
|
||||
} else if ("comment_html" in activityItem)
|
||||
return (
|
||||
<div key={activityItem.id} className="mt-4">
|
||||
<IssueCommentCard
|
||||
|
|
@ -131,7 +133,15 @@ export const IssueActivityCard: FC<IssueActivityCard> = (props) => {
|
|||
/>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
})
|
||||
) : (
|
||||
<Loader className="space-y-3 mb-3">
|
||||
<Loader.Item height="20px" />
|
||||
<Loader.Item height="20px" />
|
||||
<Loader.Item height="20px" />
|
||||
<Loader.Item height="20px" />
|
||||
</Loader>
|
||||
)}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
|
|
@ -12,20 +12,20 @@ import { IssueCommentReaction } from "./comment-reaction";
|
|||
// helpers
|
||||
import { timeAgo } from "helpers/date-time.helper";
|
||||
// types
|
||||
import type { IIssueComment } from "types";
|
||||
import type { IIssueActivity, IUser } from "types";
|
||||
|
||||
// services
|
||||
const fileService = new FileService();
|
||||
|
||||
type IIssueCommentCard = {
|
||||
comment: IIssueComment;
|
||||
comment: IIssueActivity;
|
||||
handleCommentDeletion: (comment: string) => void;
|
||||
onSubmit: (data: Partial<IIssueComment>) => void;
|
||||
onSubmit: (data: Partial<IIssueActivity>) => void;
|
||||
showAccessSpecifier?: boolean;
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
issueId: string;
|
||||
user: any;
|
||||
user: IUser | null;
|
||||
issueCommentReactionCreate: (commentId: string, reaction: string) => void;
|
||||
issueCommentReactionRemove: (commentId: string, reaction: string) => void;
|
||||
};
|
||||
|
|
@ -57,11 +57,11 @@ export const IssueCommentCard: React.FC<IIssueCommentCard> = (props) => {
|
|||
setFocus,
|
||||
watch,
|
||||
setValue,
|
||||
} = useForm<IIssueComment>({
|
||||
} = useForm<IIssueActivity>({
|
||||
defaultValues: comment,
|
||||
});
|
||||
|
||||
const formSubmit = (formData: Partial<IIssueComment>) => {
|
||||
const formSubmit = (formData: Partial<IIssueActivity>) => {
|
||||
if (isSubmitting) return;
|
||||
|
||||
setIsEditing(false);
|
||||
|
|
@ -119,13 +119,10 @@ export const IssueCommentCard: React.FC<IIssueCommentCard> = (props) => {
|
|||
deleteFile={fileService.deleteImage}
|
||||
restoreFile={fileService.restoreImage}
|
||||
ref={editorRef}
|
||||
value={watch("comment_html")}
|
||||
value={watch("comment_html") ?? ""}
|
||||
debouncedUpdatesEnabled={false}
|
||||
customClassName="min-h-[50px] p-3 shadow-sm"
|
||||
onChange={(comment_json: Object, comment_html: string) => {
|
||||
setValue("comment_json", comment_json);
|
||||
setValue("comment_html", comment_html);
|
||||
}}
|
||||
onChange={(comment_json: Object, comment_html: string) => setValue("comment_html", comment_html)}
|
||||
mentionSuggestions={editorSuggestions.mentionSuggestions}
|
||||
mentionHighlights={editorSuggestions.mentionHighlights}
|
||||
/>
|
||||
|
|
@ -158,7 +155,7 @@ export const IssueCommentCard: React.FC<IIssueCommentCard> = (props) => {
|
|||
)}
|
||||
<LiteReadOnlyEditorWithRef
|
||||
ref={showEditorRef}
|
||||
value={comment.comment_html}
|
||||
value={comment.comment_html ?? ""}
|
||||
customClassName="text-xs border border-custom-border-200 bg-custom-background-100"
|
||||
mentionHighlights={editorSuggestions.mentionHighlights}
|
||||
/>
|
||||
|
|
@ -11,16 +11,16 @@ import { LiteTextEditorWithRef } from "@plane/lite-text-editor";
|
|||
// ui
|
||||
import { Button } from "@plane/ui";
|
||||
// types
|
||||
import type { IIssueComment } from "types";
|
||||
import type { IIssueActivity } from "types";
|
||||
|
||||
const defaultValues: Partial<IIssueComment> = {
|
||||
const defaultValues: Partial<IIssueActivity> = {
|
||||
access: "INTERNAL",
|
||||
comment_html: "",
|
||||
};
|
||||
|
||||
type IIssueCommentEditor = {
|
||||
disabled?: boolean;
|
||||
onSubmit: (data: IIssueComment) => Promise<void>;
|
||||
onSubmit: (data: IIssueActivity) => Promise<void>;
|
||||
showAccessSpecifier?: boolean;
|
||||
};
|
||||
|
||||
|
|
@ -60,9 +60,9 @@ export const IssueCommentEditor: React.FC<IIssueCommentEditor> = (props) => {
|
|||
formState: { isSubmitting },
|
||||
handleSubmit,
|
||||
reset,
|
||||
} = useForm<IIssueComment>({ defaultValues });
|
||||
} = useForm<IIssueActivity>({ defaultValues });
|
||||
|
||||
const handleAddComment = async (formData: IIssueComment) => {
|
||||
const handleAddComment = async (formData: IIssueActivity) => {
|
||||
if (!formData.comment_html || isSubmitting) return;
|
||||
|
||||
await onSubmit(formData).then(() => {
|
||||
|
|
@ -99,7 +99,7 @@ export const IssueCommentEditor: React.FC<IIssueCommentEditor> = (props) => {
|
|||
onChange={(comment_json: Object, comment_html: string) => onCommentChange(comment_html)}
|
||||
commentAccessSpecifier={
|
||||
showAccessSpecifier
|
||||
? { accessValue, onAccessChange, showAccessSpecifier, commentAccess }
|
||||
? { accessValue: accessValue ?? "INTERNAL", onAccessChange, showAccessSpecifier, commentAccess }
|
||||
: undefined
|
||||
}
|
||||
submitButton={
|
||||
|
|
@ -2,7 +2,7 @@ import { FC } from "react";
|
|||
import useSWR from "swr";
|
||||
import { observer } from "mobx-react-lite";
|
||||
// components
|
||||
import { IssueReaction } from "../reactions";
|
||||
import { IssuePeekOverviewReactions } from "components/issues";
|
||||
// hooks
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
// types
|
||||
|
|
@ -49,7 +49,7 @@ export const IssueCommentReaction: FC<IIssueCommentReaction> = observer((props)
|
|||
|
||||
return (
|
||||
<div>
|
||||
<IssueReaction
|
||||
<IssuePeekOverviewReactions
|
||||
issueReactions={issueReactions}
|
||||
user={user}
|
||||
issueReactionCreate={handleCommentReactionCreate}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
export * from "./view";
|
||||
|
||||
export * from "./card";
|
||||
export * from "./comment-card";
|
||||
export * from "./comment-editor";
|
||||
export * from "./comment-reaction";
|
||||
export * from "./view";
|
||||
|
|
@ -1,29 +1,30 @@
|
|||
import { FC } from "react";
|
||||
// components
|
||||
import { IssueActivityCard } from "./card";
|
||||
import { IssueCommentEditor } from "./comment-editor";
|
||||
import { IssueActivityCard, IssueCommentEditor } from "components/issues";
|
||||
// types
|
||||
import { IIssueActivity, IUser } from "types";
|
||||
|
||||
interface IIssueComment {
|
||||
type Props = {
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
issueId: string;
|
||||
user: any;
|
||||
issueComments: any;
|
||||
user: IUser | null;
|
||||
issueActivity: IIssueActivity[] | null;
|
||||
issueCommentCreate: (comment: any) => void;
|
||||
issueCommentUpdate: (comment: any) => void;
|
||||
issueCommentRemove: (commentId: string) => void;
|
||||
issueCommentReactionCreate: (commentId: string, reaction: string) => void;
|
||||
issueCommentReactionRemove: (commentId: string, reaction: string) => void;
|
||||
showCommentAccessSpecifier: boolean;
|
||||
}
|
||||
};
|
||||
|
||||
export const IssueComment: FC<IIssueComment> = (props) => {
|
||||
export const IssueActivity: FC<Props> = (props) => {
|
||||
const {
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
issueId,
|
||||
user,
|
||||
issueComments,
|
||||
issueActivity,
|
||||
issueCommentCreate,
|
||||
issueCommentUpdate,
|
||||
issueCommentRemove,
|
||||
|
|
@ -47,7 +48,7 @@ export const IssueComment: FC<IIssueComment> = (props) => {
|
|||
projectId={projectId}
|
||||
issueId={issueId}
|
||||
user={user}
|
||||
issueComments={issueComments}
|
||||
issueActivity={issueActivity}
|
||||
issueCommentUpdate={issueCommentUpdate}
|
||||
issueCommentRemove={issueCommentRemove}
|
||||
issueCommentReactionCreate={issueCommentReactionCreate}
|
||||
6
web/components/issues/peek-overview/index.ts
Normal file
6
web/components/issues/peek-overview/index.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
export * from "./activity";
|
||||
export * from "./reactions";
|
||||
export * from "./issue-detail";
|
||||
export * from "./properties";
|
||||
export * from "./root";
|
||||
export * from "./view";
|
||||
|
|
@ -1,19 +1,22 @@
|
|||
import { ChangeEvent, FC, useCallback, useEffect, useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import debounce from "lodash/debounce";
|
||||
// packages
|
||||
import { RichTextEditor } from "@plane/rich-text-editor";
|
||||
// components
|
||||
import { TextArea } from "@plane/ui";
|
||||
import { IssueReaction } from "./reactions";
|
||||
// mobx store
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
// hooks
|
||||
import debounce from "lodash/debounce";
|
||||
import useReloadConfirmations from "hooks/use-reload-confirmation";
|
||||
import useEditorSuggestions from "hooks/use-editor-suggestions";
|
||||
// components
|
||||
import { IssuePeekOverviewReactions } from "components/issues";
|
||||
// ui
|
||||
import { TextArea } from "@plane/ui";
|
||||
// types
|
||||
import { IIssue } from "types";
|
||||
import { IIssue, IUser } from "types";
|
||||
// services
|
||||
import { FileService } from "services/file.service";
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
// constants
|
||||
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||
|
||||
const fileService = new FileService();
|
||||
|
|
@ -22,7 +25,7 @@ interface IPeekOverviewIssueDetails {
|
|||
workspaceSlug: string;
|
||||
issue: IIssue;
|
||||
issueReactions: any;
|
||||
user: any;
|
||||
user: IUser | null;
|
||||
issueUpdate: (issue: Partial<IIssue>) => void;
|
||||
issueReactionCreate: (reaction: string) => void;
|
||||
issueReactionRemove: (reaction: string) => void;
|
||||
|
|
@ -89,7 +92,7 @@ export const PeekOverviewIssueDetails: FC<IPeekOverviewIssueDetails> = (props) =
|
|||
setLocalIssueDescription({ id: issue.id, description_html: issue.description_html });
|
||||
setLocalTitleValue(issue.name);
|
||||
}
|
||||
}, [issue.id]);
|
||||
}, [issue.id, issue.description_html, issue.name]);
|
||||
|
||||
const debouncedFormSave = debounce(async () => {
|
||||
handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting("submitted"));
|
||||
|
|
@ -104,7 +107,7 @@ export const PeekOverviewIssueDetails: FC<IPeekOverviewIssueDetails> = (props) =
|
|||
} else if (isSubmitting === "submitting") {
|
||||
setShowAlert(true);
|
||||
}
|
||||
}, [isSubmitting, setShowAlert]);
|
||||
}, [isSubmitting, setShowAlert, setIsSubmitting]);
|
||||
|
||||
// reset form values
|
||||
useEffect(() => {
|
||||
|
|
@ -165,7 +168,7 @@ export const PeekOverviewIssueDetails: FC<IPeekOverviewIssueDetails> = (props) =
|
|||
<Controller
|
||||
name="description_html"
|
||||
control={control}
|
||||
render={({ field: { value, onChange } }) => (
|
||||
render={({ field: { onChange } }) => (
|
||||
<RichTextEditor
|
||||
cancelUploadImage={fileService.cancelUpload}
|
||||
uploadFile={fileService.getUploadFileFunction(workspaceSlug)}
|
||||
|
|
@ -190,7 +193,7 @@ export const PeekOverviewIssueDetails: FC<IPeekOverviewIssueDetails> = (props) =
|
|||
)}
|
||||
/>
|
||||
</div>
|
||||
<IssueReaction
|
||||
<IssuePeekOverviewReactions
|
||||
issueReactions={issueReactions}
|
||||
user={user}
|
||||
issueReactionCreate={issueReactionCreate}
|
||||
|
|
@ -47,8 +47,6 @@ export const PeekOverviewProperties: FC<IPeekOverviewProperties> = observer((pro
|
|||
|
||||
const {
|
||||
user: { currentProjectRole },
|
||||
cycleIssues: cycleIssueStore,
|
||||
moduleIssues: { addIssueToModule },
|
||||
issueDetail: { fetchPeekIssueDetails },
|
||||
} = useMobxStore();
|
||||
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
export * from "./preview";
|
||||
export * from "./root";
|
||||
export * from "./selector";
|
||||
export * from "./preview";
|
||||
|
|
@ -1,16 +1,18 @@
|
|||
import { FC } from "react";
|
||||
// components
|
||||
import { IssueReactionPreview, IssueReactionSelector } from "./";
|
||||
import { IssueReactionPreview, IssueReactionSelector } from "components/issues";
|
||||
// types
|
||||
import { IUser } from "types";
|
||||
|
||||
interface IIssueReaction {
|
||||
issueReactions: any;
|
||||
user: any;
|
||||
user: IUser | null;
|
||||
issueReactionCreate: (reaction: string) => void;
|
||||
issueReactionRemove: (reaction: string) => void;
|
||||
position?: "top" | "bottom";
|
||||
}
|
||||
|
||||
export const IssueReaction: FC<IIssueReaction> = (props) => {
|
||||
export const IssuePeekOverviewReactions: FC<IIssueReaction> = (props) => {
|
||||
const { issueReactions, user, issueReactionCreate, issueReactionRemove, position = "bottom" } = props;
|
||||
|
||||
const handleReaction = (reaction: string) => {
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
import { FC, Fragment, ReactNode, useEffect } from "react";
|
||||
import { FC, Fragment, ReactNode, useCallback, useEffect } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import useSWR from "swr";
|
||||
// mobx store
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
// hooks
|
||||
import useToast from "hooks/use-toast";
|
||||
// components
|
||||
import { IssueView } from "./view";
|
||||
import { IssueView } from "components/issues";
|
||||
// helpers
|
||||
import { copyUrlToClipboard } from "helpers/string.helper";
|
||||
// types
|
||||
import { IIssue } from "types";
|
||||
// constants
|
||||
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||
|
||||
interface IIssuePeekOverview {
|
||||
|
|
@ -30,27 +30,45 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
|
|||
const { peekIssueId } = router.query;
|
||||
|
||||
const {
|
||||
user: userStore,
|
||||
issue: issueStore,
|
||||
issueDetail: issueDetailStore,
|
||||
archivedIssueDetail: archivedIssueDetailStore,
|
||||
archivedIssues: archivedIssuesStore,
|
||||
project: projectStore,
|
||||
user: { currentProjectRole },
|
||||
issue: { removeIssueFromStructure },
|
||||
issueDetail: {
|
||||
createIssueComment,
|
||||
updateIssueComment,
|
||||
removeIssueComment,
|
||||
creationIssueCommentReaction,
|
||||
removeIssueCommentReaction,
|
||||
createIssueReaction,
|
||||
removeIssueReaction,
|
||||
createIssueSubscription,
|
||||
removeIssueSubscription,
|
||||
getIssue,
|
||||
loader,
|
||||
fetchPeekIssueDetails,
|
||||
setPeekId,
|
||||
fetchIssueActivity,
|
||||
},
|
||||
archivedIssueDetail: {
|
||||
getIssue: getArchivedIssue,
|
||||
loader: archivedIssueLoader,
|
||||
fetchPeekIssueDetails: fetchArchivedPeekIssueDetails,
|
||||
},
|
||||
archivedIssues: { deleteArchivedIssue },
|
||||
project: { currentProjectDetails },
|
||||
} = useMobxStore();
|
||||
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
const fetchIssueDetail = async () => {
|
||||
const fetchIssueDetail = useCallback(async () => {
|
||||
if (workspaceSlug && projectId && peekIssueId) {
|
||||
if (isArchived)
|
||||
await archivedIssueDetailStore.fetchPeekIssueDetails(workspaceSlug, projectId, peekIssueId as string);
|
||||
else await issueDetailStore.fetchPeekIssueDetails(workspaceSlug, projectId, peekIssueId as string);
|
||||
if (isArchived) await fetchArchivedPeekIssueDetails(workspaceSlug, projectId, peekIssueId as string);
|
||||
else await fetchPeekIssueDetails(workspaceSlug, projectId, peekIssueId as string);
|
||||
}
|
||||
};
|
||||
}, [fetchArchivedPeekIssueDetails, fetchPeekIssueDetails, workspaceSlug, projectId, peekIssueId, isArchived]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchIssueDetail();
|
||||
}, [workspaceSlug, projectId, peekIssueId]);
|
||||
}, [workspaceSlug, projectId, peekIssueId, fetchIssueDetail]);
|
||||
|
||||
const handleCopyText = (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
e.stopPropagation();
|
||||
|
|
@ -72,44 +90,43 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
|
|||
});
|
||||
};
|
||||
|
||||
const issue = isArchived ? archivedIssueDetailStore.getIssue : issueDetailStore.getIssue;
|
||||
const isLoading = isArchived ? archivedIssueDetailStore.loader : issueDetailStore.loader;
|
||||
const issue = isArchived ? getArchivedIssue : getIssue;
|
||||
const isLoading = isArchived ? archivedIssueLoader : loader;
|
||||
|
||||
const issueUpdate = (_data: Partial<IIssue>) => {
|
||||
if (handleIssue) handleIssue(_data);
|
||||
const issueUpdate = async (_data: Partial<IIssue>) => {
|
||||
if (handleIssue) {
|
||||
await handleIssue(_data);
|
||||
fetchIssueActivity(workspaceSlug, projectId, issueId);
|
||||
}
|
||||
};
|
||||
|
||||
const issueReactionCreate = (reaction: string) =>
|
||||
issueDetailStore.createIssueReaction(workspaceSlug, projectId, issueId, reaction);
|
||||
const issueReactionCreate = (reaction: string) => createIssueReaction(workspaceSlug, projectId, issueId, reaction);
|
||||
|
||||
const issueReactionRemove = (reaction: string) =>
|
||||
issueDetailStore.removeIssueReaction(workspaceSlug, projectId, issueId, reaction);
|
||||
const issueReactionRemove = (reaction: string) => removeIssueReaction(workspaceSlug, projectId, issueId, reaction);
|
||||
|
||||
const issueCommentCreate = (comment: any) =>
|
||||
issueDetailStore.createIssueComment(workspaceSlug, projectId, issueId, comment);
|
||||
const issueCommentCreate = (comment: any) => createIssueComment(workspaceSlug, projectId, issueId, comment);
|
||||
|
||||
const issueCommentUpdate = (comment: any) =>
|
||||
issueDetailStore.updateIssueComment(workspaceSlug, projectId, issueId, comment?.id, comment);
|
||||
updateIssueComment(workspaceSlug, projectId, issueId, comment?.id, comment);
|
||||
|
||||
const issueCommentRemove = (commentId: string) =>
|
||||
issueDetailStore.removeIssueComment(workspaceSlug, projectId, issueId, commentId);
|
||||
const issueCommentRemove = (commentId: string) => removeIssueComment(workspaceSlug, projectId, issueId, commentId);
|
||||
|
||||
const issueCommentReactionCreate = (commentId: string, reaction: string) =>
|
||||
issueDetailStore.creationIssueCommentReaction(workspaceSlug, projectId, issueId, commentId, reaction);
|
||||
creationIssueCommentReaction(workspaceSlug, projectId, issueId, commentId, reaction);
|
||||
|
||||
const issueCommentReactionRemove = (commentId: string, reaction: string) =>
|
||||
issueDetailStore.removeIssueCommentReaction(workspaceSlug, projectId, issueId, commentId, reaction);
|
||||
removeIssueCommentReaction(workspaceSlug, projectId, issueId, commentId, reaction);
|
||||
|
||||
const issueSubscriptionCreate = () => issueDetailStore.createIssueSubscription(workspaceSlug, projectId, issueId);
|
||||
const issueSubscriptionCreate = () => createIssueSubscription(workspaceSlug, projectId, issueId);
|
||||
|
||||
const issueSubscriptionRemove = () => issueDetailStore.removeIssueSubscription(workspaceSlug, projectId, issueId);
|
||||
const issueSubscriptionRemove = () => removeIssueSubscription(workspaceSlug, projectId, issueId);
|
||||
|
||||
const handleDeleteIssue = async () => {
|
||||
if (isArchived) await archivedIssuesStore.deleteArchivedIssue(workspaceSlug, projectId, issue!);
|
||||
else await issueStore.removeIssueFromStructure(workspaceSlug, projectId, issue!);
|
||||
if (isArchived) await deleteArchivedIssue(workspaceSlug, projectId, issue!);
|
||||
else removeIssueFromStructure(workspaceSlug, projectId, issue!);
|
||||
const { query } = router;
|
||||
if (query.peekIssueId) {
|
||||
issueDetailStore.setPeekId(null);
|
||||
setPeekId(null);
|
||||
delete query.peekIssueId;
|
||||
delete query.peekProjectId;
|
||||
router.push({
|
||||
|
|
@ -119,7 +136,7 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
|
|||
}
|
||||
};
|
||||
|
||||
const userRole = userStore.currentProjectRole ?? EUserWorkspaceRoles.GUEST;
|
||||
const userRole = currentProjectRole ?? EUserWorkspaceRoles.GUEST;
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
|
|
@ -144,7 +161,7 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
|
|||
issueSubscriptionRemove={issueSubscriptionRemove}
|
||||
handleDeleteIssue={handleDeleteIssue}
|
||||
disableUserActions={[5, 10].includes(userRole)}
|
||||
showCommentAccessSpecifier={projectStore.currentProjectDetails?.is_deployed}
|
||||
showCommentAccessSpecifier={currentProjectDetails?.is_deployed}
|
||||
>
|
||||
{children}
|
||||
</IssueView>
|
||||
|
|
@ -3,16 +3,21 @@ import { useRouter } from "next/router";
|
|||
import { observer } from "mobx-react-lite";
|
||||
import useSWR from "swr";
|
||||
import { MoveRight, MoveDiagonal, Bell, Link2, Trash2 } from "lucide-react";
|
||||
// mobx store
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
// components
|
||||
import { PeekOverviewIssueDetails } from "./issue-detail";
|
||||
import { PeekOverviewProperties } from "./properties";
|
||||
import { IssueComment } from "./activity";
|
||||
import {
|
||||
DeleteArchivedIssueModal,
|
||||
DeleteIssueModal,
|
||||
IssueActivity,
|
||||
IssueUpdateStatus,
|
||||
PeekOverviewIssueDetails,
|
||||
PeekOverviewProperties,
|
||||
} from "components/issues";
|
||||
// ui
|
||||
import { Button, CenterPanelIcon, CustomSelect, FullScreenPanelIcon, SidePanelIcon, Spinner } from "@plane/ui";
|
||||
import { DeleteIssueModal, DeleteArchivedIssueModal, IssueUpdateStatus } from "components/issues/";
|
||||
// types
|
||||
import { IIssue } from "types";
|
||||
// hooks
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
|
||||
interface IIssueView {
|
||||
workspaceSlug: string;
|
||||
|
|
@ -41,7 +46,7 @@ interface IIssueView {
|
|||
|
||||
type TPeekModes = "side-peek" | "modal" | "full-screen";
|
||||
|
||||
const peekOptions: { key: TPeekModes; icon: any; title: string }[] = [
|
||||
const PEEK_OPTIONS: { key: TPeekModes; icon: any; title: string }[] = [
|
||||
{
|
||||
key: "side-peek",
|
||||
icon: SidePanelIcon,
|
||||
|
|
@ -86,9 +91,12 @@ export const IssueView: FC<IIssueView> = observer((props) => {
|
|||
} = props;
|
||||
|
||||
const router = useRouter();
|
||||
const { peekIssueId } = router.query as { peekIssueId: string };
|
||||
const { peekIssueId } = router.query;
|
||||
|
||||
const { user: userStore, issueDetail: issueDetailStore } = useMobxStore();
|
||||
const {
|
||||
user: { currentUser },
|
||||
issueDetail: { fetchIssueSubscription, getIssueActivity, getIssueReactions, getIssueSubscription, setPeekId },
|
||||
} = useMobxStore();
|
||||
|
||||
const [peekMode, setPeekMode] = useState<TPeekModes>("side-peek");
|
||||
const [deleteIssueModal, setDeleteIssueModal] = useState(false);
|
||||
|
|
@ -96,7 +104,7 @@ export const IssueView: FC<IIssueView> = observer((props) => {
|
|||
|
||||
const updateRoutePeekId = () => {
|
||||
if (issueId != peekIssueId) {
|
||||
issueDetailStore.setPeekId(issueId);
|
||||
setPeekId(issueId);
|
||||
const { query } = router;
|
||||
router.push({
|
||||
pathname: router.pathname,
|
||||
|
|
@ -104,10 +112,13 @@ export const IssueView: FC<IIssueView> = observer((props) => {
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
const removeRoutePeekId = () => {
|
||||
const { query } = router;
|
||||
|
||||
if (query.peekIssueId) {
|
||||
issueDetailStore.setPeekId(null);
|
||||
setPeekId(null);
|
||||
|
||||
delete query.peekIssueId;
|
||||
delete query.peekProjectId;
|
||||
router.push({
|
||||
|
|
@ -123,18 +134,16 @@ export const IssueView: FC<IIssueView> = observer((props) => {
|
|||
: null,
|
||||
async () => {
|
||||
if (workspaceSlug && projectId && issueId && peekIssueId && issueId === peekIssueId) {
|
||||
await issueDetailStore.fetchIssueSubscription(workspaceSlug, projectId, issueId);
|
||||
await fetchIssueSubscription(workspaceSlug, projectId, issueId);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const issueReactions = issueDetailStore.getIssueReactions || [];
|
||||
const issueComments = issueDetailStore.getIssueComments || [];
|
||||
const issueSubscription = issueDetailStore.getIssueSubscription || [];
|
||||
const issueReactions = getIssueReactions || [];
|
||||
const issueActivity = getIssueActivity;
|
||||
const issueSubscription = getIssueSubscription || [];
|
||||
|
||||
const user = userStore?.currentUser;
|
||||
|
||||
const currentMode = peekOptions.find((m) => m.key === peekMode);
|
||||
const currentMode = PEEK_OPTIONS.find((m) => m.key === peekMode);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -198,7 +207,7 @@ export const IssueView: FC<IIssueView> = observer((props) => {
|
|||
</button>
|
||||
}
|
||||
>
|
||||
{peekOptions.map((mode) => (
|
||||
{PEEK_OPTIONS.map((mode) => (
|
||||
<CustomSelect.Option key={mode.key} value={mode.key}>
|
||||
<div
|
||||
className={`flex items-center gap-1.5 ${
|
||||
|
|
@ -219,8 +228,8 @@ export const IssueView: FC<IIssueView> = observer((props) => {
|
|||
<div className="flex items-center gap-x-4">
|
||||
<IssueUpdateStatus isSubmitting={isSubmitting} />
|
||||
<div className="flex items-center gap-4">
|
||||
{issue?.created_by !== user?.id &&
|
||||
!issue?.assignees.includes(user?.id ?? "") &&
|
||||
{issue?.created_by !== currentUser?.id &&
|
||||
!issue?.assignees.includes(currentUser?.id ?? "") &&
|
||||
!router.pathname.includes("[archivedIssueId]") && (
|
||||
<Button
|
||||
size="sm"
|
||||
|
|
@ -269,7 +278,7 @@ export const IssueView: FC<IIssueView> = observer((props) => {
|
|||
issue={issue}
|
||||
issueUpdate={issueUpdate}
|
||||
issueReactions={issueReactions}
|
||||
user={user}
|
||||
user={currentUser}
|
||||
issueReactionCreate={issueReactionCreate}
|
||||
issueReactionRemove={issueReactionRemove}
|
||||
/>
|
||||
|
|
@ -280,12 +289,12 @@ export const IssueView: FC<IIssueView> = observer((props) => {
|
|||
disableUserActions={disableUserActions}
|
||||
/>
|
||||
|
||||
<IssueComment
|
||||
<IssueActivity
|
||||
workspaceSlug={workspaceSlug}
|
||||
projectId={projectId}
|
||||
issueId={issueId}
|
||||
user={user}
|
||||
issueComments={issueComments}
|
||||
user={currentUser}
|
||||
issueActivity={issueActivity}
|
||||
issueCommentCreate={issueCommentCreate}
|
||||
issueCommentUpdate={issueCommentUpdate}
|
||||
issueCommentRemove={issueCommentRemove}
|
||||
|
|
@ -305,17 +314,17 @@ export const IssueView: FC<IIssueView> = observer((props) => {
|
|||
issue={issue}
|
||||
issueReactions={issueReactions}
|
||||
issueUpdate={issueUpdate}
|
||||
user={user}
|
||||
user={currentUser}
|
||||
issueReactionCreate={issueReactionCreate}
|
||||
issueReactionRemove={issueReactionRemove}
|
||||
/>
|
||||
|
||||
<IssueComment
|
||||
<IssueActivity
|
||||
workspaceSlug={workspaceSlug}
|
||||
projectId={projectId}
|
||||
issueId={issueId}
|
||||
user={user}
|
||||
issueComments={issueComments}
|
||||
user={currentUser}
|
||||
issueActivity={issueActivity}
|
||||
issueCommentCreate={issueCommentCreate}
|
||||
issueCommentUpdate={issueCommentUpdate}
|
||||
issueCommentRemove={issueCommentRemove}
|
||||
|
|
@ -65,7 +65,7 @@ export const SubIssues: React.FC<ISubIssues> = ({
|
|||
workspaceSlug={workspaceSlug}
|
||||
projectId={peekProjectId.toString()}
|
||||
issueId={peekIssueId.toString()}
|
||||
handleIssue={(issueToUpdate) => handleUpdateIssue(issue, { ...issue, ...issueToUpdate })}
|
||||
handleIssue={async (issueToUpdate) => await handleUpdateIssue(issue, { ...issue, ...issueToUpdate })}
|
||||
/>
|
||||
)}
|
||||
<div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue