2022-11-30 15:58:45 +00:00
|
|
|
import React, { useState } from "react";
|
2022-11-19 14:21:26 +00:00
|
|
|
// swr
|
|
|
|
import useSWR from "swr";
|
|
|
|
// headless ui
|
|
|
|
import { Listbox, Transition } from "@headlessui/react";
|
|
|
|
// react hook form
|
2022-12-07 23:27:10 +00:00
|
|
|
import { useForm, Controller, UseFormWatch } from "react-hook-form";
|
2022-11-19 14:21:26 +00:00
|
|
|
// services
|
2022-12-12 04:49:52 +00:00
|
|
|
import stateServices from "lib/services/state.service";
|
|
|
|
import issuesServices from "lib/services/issues.service";
|
2022-11-19 14:21:26 +00:00
|
|
|
import workspaceService from "lib/services/workspace.service";
|
|
|
|
// hooks
|
|
|
|
import useUser from "lib/hooks/useUser";
|
2022-12-07 23:27:10 +00:00
|
|
|
import useToast from "lib/hooks/useToast";
|
2022-11-19 14:21:26 +00:00
|
|
|
// fetching keys
|
|
|
|
import {
|
|
|
|
PROJECT_ISSUES_LIST,
|
|
|
|
STATE_LIST,
|
|
|
|
WORKSPACE_MEMBERS,
|
|
|
|
PROJECT_ISSUE_LABELS,
|
|
|
|
} from "constants/fetch-keys";
|
|
|
|
// commons
|
2022-11-24 13:48:18 +00:00
|
|
|
import { classNames, copyTextToClipboard } from "constants/common";
|
2022-12-07 23:27:10 +00:00
|
|
|
import { PRIORITIES } from "constants/";
|
2022-11-19 14:21:26 +00:00
|
|
|
// ui
|
2022-11-29 14:19:39 +00:00
|
|
|
import { Input, Button, Spinner } from "ui";
|
2022-11-30 15:58:45 +00:00
|
|
|
import { Popover } from "@headlessui/react";
|
2022-11-19 14:21:26 +00:00
|
|
|
// icons
|
2022-11-24 13:48:18 +00:00
|
|
|
import {
|
|
|
|
UserIcon,
|
|
|
|
TagIcon,
|
|
|
|
UserGroupIcon,
|
|
|
|
ChevronDownIcon,
|
|
|
|
Squares2X2Icon,
|
|
|
|
ChartBarIcon,
|
|
|
|
ClipboardDocumentIcon,
|
|
|
|
LinkIcon,
|
2022-11-29 14:19:39 +00:00
|
|
|
ArrowPathIcon,
|
2022-12-01 14:29:21 +00:00
|
|
|
CalendarDaysIcon,
|
2022-11-24 13:48:18 +00:00
|
|
|
} from "@heroicons/react/24/outline";
|
2022-11-19 14:21:26 +00:00
|
|
|
// types
|
|
|
|
import type { Control } from "react-hook-form";
|
2022-12-12 04:49:52 +00:00
|
|
|
import type { IIssue, IIssueLabels, IssueResponse, IState, NestedKeyOf } from "types";
|
2022-11-30 15:58:45 +00:00
|
|
|
import { TwitterPicker } from "react-color";
|
2022-12-07 23:27:10 +00:00
|
|
|
import IssuesListModal from "components/project/issues/IssuesListModal";
|
2022-11-19 14:21:26 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
control: Control<IIssue, any>;
|
|
|
|
submitChanges: (formData: Partial<IIssue>) => void;
|
2022-11-24 13:48:18 +00:00
|
|
|
issueDetail: IIssue | undefined;
|
2022-12-07 23:27:10 +00:00
|
|
|
watch: UseFormWatch<IIssue>;
|
2022-11-19 14:21:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const defaultValues: Partial<IIssueLabels> = {
|
|
|
|
name: "",
|
2022-11-30 15:58:45 +00:00
|
|
|
colour: "#ff0000",
|
2022-11-19 14:21:26 +00:00
|
|
|
};
|
|
|
|
|
2022-12-07 23:27:10 +00:00
|
|
|
const IssueDetailSidebar: React.FC<Props> = ({
|
|
|
|
control,
|
|
|
|
watch: watchIssue,
|
|
|
|
submitChanges,
|
|
|
|
issueDetail,
|
|
|
|
}) => {
|
|
|
|
const [isBlockerModalOpen, setIsBlockerModalOpen] = useState(false);
|
|
|
|
const [isBlockedModalOpen, setIsBlockedModalOpen] = useState(false);
|
|
|
|
const [isParentModalOpen, setIsParentModalOpen] = useState(false);
|
|
|
|
|
|
|
|
const { activeWorkspace, activeProject, cycles, issues } = useUser();
|
2022-11-19 14:21:26 +00:00
|
|
|
|
2022-12-01 14:29:21 +00:00
|
|
|
const { setToastAlert } = useToast();
|
|
|
|
|
2022-11-19 14:21:26 +00:00
|
|
|
const { data: states } = useSWR<IState[]>(
|
|
|
|
activeWorkspace && activeProject ? STATE_LIST(activeProject.id) : null,
|
|
|
|
activeWorkspace && activeProject
|
|
|
|
? () => stateServices.getStates(activeWorkspace.slug, activeProject.id)
|
|
|
|
: null
|
|
|
|
);
|
|
|
|
|
2022-12-12 04:49:52 +00:00
|
|
|
const { data: people } = useSWR(
|
2022-12-07 04:45:57 +00:00
|
|
|
activeWorkspace ? WORKSPACE_MEMBERS(activeWorkspace.slug) : null,
|
2022-11-19 14:21:26 +00:00
|
|
|
activeWorkspace ? () => workspaceService.workspaceMembers(activeWorkspace.slug) : null
|
|
|
|
);
|
|
|
|
|
|
|
|
const { data: issueLabels, mutate: issueLabelMutate } = useSWR<IIssueLabels[]>(
|
|
|
|
activeProject && activeWorkspace ? PROJECT_ISSUE_LABELS(activeProject.id) : null,
|
|
|
|
activeProject && activeWorkspace
|
|
|
|
? () => issuesServices.getIssueLabels(activeWorkspace.slug, activeProject.id)
|
|
|
|
: null
|
|
|
|
);
|
|
|
|
|
|
|
|
const {
|
|
|
|
register,
|
|
|
|
handleSubmit,
|
|
|
|
formState: { isSubmitting },
|
|
|
|
reset,
|
2022-11-30 15:58:45 +00:00
|
|
|
watch,
|
|
|
|
control: controlLabel,
|
2022-11-19 14:21:26 +00:00
|
|
|
} = useForm({
|
|
|
|
defaultValues,
|
|
|
|
});
|
|
|
|
|
|
|
|
const onSubmit = (formData: any) => {
|
|
|
|
if (!activeWorkspace || !activeProject || isSubmitting) return;
|
|
|
|
issuesServices
|
|
|
|
.createIssueLabel(activeWorkspace.slug, activeProject.id, formData)
|
|
|
|
.then((res) => {
|
|
|
|
console.log(res);
|
|
|
|
reset(defaultValues);
|
|
|
|
issueLabelMutate((prevData) => [...(prevData ?? []), res], false);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-12-07 23:27:10 +00:00
|
|
|
const sidebarSections: Array<
|
|
|
|
Array<{
|
|
|
|
label: string;
|
|
|
|
name: NestedKeyOf<IIssue>;
|
|
|
|
canSelectMultipleOptions: boolean;
|
|
|
|
icon: (props: any) => JSX.Element;
|
|
|
|
options?: Array<{ label: string; value: any }>;
|
|
|
|
modal: boolean;
|
|
|
|
issuesList?: Array<IIssue>;
|
|
|
|
isOpen?: boolean;
|
|
|
|
setIsOpen?: (arg: boolean) => void;
|
|
|
|
}>
|
|
|
|
> = [
|
2022-11-30 15:58:45 +00:00
|
|
|
[
|
|
|
|
{
|
|
|
|
label: "Status",
|
|
|
|
name: "state",
|
|
|
|
canSelectMultipleOptions: false,
|
|
|
|
icon: Squares2X2Icon,
|
|
|
|
options: states?.map((state) => ({
|
|
|
|
label: state.name,
|
|
|
|
value: state.id,
|
|
|
|
})),
|
2022-12-07 23:27:10 +00:00
|
|
|
modal: false,
|
2022-11-30 15:58:45 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Assignees",
|
|
|
|
name: "assignees_list",
|
|
|
|
canSelectMultipleOptions: true,
|
|
|
|
icon: UserGroupIcon,
|
|
|
|
options: people?.map((person) => ({
|
|
|
|
label: person.member.first_name,
|
|
|
|
value: person.member.id,
|
|
|
|
})),
|
2022-12-07 23:27:10 +00:00
|
|
|
modal: false,
|
2022-11-30 15:58:45 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: "Priority",
|
|
|
|
name: "priority",
|
|
|
|
canSelectMultipleOptions: false,
|
|
|
|
icon: ChartBarIcon,
|
|
|
|
options: PRIORITIES.map((property) => ({
|
|
|
|
label: property,
|
|
|
|
value: property,
|
|
|
|
})),
|
2022-12-07 23:27:10 +00:00
|
|
|
modal: false,
|
2022-11-30 15:58:45 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
2022-12-07 23:27:10 +00:00
|
|
|
label: "Parent",
|
|
|
|
name: "parent",
|
|
|
|
canSelectMultipleOptions: false,
|
2022-11-30 15:58:45 +00:00
|
|
|
icon: UserIcon,
|
2022-12-07 23:27:10 +00:00
|
|
|
issuesList:
|
|
|
|
issues?.results.filter(
|
|
|
|
(i) =>
|
|
|
|
i.id !== issueDetail?.id &&
|
|
|
|
i.id !== issueDetail?.parent &&
|
|
|
|
i.parent !== issueDetail?.id
|
|
|
|
) ?? [],
|
|
|
|
modal: true,
|
|
|
|
isOpen: isParentModalOpen,
|
|
|
|
setIsOpen: setIsParentModalOpen,
|
2022-11-30 15:58:45 +00:00
|
|
|
},
|
2022-12-07 23:27:10 +00:00
|
|
|
// {
|
|
|
|
// label: "Blocker",
|
|
|
|
// name: "blockers_list",
|
|
|
|
// canSelectMultipleOptions: true,
|
|
|
|
// icon: UserIcon,
|
|
|
|
// issuesList: issues?.results.filter((i) => i.id !== issueDetail?.id) ?? [],
|
|
|
|
// modal: true,
|
|
|
|
// isOpen: isBlockerModalOpen,
|
|
|
|
// setIsOpen: setIsBlockerModalOpen,
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// label: "Blocked",
|
|
|
|
// name: "blocked_list",
|
|
|
|
// canSelectMultipleOptions: true,
|
|
|
|
// icon: UserIcon,
|
|
|
|
// issuesList: issues?.results.filter((i) => i.id !== issueDetail?.id) ?? [],
|
|
|
|
// modal: true,
|
|
|
|
// isOpen: isBlockedModalOpen,
|
|
|
|
// setIsOpen: setIsBlockedModalOpen,
|
|
|
|
// },
|
2022-11-30 15:58:45 +00:00
|
|
|
{
|
2022-12-07 23:27:10 +00:00
|
|
|
label: "Target Date",
|
2022-11-30 15:58:45 +00:00
|
|
|
name: "target_date",
|
|
|
|
canSelectMultipleOptions: true,
|
2022-12-01 14:29:21 +00:00
|
|
|
icon: CalendarDaysIcon,
|
2022-12-07 23:27:10 +00:00
|
|
|
modal: false,
|
2022-11-30 15:58:45 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
label: "Cycle",
|
|
|
|
name: "cycle",
|
|
|
|
canSelectMultipleOptions: false,
|
|
|
|
icon: ArrowPathIcon,
|
|
|
|
options: cycles?.map((cycle) => ({
|
|
|
|
label: cycle.name,
|
|
|
|
value: cycle.id,
|
|
|
|
})),
|
2022-12-07 23:27:10 +00:00
|
|
|
modal: false,
|
2022-11-30 15:58:45 +00:00
|
|
|
},
|
|
|
|
],
|
2022-11-24 13:48:18 +00:00
|
|
|
];
|
|
|
|
|
2022-11-29 14:19:39 +00:00
|
|
|
const handleCycleChange = (cycleId: string) => {
|
|
|
|
if (activeWorkspace && activeProject && issueDetail)
|
|
|
|
issuesServices.addIssueToSprint(activeWorkspace.slug, activeProject.id, cycleId, {
|
|
|
|
issue: issueDetail.id,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-11-19 14:21:26 +00:00
|
|
|
return (
|
2022-11-30 15:58:45 +00:00
|
|
|
<div className="h-full w-full divide-y-2 divide-gray-100">
|
|
|
|
<div className="flex justify-between items-center pb-3">
|
|
|
|
<h4 className="text-sm font-medium">
|
|
|
|
{activeProject?.identifier}-{issueDetail?.sequence_id}
|
|
|
|
</h4>
|
|
|
|
<div className="flex items-center gap-2 flex-wrap">
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="p-2 hover:bg-gray-100 border rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 duration-300"
|
|
|
|
onClick={() =>
|
|
|
|
copyTextToClipboard(
|
|
|
|
`https://app.plane.so/projects/${activeProject?.id}/issues/${issueDetail?.id}`
|
|
|
|
)
|
2022-12-01 14:29:21 +00:00
|
|
|
.then(() => {
|
|
|
|
setToastAlert({
|
|
|
|
type: "success",
|
|
|
|
title: "Copied to clipboard",
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
setToastAlert({
|
|
|
|
type: "error",
|
|
|
|
title: "Some error occurred",
|
|
|
|
});
|
|
|
|
})
|
2022-11-30 15:58:45 +00:00
|
|
|
}
|
|
|
|
>
|
|
|
|
<LinkIcon className="h-3.5 w-3.5" />
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="p-2 hover:bg-gray-100 border rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 duration-300"
|
2022-12-01 14:29:21 +00:00
|
|
|
onClick={() =>
|
|
|
|
copyTextToClipboard(`${issueDetail?.id}`)
|
|
|
|
.then(() => {
|
|
|
|
setToastAlert({
|
|
|
|
type: "success",
|
|
|
|
title: "Copied to clipboard",
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
setToastAlert({
|
|
|
|
type: "error",
|
|
|
|
title: "Some error occurred",
|
|
|
|
});
|
|
|
|
})
|
|
|
|
}
|
2022-11-30 15:58:45 +00:00
|
|
|
>
|
|
|
|
<ClipboardDocumentIcon className="h-3.5 w-3.5" />
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="divide-y-2 divide-gray-100">
|
|
|
|
{sidebarSections.map((section, index) => (
|
|
|
|
<div key={index} className="py-1">
|
|
|
|
{section.map((item) => (
|
2022-12-07 23:27:10 +00:00
|
|
|
<div key={item.label} className="flex items-center py-2 flex-wrap">
|
|
|
|
<div className="flex items-center gap-x-2 text-sm sm:basis-1/2">
|
|
|
|
<item.icon className="flex-shrink-0 h-4 w-4" />
|
2022-11-30 15:58:45 +00:00
|
|
|
<p>{item.label}</p>
|
|
|
|
</div>
|
2022-12-07 23:27:10 +00:00
|
|
|
<div className="sm:basis-1/2">
|
2022-11-30 15:58:45 +00:00
|
|
|
{item.name === "target_date" ? (
|
|
|
|
<Controller
|
|
|
|
control={control}
|
|
|
|
name="target_date"
|
|
|
|
render={({ field: { value, onChange } }) => (
|
|
|
|
<input
|
|
|
|
type="date"
|
2022-12-07 23:27:10 +00:00
|
|
|
value={value ?? ""}
|
2022-11-30 15:58:45 +00:00
|
|
|
onChange={(e: any) => {
|
|
|
|
submitChanges({ target_date: e.target.value });
|
|
|
|
onChange(e.target.value);
|
|
|
|
}}
|
2022-12-07 23:27:10 +00:00
|
|
|
className="hover:bg-gray-100 border rounded-md shadow-sm px-2 py-1 cursor-pointer focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 text-xs duration-300 w-full"
|
2022-11-30 15:58:45 +00:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
2022-12-07 23:27:10 +00:00
|
|
|
) : item.modal ? (
|
|
|
|
<Controller
|
|
|
|
control={control}
|
|
|
|
name={item.name as keyof IIssue}
|
|
|
|
render={({ field: { value, onChange } }) => (
|
|
|
|
<>
|
|
|
|
<IssuesListModal
|
|
|
|
isOpen={Boolean(item?.isOpen)}
|
|
|
|
handleClose={() => item.setIsOpen && item.setIsOpen(false)}
|
|
|
|
onChange={(val) => {
|
|
|
|
console.log(val);
|
|
|
|
// submitChanges({ [item.name]: val });
|
|
|
|
onChange(val);
|
|
|
|
}}
|
|
|
|
issues={item?.issuesList ?? []}
|
|
|
|
title={`Select ${item.label}`}
|
|
|
|
multiple={item.canSelectMultipleOptions}
|
|
|
|
value={value}
|
|
|
|
/>
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="flex justify-between items-center gap-1 hover:bg-gray-100 border rounded-md shadow-sm px-2 py-1 cursor-pointer focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 text-xs duration-300 w-full"
|
|
|
|
onClick={() => item.setIsOpen && item.setIsOpen(true)}
|
|
|
|
>
|
|
|
|
{watchIssue(`${item.name as keyof IIssue}`) &&
|
|
|
|
watchIssue(`${item.name as keyof IIssue}`) !== ""
|
|
|
|
? `${activeProject?.identifier}-
|
|
|
|
${
|
|
|
|
issues?.results.find(
|
|
|
|
(i) => i.id === watchIssue(`${item.name as keyof IIssue}`)
|
|
|
|
)?.sequence_id
|
|
|
|
}`
|
|
|
|
: `Select ${item.label}`}
|
|
|
|
</button>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
/>
|
2022-11-30 15:58:45 +00:00
|
|
|
) : (
|
|
|
|
<Controller
|
|
|
|
control={control}
|
|
|
|
name={item.name as keyof IIssue}
|
|
|
|
render={({ field: { value } }) => (
|
|
|
|
<Listbox
|
|
|
|
as="div"
|
|
|
|
value={value}
|
|
|
|
multiple={item.canSelectMultipleOptions}
|
|
|
|
onChange={(value: any) => {
|
|
|
|
if (item.name === "cycle") handleCycleChange(value);
|
|
|
|
else submitChanges({ [item.name]: value });
|
|
|
|
}}
|
|
|
|
className="flex-shrink-0"
|
|
|
|
>
|
|
|
|
{({ open }) => (
|
|
|
|
<div className="relative">
|
2022-12-07 23:27:10 +00:00
|
|
|
<Listbox.Button className="flex justify-between items-center gap-1 hover:bg-gray-100 border rounded-md shadow-sm px-2 w-full py-1 cursor-pointer focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 text-xs duration-300">
|
2022-11-30 15:58:45 +00:00
|
|
|
<span
|
|
|
|
className={classNames(
|
|
|
|
value ? "" : "text-gray-900",
|
2022-12-07 23:27:10 +00:00
|
|
|
"hidden truncate sm:block text-left",
|
2022-11-30 15:58:45 +00:00
|
|
|
item.label === "Priority" ? "capitalize" : ""
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
{value
|
|
|
|
? Array.isArray(value)
|
|
|
|
? value
|
|
|
|
.map(
|
|
|
|
(i: any) =>
|
|
|
|
item.options?.find((option) => option.value === i)
|
|
|
|
?.label
|
|
|
|
)
|
|
|
|
.join(", ") || item.label
|
|
|
|
: item.options?.find((option) => option.value === value)
|
|
|
|
?.label
|
|
|
|
: "None"}
|
|
|
|
</span>
|
|
|
|
<ChevronDownIcon className="h-3 w-3" />
|
|
|
|
</Listbox.Button>
|
2022-11-24 13:48:18 +00:00
|
|
|
|
2022-11-30 15:58:45 +00:00
|
|
|
<Transition
|
|
|
|
show={open}
|
|
|
|
as={React.Fragment}
|
|
|
|
leave="transition ease-in duration-100"
|
|
|
|
leaveFrom="opacity-100"
|
|
|
|
leaveTo="opacity-0"
|
|
|
|
>
|
|
|
|
<Listbox.Options className="absolute z-10 right-0 mt-1 w-40 bg-white shadow-lg max-h-28 rounded-md py-1 text-xs ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none">
|
|
|
|
<div className="p-1">
|
|
|
|
{item.options ? (
|
|
|
|
item.options.length > 0 ? (
|
|
|
|
item.options.map((option) => (
|
|
|
|
<Listbox.Option
|
|
|
|
key={option.value}
|
|
|
|
className={({ active, selected }) =>
|
|
|
|
`${
|
|
|
|
active || selected
|
|
|
|
? "text-white bg-theme"
|
|
|
|
: "text-gray-900"
|
|
|
|
} ${
|
|
|
|
item.label === "Priority" && "capitalize"
|
|
|
|
} cursor-pointer select-none relative p-2 rounded-md truncate`
|
|
|
|
}
|
|
|
|
value={option.value}
|
|
|
|
>
|
|
|
|
{option.label}
|
|
|
|
</Listbox.Option>
|
|
|
|
))
|
|
|
|
) : (
|
|
|
|
<div className="text-center">No {item.label}s found</div>
|
|
|
|
)
|
|
|
|
) : (
|
|
|
|
<Spinner />
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</Listbox.Options>
|
|
|
|
</Transition>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</Listbox>
|
2022-11-19 14:21:26 +00:00
|
|
|
)}
|
2022-11-30 15:58:45 +00:00
|
|
|
/>
|
2022-11-19 14:21:26 +00:00
|
|
|
)}
|
2022-11-30 15:58:45 +00:00
|
|
|
</div>
|
2022-11-19 14:21:26 +00:00
|
|
|
</div>
|
2022-11-30 15:58:45 +00:00
|
|
|
))}
|
2022-11-19 14:21:26 +00:00
|
|
|
</div>
|
2022-11-30 15:58:45 +00:00
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
<div className="space-y-2 pt-3">
|
|
|
|
<h5 className="text-xs font-medium">Add new label</h5>
|
|
|
|
<form className="flex items-center gap-x-2" onSubmit={handleSubmit(onSubmit)}>
|
|
|
|
<div>
|
|
|
|
<Popover className="relative">
|
|
|
|
{({ open }) => (
|
|
|
|
<>
|
|
|
|
<Popover.Button
|
|
|
|
className={`bg-white flex items-center gap-1 rounded-md p-1 outline-none focus:ring-2 focus:ring-indigo-500`}
|
2022-11-19 14:21:26 +00:00
|
|
|
>
|
2022-11-30 15:58:45 +00:00
|
|
|
{watch("colour") && watch("colour") !== "" && (
|
|
|
|
<span
|
|
|
|
className="w-6 h-6 rounded"
|
|
|
|
style={{
|
|
|
|
backgroundColor: watch("colour") ?? "green",
|
|
|
|
}}
|
|
|
|
></span>
|
|
|
|
)}
|
|
|
|
<ChevronDownIcon className="h-4 w-4" />
|
|
|
|
</Popover.Button>
|
2022-11-19 14:21:26 +00:00
|
|
|
|
2022-11-30 15:58:45 +00:00
|
|
|
<Transition
|
|
|
|
as={React.Fragment}
|
|
|
|
enter="transition ease-out duration-200"
|
|
|
|
enterFrom="opacity-0 translate-y-1"
|
|
|
|
enterTo="opacity-100 translate-y-0"
|
|
|
|
leave="transition ease-in duration-150"
|
|
|
|
leaveFrom="opacity-100 translate-y-0"
|
|
|
|
leaveTo="opacity-0 translate-y-1"
|
|
|
|
>
|
|
|
|
<Popover.Panel className="absolute z-10 transform right-0 mt-1 px-2 max-w-xs sm:px-0">
|
|
|
|
<Controller
|
|
|
|
name="colour"
|
|
|
|
control={controlLabel}
|
|
|
|
render={({ field: { value, onChange } }) => (
|
|
|
|
<TwitterPicker color={value} onChange={(value) => onChange(value.hex)} />
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</Popover.Panel>
|
|
|
|
</Transition>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</Popover>
|
|
|
|
</div>
|
|
|
|
<Input
|
|
|
|
id="name"
|
|
|
|
name="name"
|
|
|
|
placeholder="Title"
|
|
|
|
register={register}
|
|
|
|
validations={{
|
|
|
|
required: "This is required",
|
|
|
|
}}
|
|
|
|
autoComplete="off"
|
|
|
|
/>
|
|
|
|
<Button type="submit" disabled={isSubmitting}>
|
|
|
|
+
|
|
|
|
</Button>
|
|
|
|
</form>
|
2022-12-07 23:27:10 +00:00
|
|
|
<div className="flex justify-between items-center">
|
|
|
|
<div className="flex items-center gap-x-2 text-sm basis-1/2">
|
2022-11-30 15:58:45 +00:00
|
|
|
<TagIcon className="w-4 h-4" />
|
|
|
|
<p>Label</p>
|
|
|
|
</div>
|
2022-12-07 23:27:10 +00:00
|
|
|
<div className="basis-1/2">
|
2022-11-30 15:58:45 +00:00
|
|
|
<Controller
|
|
|
|
control={control}
|
|
|
|
name="labels_list"
|
|
|
|
render={({ field: { value } }) => (
|
|
|
|
<Listbox
|
|
|
|
as="div"
|
|
|
|
value={value}
|
|
|
|
multiple
|
|
|
|
onChange={(value: any) => submitChanges({ labels_list: value })}
|
|
|
|
className="flex-shrink-0"
|
|
|
|
>
|
|
|
|
{({ open }) => (
|
|
|
|
<>
|
|
|
|
<Listbox.Label className="sr-only">Label</Listbox.Label>
|
|
|
|
<div className="relative">
|
2022-12-07 23:27:10 +00:00
|
|
|
<Listbox.Button className="flex justify-between items-center gap-1 hover:bg-gray-100 border rounded-md shadow-sm px-2 w-full py-1 cursor-pointer focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 text-xs duration-300">
|
2022-11-30 15:58:45 +00:00
|
|
|
<span
|
|
|
|
className={classNames(
|
|
|
|
value ? "" : "text-gray-900",
|
2022-12-07 23:27:10 +00:00
|
|
|
"hidden truncate capitalize sm:block text-left"
|
2022-11-30 15:58:45 +00:00
|
|
|
)}
|
2022-11-19 14:21:26 +00:00
|
|
|
>
|
2022-11-30 15:58:45 +00:00
|
|
|
{value && value.length > 0
|
|
|
|
? value
|
|
|
|
.map(
|
|
|
|
(i: string) =>
|
|
|
|
issueLabels?.find((option) => option.id === i)?.name
|
2022-11-29 14:19:39 +00:00
|
|
|
)
|
2022-11-30 15:58:45 +00:00
|
|
|
.join(", ")
|
|
|
|
: "None"}
|
|
|
|
</span>
|
|
|
|
<ChevronDownIcon className="h-3 w-3" />
|
|
|
|
</Listbox.Button>
|
|
|
|
|
|
|
|
<Transition
|
|
|
|
show={open}
|
|
|
|
as={React.Fragment}
|
|
|
|
leave="transition ease-in duration-100"
|
|
|
|
leaveFrom="opacity-100"
|
|
|
|
leaveTo="opacity-0"
|
|
|
|
>
|
|
|
|
<Listbox.Options className="absolute z-10 right-0 mt-1 w-40 bg-white shadow-lg max-h-28 rounded-md py-1 text-xs ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none">
|
|
|
|
<div className="p-1">
|
|
|
|
{issueLabels ? (
|
|
|
|
issueLabels.length > 0 ? (
|
|
|
|
issueLabels.map((label: IIssueLabels) => (
|
|
|
|
<Listbox.Option
|
|
|
|
key={label.id}
|
|
|
|
className={({ active, selected }) =>
|
|
|
|
`${
|
|
|
|
active || selected
|
|
|
|
? "text-white bg-theme"
|
|
|
|
: "text-gray-900"
|
|
|
|
} flex items-center gap-2 cursor-pointer select-none relative p-2 rounded-md truncate`
|
|
|
|
}
|
|
|
|
value={label.id}
|
|
|
|
>
|
|
|
|
<span
|
|
|
|
className="h-2 w-2 rounded-full flex-shrink-0"
|
|
|
|
style={{ backgroundColor: label.colour ?? "green" }}
|
|
|
|
></span>
|
|
|
|
{label.name}
|
|
|
|
</Listbox.Option>
|
|
|
|
))
|
2022-11-29 14:19:39 +00:00
|
|
|
) : (
|
2022-11-30 15:58:45 +00:00
|
|
|
<div className="text-center">No labels found</div>
|
|
|
|
)
|
|
|
|
) : (
|
|
|
|
<Spinner />
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</Listbox.Options>
|
|
|
|
</Transition>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</Listbox>
|
|
|
|
)}
|
|
|
|
/>
|
2022-11-19 14:21:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default IssueDetailSidebar;
|