fix: create new issue when grouped by label (#1308)

This commit is contained in:
Aaryan Khandelwal 2023-06-23 11:08:53 +05:30 committed by GitHub
parent e7bb580289
commit f839150741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 43 deletions

View File

@ -2,11 +2,12 @@
import useProjectIssuesView from "hooks/use-issues-view";
// components
import { SingleBoard } from "components/core/board-view/single-board";
// icons
import { getStateGroupIcon } from "components/icons";
// helpers
import { addSpaceIfCamelCase } from "helpers/string.helper";
// types
import { ICurrentUserResponse, IIssue, IState, UserAuth } from "types";
import { getStateGroupIcon } from "components/icons";
type Props = {
type: "issue" | "cycle" | "module";

View File

@ -166,7 +166,7 @@ export const BoardHeader: React.FC<Props> = ({
<ArrowsPointingOutIcon className="h-4 w-4" />
)}
</button>
{!isCompleted && (
{!isCompleted && selectedGroup !== "created_by" && (
<button
type="button"
className="grid h-7 w-7 place-items-center rounded p-1 text-brand-secondary outline-none duration-300 hover:bg-brand-surface-2"

View File

@ -145,43 +145,45 @@ export const SingleBoard: React.FC<Props> = ({
{provided.placeholder}
</span>
</div>
<div>
{type === "issue" ? (
<button
type="button"
className="flex items-center gap-2 font-medium text-brand-accent outline-none p-1"
onClick={addIssueToState}
>
<PlusIcon className="h-4 w-4" />
Add Issue
</button>
) : (
!isCompleted && (
<CustomMenu
customButton={
<button
type="button"
className="flex items-center gap-2 font-medium text-brand-accent outline-none"
>
<PlusIcon className="h-4 w-4" />
Add Issue
</button>
}
position="left"
noBorder
{selectedGroup !== "created_by" && (
<div>
{type === "issue" ? (
<button
type="button"
className="flex items-center gap-2 font-medium text-brand-accent outline-none p-1"
onClick={addIssueToState}
>
<CustomMenu.MenuItem onClick={addIssueToState}>
Create new
</CustomMenu.MenuItem>
{openIssuesListModal && (
<CustomMenu.MenuItem onClick={openIssuesListModal}>
Add an existing issue
<PlusIcon className="h-4 w-4" />
Add Issue
</button>
) : (
!isCompleted && (
<CustomMenu
customButton={
<button
type="button"
className="flex items-center gap-2 font-medium text-brand-accent outline-none"
>
<PlusIcon className="h-4 w-4" />
Add Issue
</button>
}
position="left"
noBorder
>
<CustomMenu.MenuItem onClick={addIssueToState}>
Create new
</CustomMenu.MenuItem>
)}
</CustomMenu>
)
)}
</div>
{openIssuesListModal && (
<CustomMenu.MenuItem onClick={openIssuesListModal}>
Add an existing issue
</CustomMenu.MenuItem>
)}
</CustomMenu>
)
)}
</div>
)}
</div>
)}
</StrictModeDroppable>

View File

@ -72,9 +72,9 @@ export const ExistingIssuesListModal: React.FC<Props> = ({
const onSubmit: SubmitHandler<FormInput> = async (data) => {
if (!data.issues || data.issues.length === 0) {
setToastAlert({
title: "Error",
type: "error",
message: "Please select atleast one issue",
title: "Error!",
message: "Please select at least one issue.",
});
return;

View File

@ -283,9 +283,17 @@ export const IssuesView: React.FC<Props> = ({
const addIssueToState = useCallback(
(groupTitle: string) => {
setCreateIssueModal(true);
let preloadedValue: string | string[] = groupTitle;
if (selectedGroup === "labels") {
if (groupTitle === "None") preloadedValue = [];
else preloadedValue = [groupTitle];
}
if (selectedGroup)
setPreloadedData({
[selectedGroup]: groupTitle,
[selectedGroup]: preloadedValue,
actionType: "createIssue",
});
else setPreloadedData({ actionType: "createIssue" });

View File

@ -6,6 +6,10 @@ import useSWR from "swr";
// headless ui
import { Combobox, Transition } from "@headlessui/react";
// services
import issuesServices from "services/issues.service";
// ui
import { IssueLabelsList } from "components/ui";
// icons
import {
CheckIcon,
@ -14,13 +18,10 @@ import {
RectangleGroupIcon,
TagIcon,
} from "@heroicons/react/24/outline";
// services
import issuesServices from "services/issues.service";
// types
import type { IIssueLabels } from "types";
// fetch-keys
import { PROJECT_ISSUE_LABELS } from "constants/fetch-keys";
import { IssueLabelsList } from "components/ui";
type Props = {
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;