mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix: quick add not working for labels & assignee (#2689)
* fix: quick add not working for labels & assignee * fix: build error on spreadsheet view
This commit is contained in:
parent
9f206331bc
commit
53e7da08e4
@ -1,57 +1,27 @@
|
|||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
|
|
||||||
// store
|
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
|
// store
|
||||||
import { useMobxStore } from "lib/mobx/store-provider";
|
import { useMobxStore } from "lib/mobx/store-provider";
|
||||||
|
|
||||||
// hooks
|
// hooks
|
||||||
import useToast from "hooks/use-toast";
|
import useToast from "hooks/use-toast";
|
||||||
import useKeypress from "hooks/use-keypress";
|
import useKeypress from "hooks/use-keypress";
|
||||||
import useProjectDetails from "hooks/use-project-details";
|
import useProjectDetails from "hooks/use-project-details";
|
||||||
import useOutsideClickDetector from "hooks/use-outside-click-detector";
|
import useOutsideClickDetector from "hooks/use-outside-click-detector";
|
||||||
|
// helpers
|
||||||
// constants
|
import { createIssuePayload } from "helpers/issue.helper";
|
||||||
import { createIssuePayload } from "constants/issue";
|
|
||||||
|
|
||||||
// icons
|
// icons
|
||||||
import { PlusIcon } from "lucide-react";
|
import { PlusIcon } from "lucide-react";
|
||||||
|
|
||||||
// types
|
// types
|
||||||
import { IIssue } from "types";
|
import { IIssue } from "types";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
groupId?: string;
|
groupId?: string;
|
||||||
dependencies?: any[];
|
|
||||||
prePopulatedData?: Partial<IIssue>;
|
prePopulatedData?: Partial<IIssue>;
|
||||||
onSuccess?: (data: IIssue) => Promise<void> | void;
|
onSuccess?: (data: IIssue) => Promise<void> | void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const useCheckIfThereIsSpaceOnRight = (ref: React.RefObject<HTMLDivElement>, deps: any[]) => {
|
|
||||||
const [isThereSpaceOnRight, setIsThereSpaceOnRight] = useState(true);
|
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
const { moduleId, cycleId, viewId } = router.query;
|
|
||||||
|
|
||||||
const container = document.getElementById(`calendar-view-${cycleId ?? moduleId ?? viewId}`);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!ref.current) return;
|
|
||||||
|
|
||||||
const { right } = ref.current.getBoundingClientRect();
|
|
||||||
|
|
||||||
const width = right;
|
|
||||||
|
|
||||||
const innerWidth = container?.getBoundingClientRect().width ?? window.innerWidth;
|
|
||||||
|
|
||||||
if (width > innerWidth) setIsThereSpaceOnRight(false);
|
|
||||||
else setIsThereSpaceOnRight(true);
|
|
||||||
}, [ref, deps, container]);
|
|
||||||
|
|
||||||
return isThereSpaceOnRight;
|
|
||||||
};
|
|
||||||
|
|
||||||
const defaultValues: Partial<IIssue> = {
|
const defaultValues: Partial<IIssue> = {
|
||||||
name: "",
|
name: "",
|
||||||
};
|
};
|
||||||
@ -80,7 +50,7 @@ const Inputs = (props: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const CalendarInlineCreateIssueForm: React.FC<Props> = observer((props) => {
|
export const CalendarInlineCreateIssueForm: React.FC<Props> = observer((props) => {
|
||||||
const { prePopulatedData, dependencies = [], groupId } = props;
|
const { prePopulatedData, groupId } = props;
|
||||||
|
|
||||||
// router
|
// router
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -135,8 +105,6 @@ export const CalendarInlineCreateIssueForm: React.FC<Props> = observer((props) =
|
|||||||
});
|
});
|
||||||
}, [errors, setToastAlert]);
|
}, [errors, setToastAlert]);
|
||||||
|
|
||||||
const isSpaceOnRight = useCheckIfThereIsSpaceOnRight(ref, dependencies);
|
|
||||||
|
|
||||||
const onSubmitHandler = async (formData: IIssue) => {
|
const onSubmitHandler = async (formData: IIssue) => {
|
||||||
if (isSubmitting || !workspaceSlug || !projectId) return;
|
if (isSubmitting || !workspaceSlug || !projectId) return;
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ import useOutsideClickDetector from "hooks/use-outside-click-detector";
|
|||||||
import { renderDateFormat } from "helpers/date-time.helper";
|
import { renderDateFormat } from "helpers/date-time.helper";
|
||||||
// types
|
// types
|
||||||
import { IIssue } from "types";
|
import { IIssue } from "types";
|
||||||
// constants
|
// helpers
|
||||||
import { createIssuePayload } from "constants/issue";
|
import { createIssuePayload } from "helpers/issue.helper";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
prePopulatedData?: Partial<IIssue>;
|
prePopulatedData?: Partial<IIssue>;
|
||||||
|
@ -2,19 +2,16 @@ import { useEffect, useState, useRef } from "react";
|
|||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { PlusIcon } from "lucide-react";
|
import { PlusIcon } from "lucide-react";
|
||||||
// store
|
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
|
// store
|
||||||
import { useMobxStore } from "lib/mobx/store-provider";
|
import { useMobxStore } from "lib/mobx/store-provider";
|
||||||
|
|
||||||
// hooks
|
// hooks
|
||||||
import useToast from "hooks/use-toast";
|
import useToast from "hooks/use-toast";
|
||||||
import useKeypress from "hooks/use-keypress";
|
import useKeypress from "hooks/use-keypress";
|
||||||
import useProjectDetails from "hooks/use-project-details";
|
import useProjectDetails from "hooks/use-project-details";
|
||||||
import useOutsideClickDetector from "hooks/use-outside-click-detector";
|
import useOutsideClickDetector from "hooks/use-outside-click-detector";
|
||||||
|
// helpers
|
||||||
// constants
|
import { createIssuePayload } from "helpers/issue.helper";
|
||||||
import { createIssuePayload } from "constants/issue";
|
|
||||||
|
|
||||||
// types
|
// types
|
||||||
import { IIssue } from "types";
|
import { IIssue } from "types";
|
||||||
|
|
||||||
|
@ -1,23 +1,19 @@
|
|||||||
import { useEffect, useState, useRef } from "react";
|
import { useEffect, useState, useRef } from "react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
|
import { observer } from "mobx-react-lite";
|
||||||
|
import { PlusIcon } from "lucide-react";
|
||||||
// hooks
|
// hooks
|
||||||
import useToast from "hooks/use-toast";
|
import useToast from "hooks/use-toast";
|
||||||
import useKeypress from "hooks/use-keypress";
|
import useKeypress from "hooks/use-keypress";
|
||||||
import useProjectDetails from "hooks/use-project-details";
|
import useProjectDetails from "hooks/use-project-details";
|
||||||
import useOutsideClickDetector from "hooks/use-outside-click-detector";
|
import useOutsideClickDetector from "hooks/use-outside-click-detector";
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { observer } from "mobx-react-lite";
|
|
||||||
import { useMobxStore } from "lib/mobx/store-provider";
|
import { useMobxStore } from "lib/mobx/store-provider";
|
||||||
|
// helpers
|
||||||
// constants
|
import { createIssuePayload } from "helpers/issue.helper";
|
||||||
import { createIssuePayload } from "constants/issue";
|
|
||||||
|
|
||||||
// types
|
// types
|
||||||
import { IIssue } from "types";
|
import { IIssue } from "types";
|
||||||
import { PlusIcon } from "lucide-react";
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
groupId?: string;
|
groupId?: string;
|
||||||
|
@ -1,23 +1,19 @@
|
|||||||
import { useEffect, useState, useRef } from "react";
|
import { useEffect, useState, useRef } from "react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
|
import { observer } from "mobx-react-lite";
|
||||||
|
import { PlusIcon } from "lucide-react";
|
||||||
// hooks
|
// hooks
|
||||||
import useToast from "hooks/use-toast";
|
import useToast from "hooks/use-toast";
|
||||||
import useKeypress from "hooks/use-keypress";
|
import useKeypress from "hooks/use-keypress";
|
||||||
import useProjectDetails from "hooks/use-project-details";
|
import useProjectDetails from "hooks/use-project-details";
|
||||||
import useOutsideClickDetector from "hooks/use-outside-click-detector";
|
import useOutsideClickDetector from "hooks/use-outside-click-detector";
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { observer } from "mobx-react-lite";
|
|
||||||
import { useMobxStore } from "lib/mobx/store-provider";
|
import { useMobxStore } from "lib/mobx/store-provider";
|
||||||
|
// helpers
|
||||||
// constants
|
import { createIssuePayload } from "helpers/issue.helper";
|
||||||
import { createIssuePayload } from "constants/issue";
|
|
||||||
|
|
||||||
// types
|
// types
|
||||||
import { IIssue } from "types";
|
import { IIssue } from "types";
|
||||||
import { PlusIcon } from "lucide-react";
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
groupId?: string;
|
groupId?: string;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { v4 as uuidv4 } from "uuid";
|
|
||||||
// icons
|
// icons
|
||||||
import { Calendar, GanttChartSquare, Kanban, List, Sheet } from "lucide-react";
|
import { Calendar, GanttChartSquare, Kanban, List, Sheet } from "lucide-react";
|
||||||
// types
|
// types
|
||||||
@ -12,9 +11,6 @@ import {
|
|||||||
TIssuePriorities,
|
TIssuePriorities,
|
||||||
TIssueTypeFilters,
|
TIssueTypeFilters,
|
||||||
TStateGroups,
|
TStateGroups,
|
||||||
IIssue,
|
|
||||||
IProject,
|
|
||||||
IWorkspace,
|
|
||||||
} from "types";
|
} from "types";
|
||||||
|
|
||||||
export const ISSUE_PRIORITIES: {
|
export const ISSUE_PRIORITIES: {
|
||||||
@ -420,72 +416,3 @@ export const groupReactionEmojis = (reactions: any) => {
|
|||||||
|
|
||||||
return _groupedEmojis;
|
return _groupedEmojis;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param workspaceDetail workspace detail to be added in the issue payload
|
|
||||||
* @param projectDetail project detail to be added in the issue payload
|
|
||||||
* @param formData partial issue data from the form. This will override the default values
|
|
||||||
* @returns full issue payload with some default values
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const createIssuePayload: (
|
|
||||||
workspaceDetail: IWorkspace,
|
|
||||||
projectDetail: IProject,
|
|
||||||
formData: Partial<IIssue>
|
|
||||||
) => IIssue = (workspaceDetail: IWorkspace, projectDetail: IProject, formData: Partial<IIssue>) => {
|
|
||||||
const payload = {
|
|
||||||
archived_at: null,
|
|
||||||
assignees: [],
|
|
||||||
assignee_details: [],
|
|
||||||
attachment_count: 0,
|
|
||||||
attachments: [],
|
|
||||||
issue_relations: [],
|
|
||||||
related_issues: [],
|
|
||||||
bridge_id: null,
|
|
||||||
completed_at: new Date(),
|
|
||||||
created_at: "",
|
|
||||||
created_by: "",
|
|
||||||
cycle: null,
|
|
||||||
cycle_id: null,
|
|
||||||
cycle_detail: null,
|
|
||||||
description: {},
|
|
||||||
description_html: "",
|
|
||||||
description_stripped: "",
|
|
||||||
estimate_point: null,
|
|
||||||
issue_cycle: null,
|
|
||||||
issue_link: [],
|
|
||||||
issue_module: null,
|
|
||||||
labels: [],
|
|
||||||
label_details: [],
|
|
||||||
is_draft: false,
|
|
||||||
links_list: [],
|
|
||||||
link_count: 0,
|
|
||||||
module: null,
|
|
||||||
module_id: null,
|
|
||||||
name: "",
|
|
||||||
parent: null,
|
|
||||||
parent_detail: null,
|
|
||||||
priority: "none",
|
|
||||||
project: projectDetail.id,
|
|
||||||
project_detail: projectDetail,
|
|
||||||
sequence_id: 0,
|
|
||||||
sort_order: 0,
|
|
||||||
sprints: null,
|
|
||||||
start_date: null,
|
|
||||||
state: projectDetail.default_state,
|
|
||||||
state_detail: {} as any,
|
|
||||||
sub_issues_count: 0,
|
|
||||||
target_date: null,
|
|
||||||
updated_at: "",
|
|
||||||
updated_by: "",
|
|
||||||
workspace: workspaceDetail.id,
|
|
||||||
workspace_detail: workspaceDetail,
|
|
||||||
id: uuidv4(),
|
|
||||||
tempId: uuidv4(),
|
|
||||||
// to be overridden by the form data
|
|
||||||
...formData,
|
|
||||||
} as IIssue;
|
|
||||||
|
|
||||||
return payload;
|
|
||||||
};
|
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
|
import { v4 as uuidv4 } from "uuid";
|
||||||
// helpers
|
// helpers
|
||||||
import { orderArrayBy } from "helpers/array.helper";
|
import { orderArrayBy } from "helpers/array.helper";
|
||||||
// types
|
// types
|
||||||
import { IIssue, TIssueGroupByOptions, TIssueLayouts, TIssueOrderByOptions, TIssueParams } from "types";
|
import {
|
||||||
|
IIssue,
|
||||||
|
TIssueGroupByOptions,
|
||||||
|
TIssueLayouts,
|
||||||
|
TIssueOrderByOptions,
|
||||||
|
TIssueParams,
|
||||||
|
IProject,
|
||||||
|
IWorkspace,
|
||||||
|
} from "types";
|
||||||
// constants
|
// constants
|
||||||
import { ISSUE_DISPLAY_FILTERS_BY_LAYOUT } from "constants/issue";
|
import { ISSUE_DISPLAY_FILTERS_BY_LAYOUT } from "constants/issue";
|
||||||
|
|
||||||
@ -109,3 +118,82 @@ export const handleIssueQueryParamsByLayout = (
|
|||||||
|
|
||||||
return queryParams;
|
return queryParams;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @description create a full issue payload with some default values. This function also parse the form field
|
||||||
|
* like assignees, labels, etc. and add them to the payload
|
||||||
|
* @param workspaceDetail workspace detail to be added in the issue payload
|
||||||
|
* @param projectDetail project detail to be added in the issue payload
|
||||||
|
* @param formData partial issue data from the form. This will override the default values
|
||||||
|
* @returns full issue payload with some default values
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const createIssuePayload: (
|
||||||
|
workspaceDetail: IWorkspace,
|
||||||
|
projectDetail: IProject,
|
||||||
|
formData: Partial<IIssue>
|
||||||
|
) => IIssue = (workspaceDetail: IWorkspace, projectDetail: IProject, formData: Partial<IIssue>) => {
|
||||||
|
const payload = {
|
||||||
|
archived_at: null,
|
||||||
|
assignee_details: [],
|
||||||
|
attachment_count: 0,
|
||||||
|
attachments: [],
|
||||||
|
issue_relations: [],
|
||||||
|
related_issues: [],
|
||||||
|
bridge_id: null,
|
||||||
|
completed_at: new Date(),
|
||||||
|
created_at: "",
|
||||||
|
created_by: "",
|
||||||
|
cycle: null,
|
||||||
|
cycle_id: null,
|
||||||
|
cycle_detail: null,
|
||||||
|
description: {},
|
||||||
|
description_html: "",
|
||||||
|
description_stripped: "",
|
||||||
|
estimate_point: null,
|
||||||
|
issue_cycle: null,
|
||||||
|
issue_link: [],
|
||||||
|
issue_module: null,
|
||||||
|
label_details: [],
|
||||||
|
is_draft: false,
|
||||||
|
links_list: [],
|
||||||
|
link_count: 0,
|
||||||
|
module: null,
|
||||||
|
module_id: null,
|
||||||
|
name: "",
|
||||||
|
parent: null,
|
||||||
|
parent_detail: null,
|
||||||
|
priority: "none",
|
||||||
|
project: projectDetail.id,
|
||||||
|
project_detail: projectDetail,
|
||||||
|
sequence_id: 0,
|
||||||
|
sort_order: 0,
|
||||||
|
sprints: null,
|
||||||
|
start_date: null,
|
||||||
|
state: projectDetail.default_state,
|
||||||
|
state_detail: {} as any,
|
||||||
|
sub_issues_count: 0,
|
||||||
|
target_date: null,
|
||||||
|
updated_at: "",
|
||||||
|
updated_by: "",
|
||||||
|
workspace: workspaceDetail.id,
|
||||||
|
workspace_detail: workspaceDetail,
|
||||||
|
id: uuidv4(),
|
||||||
|
tempId: uuidv4(),
|
||||||
|
// to be overridden by the form data
|
||||||
|
...formData,
|
||||||
|
assignees: Array.isArray(formData.assignees)
|
||||||
|
? formData.assignees
|
||||||
|
: formData.assignees && formData.assignees !== "none" && formData.assignees !== null
|
||||||
|
? [formData.assignees]
|
||||||
|
: [],
|
||||||
|
labels: Array.isArray(formData.labels)
|
||||||
|
? formData.labels
|
||||||
|
: formData.labels && formData.labels !== "none" && formData.labels !== null
|
||||||
|
? [formData.labels]
|
||||||
|
: [],
|
||||||
|
} as IIssue;
|
||||||
|
|
||||||
|
return payload;
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user