style: issue details, list view, kanban card

This commit is contained in:
Aaryan Khandelwal 2022-12-08 04:57:10 +05:30
parent 1368fb9164
commit b1aa389930
32 changed files with 935 additions and 1326 deletions

View file

@ -18,11 +18,10 @@ import {
ArrowsPointingOutIcon,
CalendarDaysIcon,
EllipsisHorizontalIcon,
PencilIcon,
PlusIcon,
} from "@heroicons/react/24/outline";
import Image from "next/image";
import { divide } from "lodash";
import { getPriorityIcon } from "constants/global";
type Props = {
selectedGroup: NestedKeyOf<IIssue> | null;
@ -181,133 +180,116 @@ const SingleBoard: React.FC<Props> = ({
ref={provided.innerRef}
{...provided.draggableProps}
>
<div
className="px-2 py-3 space-y-1.5 select-none"
{...provided.dragHandleProps}
>
<span className="group-hover:text-theme text-sm break-all">
<div className="p-2 select-none" {...provided.dragHandleProps}>
{properties.key && (
<div className="text-xs font-medium text-gray-500 mb-2">
{childIssue.project_detail?.identifier}-{childIssue.sequence_id}
</div>
)}
<h5 className="group-hover:text-theme text-sm break-all mb-3">
{childIssue.name}
</span>
{Object.keys(properties).map(
(key) =>
properties[key as keyof Properties] &&
!Array.isArray(childIssue[key as keyof IIssue]) && (
<div
key={key}
className={`${
key === "name"
? "text-sm mb-2"
: key === "description"
? "text-xs text-black"
: key === "priority"
? `text-xs bg-gray-200 px-2 py-1 mt-2 flex items-center gap-x-1 rounded w-min whitespace-nowrap capitalize font-medium ${
childIssue.priority === "urgent"
? "bg-red-100 text-red-600"
: childIssue.priority === "high"
? "bg-orange-100 text-orange-600"
: childIssue.priority === "medium"
? "bg-yellow-100 text-yellow-500"
: childIssue.priority === "low"
? "bg-green-100 text-green-500"
: "hidden"
}`
: key === "target_date"
? "text-xs bg-indigo-50 px-2 py-1 mt-2 flex items-center gap-x-1 rounded w-min whitespace-nowrap"
: "text-sm text-gray-500"
} gap-1 relative
`}
>
{key === "start_date" && childIssue.start_date !== null && (
<span className="text-sm">
<CalendarDaysIcon className="h-4 w-4" />
{renderShortNumericDateFormat(childIssue.start_date)} -
{childIssue.target_date
? renderShortNumericDateFormat(childIssue.target_date)
: "None"}
</span>
)}
{key === "due_date" && (
<>
<span
className={`flex items-center gap-x-1 group ${
childIssue.target_date === null
? ""
: childIssue.target_date < new Date().toISOString()
? "text-red-600"
: findHowManyDaysLeft(childIssue.target_date) <=
3 && "text-orange-400"
</h5>
<div className="flex items-center gap-x-1 gap-y-2 text-xs flex-wrap">
{properties.priority && (
<div
className={`rounded shadow-sm px-2 py-1 cursor-pointer focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 capitalize ${
childIssue.priority === "high"
? "bg-red-100 text-red-600"
: childIssue.priority === "medium"
? "bg-orange-100 text-orange-500"
: childIssue.priority === "low"
? "bg-green-100 text-green-500"
: "hidden"
}`}
>
{/* {getPriorityIcon(childIssue.priority ?? "")} */}
{childIssue.priority}
</div>
)}
{properties.state && (
<div className="flex-shrink-0 flex items-center gap-1 hover:bg-gray-100 border rounded 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">
<span
className="flex-shrink-0 h-1.5 w-1.5 rounded-full"
style={{ backgroundColor: childIssue.state_detail.color }}
></span>
{addSpaceIfCamelCase(childIssue.state_detail.name)}
</div>
)}
{properties.start_date && (
<div className="flex-shrink-0 flex items-center gap-1 hover:bg-gray-100 border rounded 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">
<CalendarDaysIcon className="h-4 w-4" />
{childIssue.start_date
? renderShortNumericDateFormat(childIssue.start_date)
: "N/A"}
</div>
)}
{properties.target_date && (
<div
className={`flex-shrink-0 group flex items-center gap-1 hover:bg-gray-100 border rounded 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 ${
childIssue.target_date === null
? ""
: childIssue.target_date < new Date().toISOString()
? "text-red-600"
: findHowManyDaysLeft(childIssue.target_date) <= 3 &&
"text-orange-400"
}`}
>
<CalendarDaysIcon className="h-4 w-4" />
{childIssue.target_date
? renderShortNumericDateFormat(childIssue.target_date)
: "N/A"}
{childIssue.target_date && (
<span className="absolute -top-full mb-2 left-4 border transition-opacity opacity-0 group-hover:opacity-100 bg-white rounded px-2 py-1">
{childIssue.target_date < new Date().toISOString()
? `Target date has passed by ${findHowManyDaysLeft(
childIssue.target_date
)} days`
: findHowManyDaysLeft(childIssue.target_date) <= 3
? `Target date is in ${findHowManyDaysLeft(
childIssue.target_date
)} days`
: "Target date"}
</span>
)}
</div>
)}
{properties.assignee && (
<div className="justify-end w-full flex items-center gap-1 text-xs">
{childIssue?.assignee_details?.length > 0 ? (
childIssue?.assignee_details?.map(
(assignee, index: number) => (
<div
key={index}
className={`relative z-[1] h-5 w-5 rounded-full ${
index !== 0 ? "-ml-2.5" : ""
}`}
>
<CalendarDaysIcon className="h-4 w-4" />
{childIssue.target_date
? renderShortNumericDateFormat(childIssue.target_date)
: "N/A"}
{childIssue.target_date && (
<span className="absolute -top-full mb-2 left-4 border transition-opacity opacity-0 group-hover:opacity-100 bg-white rounded px-2 py-1">
{childIssue.target_date < new Date().toISOString()
? `Due date has passed by ${findHowManyDaysLeft(
childIssue.target_date
)} days`
: findHowManyDaysLeft(childIssue.target_date) <= 3
? `Due date is in ${findHowManyDaysLeft(
childIssue.target_date
)} days`
: "Due date"}
</span>
{assignee.avatar && assignee.avatar !== "" ? (
<div className="h-5 w-5 border-2 bg-white border-white rounded-full">
<Image
src={assignee.avatar}
height="100%"
width="100%"
className="rounded-full"
alt={assignee.name}
/>
</div>
) : (
<div
className={`h-5 w-5 bg-gray-700 text-white border-2 border-white grid place-items-center rounded-full`}
>
{assignee.first_name.charAt(0)}
</div>
)}
</span>
</>
)}
{key === "key" && (
<span className="text-xs">
{childIssue.project_detail?.identifier}-
{childIssue.sequence_id}
</span>
)}
{key === "state" && (
<>{addSpaceIfCamelCase(childIssue["state_detail"].name)}</>
)}
{key === "priority" && <>{childIssue.priority}</>}
{/* {key === "description" && <>{childIssue.description}</>} */}
{key === "assignee" ? (
<div className="flex items-center gap-1 text-xs">
{childIssue?.assignee_details?.length > 0 ? (
childIssue?.assignee_details?.map(
(assignee, index: number) => (
<div
key={index}
className={`relative z-[1] h-5 w-5 rounded-full ${
index !== 0 ? "-ml-2.5" : ""
}`}
>
{assignee.avatar && assignee.avatar !== "" ? (
<div className="h-5 w-5 border-2 bg-white border-white rounded-full">
<Image
src={assignee.avatar}
height="100%"
width="100%"
className="rounded-full"
alt={assignee.name}
/>
</div>
) : (
<div
className={`h-5 w-5 bg-gray-700 text-white border-2 border-white grid place-items-center rounded-full`}
>
{assignee.first_name.charAt(0)}
</div>
)}
</div>
)
)
) : (
<span>No assignee.</span>
)}
</div>
) : null}
</div>
)
)}
</div>
)
)
) : (
<span>No assignee.</span>
)}
</div>
)}
</div>
</div>
</a>
</Link>

View file

@ -14,7 +14,7 @@ type Props = {
control: Control<IIssue, any>;
isOpen: boolean;
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
issues: IssueResponse | undefined;
issues: IIssue[];
};
const SelectParent: React.FC<Props> = ({ control, isOpen, setIsOpen, issues }) => {

View file

@ -392,16 +392,16 @@ const CreateUpdateIssuesModal: React.FC<Props> = ({
/> */}
</div>
<div>
<Input
{/* <Input
id="target_date"
label="Due Date"
label="Target Date"
name="target_date"
type="date"
placeholder="Enter name"
autoComplete="off"
error={errors.target_date}
register={register}
/>
/> */}
</div>
<div className="flex items-center flex-wrap gap-2">
<SelectState control={control} setIsOpen={setIsStateModalOpen} />
@ -409,11 +409,25 @@ const CreateUpdateIssuesModal: React.FC<Props> = ({
<SelectPriority control={control} />
<SelectAssignee control={control} />
<SelectLabels control={control} />
<Controller
control={control}
name="target_date"
render={({ field: { value, onChange } }) => (
<input
type="date"
value={value ?? ""}
onChange={(e: any) => {
onChange(e.target.value);
}}
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"
/>
)}
/>
<SelectParent
control={control}
isOpen={parentIssueListModalOpen}
setIsOpen={setParentIssueListModalOpen}
issues={issues}
issues={issues?.results ?? []}
/>
<Menu as="div" className="relative inline-block">
<Menu.Button className="grid place-items-center p-1 hover:bg-gray-100 border rounded-md shadow-sm cursor-pointer focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm duration-300">

View file

@ -2,35 +2,49 @@
import React, { useState } from "react";
// headless ui
import { Combobox, Dialog, Transition } from "@headlessui/react";
// ui
import { Button } from "ui";
// icons
import { MagnifyingGlassIcon, RectangleStackIcon } from "@heroicons/react/24/outline";
// types
import { IIssue, IssueResponse } from "types";
import { IIssue } from "types";
import { classNames } from "constants/common";
import useUser from "lib/hooks/useUser";
type Props = {
isOpen: boolean;
handleClose: () => void;
value?: any;
onChange: (...event: any[]) => void;
issues: IssueResponse | undefined;
issues: IIssue[];
title?: string;
multiple?: boolean;
};
const IssuesListModal: React.FC<Props> = ({ isOpen, handleClose: onClose, onChange, issues }) => {
const IssuesListModal: React.FC<Props> = ({
isOpen,
handleClose: onClose,
value,
onChange,
issues,
title = "Issues",
multiple = false,
}) => {
const [query, setQuery] = useState("");
const [values, setValues] = useState<string[]>([]);
const { activeProject } = useUser();
const handleClose = () => {
onClose();
setQuery("");
setValues([]);
};
const filteredIssues: IIssue[] =
query === ""
? issues?.results ?? []
: issues?.results.filter((issue) => issue.name.toLowerCase().includes(query.toLowerCase())) ??
[];
? issues ?? []
: issues?.filter((issue) => issue.name.toLowerCase().includes(query.toLowerCase())) ?? [];
return (
<>
@ -59,7 +73,14 @@ const IssuesListModal: React.FC<Props> = ({ isOpen, handleClose: onClose, onChan
leaveTo="opacity-0 scale-95"
>
<Dialog.Panel className="relative mx-auto max-w-2xl transform divide-y divide-gray-500 divide-opacity-10 rounded-xl bg-white bg-opacity-80 shadow-2xl ring-1 ring-black ring-opacity-5 backdrop-blur backdrop-filter transition-all">
<Combobox onChange={onChange}>
<Combobox
value={value}
onChange={(val) => {
if (multiple) setValues(val);
else onChange(val);
}}
// multiple={multiple}
>
<div className="relative m-1">
<MagnifyingGlassIcon
className="pointer-events-none absolute top-3.5 left-4 h-5 w-5 text-gray-900 text-opacity-40"
@ -80,7 +101,7 @@ const IssuesListModal: React.FC<Props> = ({ isOpen, handleClose: onClose, onChan
<li className="p-2">
{query === "" && (
<h2 className="mt-4 mb-2 px-3 text-xs font-semibold text-gray-900">
Issues
{title}
</h2>
)}
<ul className="text-sm text-gray-700">
@ -95,20 +116,26 @@ const IssuesListModal: React.FC<Props> = ({ isOpen, handleClose: onClose, onChan
)
}
onClick={() => {
// setIssueIdFromList(issue.id);
handleClose();
if (!multiple) handleClose();
}}
>
<span
className={`h-1.5 w-1.5 block rounded-full`}
style={{
backgroundColor: issue.state_detail.color,
}}
/>
<span className="text-xs text-gray-500">
{activeProject?.identifier}-{issue.sequence_id}
</span>{" "}
{issue.name}
{({ selected }) => (
<>
{multiple ? (
<input type="checkbox" checked={selected} readOnly />
) : null}
<span
className="flex-shrink-0 h-1.5 w-1.5 block rounded-full"
style={{
backgroundColor: issue.state_detail.color,
}}
/>
<span className="flex-shrink-0 text-xs text-gray-500">
{activeProject?.identifier}-{issue.sequence_id}
</span>{" "}
{issue.name}
</>
)}
</Combobox.Option>
))}
</ul>
@ -128,6 +155,16 @@ const IssuesListModal: React.FC<Props> = ({ isOpen, handleClose: onClose, onChan
</div>
)}
</Combobox>
{multiple ? (
<div className="flex justify-end items-center gap-2 p-3">
<Button type="button" theme="danger" size="sm" onClick={handleClose}>
Cancel
</Button>
<Button type="button" size="sm" onClick={() => onChange(values)}>
Add to Cycle
</Button>
</div>
) : null}
</Dialog.Panel>
</Transition.Child>
</div>

View file

@ -1,5 +1,5 @@
// react
import React, { useEffect, useState } from "react";
import React, { useState } from "react";
// next
import Link from "next/link";
import Image from "next/image";
@ -10,7 +10,7 @@ import { Listbox, Transition } from "@headlessui/react";
// icons
import { PencilIcon, TrashIcon } from "@heroicons/react/24/outline";
// types
import { IIssue, IssueResponse, IState, NestedKeyOf, Properties, WorkspaceMember } from "types";
import { IIssue, IssueResponse, NestedKeyOf, Properties, WorkspaceMember } from "types";
// hooks
import useUser from "lib/hooks/useUser";
// fetch keys
@ -20,13 +20,7 @@ import { PROJECT_ISSUES_LIST, WORKSPACE_MEMBERS } from "constants/fetch-keys";
import issuesServices from "lib/services/issues.services";
import workspaceService from "lib/services/workspace.service";
// constants
import {
addSpaceIfCamelCase,
classNames,
renderShortNumericDateFormat,
replaceUnderscoreIfSnakeCase,
} from "constants/common";
import IssuePreviewModal from "../PreviewModal";
import { addSpaceIfCamelCase, classNames, renderShortNumericDateFormat } from "constants/common";
// types
type Props = {
@ -44,9 +38,6 @@ const ListView: React.FC<Props> = ({
setSelectedIssue,
handleDeleteIssue,
}) => {
const [issuePreviewModal, setIssuePreviewModal] = useState(false);
const [previewModalIssueId, setPreviewModalIssueId] = useState<string | null>(null);
const { activeWorkspace, activeProject, states } = useUser();
const partialUpdateIssue = (formData: Partial<IIssue>, issueId: string) => {
@ -74,368 +65,348 @@ const ListView: React.FC<Props> = ({
activeWorkspace ? () => workspaceService.workspaceMembers(activeWorkspace.slug) : null
);
const handleHover = (issueId: string) => {
document.addEventListener("keydown", (e) => {
// if (e.code === "Space") {
// e.preventDefault();
// setPreviewModalIssueId(issueId);
// setIssuePreviewModal(true);
// }
});
};
return (
<div className="mt-4 flex flex-col">
<IssuePreviewModal
isOpen={issuePreviewModal}
setIsOpen={setIssuePreviewModal}
issueId={previewModalIssueId}
/>
<div className="overflow-x-auto">
<div className="inline-block min-w-full p-0.5 align-middle">
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg">
<table className="min-w-full">
<thead className="bg-gray-100">
<tr>
<th
scope="col"
className="px-3 py-3.5 text-left uppercase text-sm font-semibold text-gray-900"
>
NAME
</th>
{Object.keys(properties).map(
(key) =>
properties[key as keyof Properties] && (
<th
key={key}
scope="col"
className="px-3 py-3.5 text-left uppercase text-sm font-semibold text-gray-900"
>
{replaceUnderscoreIfSnakeCase(key)}
</th>
)
)}
<th
scope="col"
className="px-3 py-3.5 text-right text-sm font-semibold text-gray-900"
>
ACTIONS
</th>
</tr>
</thead>
<tbody className="bg-white">
{Object.keys(groupedByIssues).map((singleGroup) => (
<React.Fragment key={singleGroup}>
{selectedGroup !== null ? (
<tr className="border-t border-gray-200">
<th
colSpan={14}
scope="colgroup"
className="bg-gray-50 px-4 py-2 text-left font-medium text-gray-900 capitalize"
>
<div className="mt-4 flex flex-col space-y-5">
{Object.keys(groupedByIssues).map((singleGroup) => (
<div key={singleGroup} className="overflow-x-auto">
<div className="inline-block min-w-full p-0.5 align-middle">
<div className="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg">
<table className="min-w-full">
{selectedGroup !== null ? (
<thead className="bg-gray-100">
<tr>
<th
colSpan={14}
scope="col"
className="px-3 py-3.5 text-left uppercase text-sm font-semibold text-gray-900"
>
<div className="flex items-center gap-2">
{selectedGroup === "state_detail.name" ? (
<span
className="flex-shrink-0 h-1.5 w-1.5 block rounded-full"
style={{
backgroundColor: states?.find((s) => s.name === singleGroup)?.color,
}}
></span>
) : null}
{singleGroup === null || singleGroup === "null"
? selectedGroup === "priority" && "No priority"
: addSpaceIfCamelCase(singleGroup)}
<span className="ml-2 text-gray-500 font-normal text-sm">
{groupedByIssues[singleGroup as keyof IIssue].length}
</span>
</th>
</tr>
) : null}
{groupedByIssues[singleGroup].length > 0
? groupedByIssues[singleGroup].map((issue: IIssue, index: number) => {
const assignees = [
...(issue?.assignees_list ?? []),
...(issue?.assignees ?? []),
]?.map(
(assignee) =>
people?.find((p) => p.member.id === assignee)?.member.email
);
</div>
</th>
</tr>
</thead>
) : (
<thead className="bg-gray-100">
<tr>
<th
colSpan={14}
scope="col"
className="px-3 py-3.5 text-left uppercase text-sm font-semibold text-gray-900"
>
ALL ISSUES
<span className="ml-2 text-gray-500 font-normal text-sm">
{groupedByIssues[singleGroup as keyof IIssue].length}
</span>
</th>
</tr>
</thead>
)}
<tbody className="bg-white">
{groupedByIssues[singleGroup].length > 0
? groupedByIssues[singleGroup].map((issue: IIssue, index: number) => {
const assignees = [
...(issue?.assignees_list ?? []),
...(issue?.assignees ?? []),
]?.map(
(assignee) => people?.find((p) => p.member.id === assignee)?.member.email
);
return (
<tr
key={issue.id}
className={classNames(
index === 0 ? "border-gray-300" : "border-gray-200",
"border-t"
)}
onMouseEnter={() => handleHover(issue.id)}
>
<td className="px-3 py-4 text-sm font-medium text-gray-900 w-[15rem]">
<Link href={`/projects/${issue.project}/issues/${issue.id}`}>
<a className="hover:text-theme duration-300">{issue.name}</a>
</Link>
</td>
{Object.keys(properties).map(
(key) =>
properties[key as keyof Properties] && (
<React.Fragment key={key}>
{(key as keyof Properties) === "key" ? (
<td className="px-3 py-4 font-medium text-gray-900 text-xs whitespace-nowrap">
{activeProject?.identifier}-{issue.sequence_id}
</td>
) : (key as keyof Properties) === "priority" ? (
<td className="px-3 py-4 text-sm font-medium text-gray-900 relative">
<Listbox
as="div"
value={issue.priority}
onChange={(data: string) => {
partialUpdateIssue({ priority: data }, issue.id);
}}
className="flex-shrink-0"
>
{({ open }) => (
<>
<div className="">
<Listbox.Button className="inline-flex items-center whitespace-nowrap rounded-full bg-gray-50 py-1 px-0.5 text-xs font-medium text-gray-500 hover:bg-gray-100 border">
<span
className={classNames(
issue.priority ? "" : "text-gray-900",
"hidden truncate capitalize sm:block w-16"
)}
>
{issue.priority ?? "None"}
</span>
</Listbox.Button>
<Transition
show={open}
as={React.Fragment}
leave="transition ease-in duration-100"
leaveFrom="opacity-100"
leaveTo="opacity-0"
return (
<tr
key={issue.id}
className={classNames(
index === 0 ? "border-gray-300" : "border-gray-200",
"border-t"
)}
>
<td className="px-3 py-4 text-sm font-medium text-gray-900 w-[15rem]">
<Link href={`/projects/${issue.project}/issues/${issue.id}`}>
<a className="hover:text-theme duration-300">{issue.name}</a>
</Link>
</td>
{Object.keys(properties).map(
(key) =>
properties[key as keyof Properties] && (
<React.Fragment key={key}>
{(key as keyof Properties) === "key" ? (
<td className="px-3 py-4 font-medium text-gray-900 text-xs whitespace-nowrap">
{activeProject?.identifier}-{issue.sequence_id}
</td>
) : (key as keyof Properties) === "priority" ? (
<td className="px-3 py-4 text-sm font-medium text-gray-900 relative">
<Listbox
as="div"
value={issue.priority}
onChange={(data: string) => {
partialUpdateIssue({ priority: data }, issue.id);
}}
className="flex-shrink-0"
>
{({ open }) => (
<>
<div className="">
<Listbox.Button className="inline-flex items-center whitespace-nowrap rounded-full bg-gray-50 py-1 px-0.5 text-xs font-medium text-gray-500 hover:bg-gray-100 border">
<span
className={classNames(
issue.priority ? "" : "text-gray-900",
"hidden truncate capitalize sm:block w-16"
)}
>
<Listbox.Options className="absolute z-10 mt-1 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">
{PRIORITIES?.map((priority) => (
<Listbox.Option
key={priority}
className={({ active }) =>
classNames(
active ? "bg-indigo-50" : "bg-white",
"cursor-pointer capitalize select-none px-3 py-2"
{issue.priority ?? "None"}
</span>
</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 mt-1 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">
{PRIORITIES?.map((priority) => (
<Listbox.Option
key={priority}
className={({ active }) =>
classNames(
active ? "bg-indigo-50" : "bg-white",
"cursor-pointer capitalize select-none px-3 py-2"
)
}
value={priority}
>
{priority}
</Listbox.Option>
))}
</Listbox.Options>
</Transition>
</div>
</>
)}
</Listbox>
</td>
) : (key as keyof Properties) === "assignee" ? (
<td className="px-3 py-4 text-sm font-medium text-gray-900 relative">
<Listbox
as="div"
value={issue.assignees}
onChange={(data: any) => {
const newData = issue.assignees ?? [];
if (newData.includes(data)) {
newData.splice(newData.indexOf(data), 1);
} else {
newData.push(data);
}
partialUpdateIssue(
{ assignees_list: newData },
issue.id
);
}}
className="flex-shrink-0"
>
{({ open }) => (
<>
<div>
<Listbox.Button className="rounded-full bg-gray-50 px-5 py-1 text-xs text-gray-500 hover:bg-gray-100 border">
{() => {
if (assignees.length > 0)
return (
<>
{assignees.map((assignee, index) => (
<div
key={index}
className={
"hidden truncate sm:block text-left"
}
>
{assignee}
</div>
))}
</>
);
else return <span>None</span>;
}}
</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 mt-1 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">
{people?.map((person) => (
<Listbox.Option
key={person.id}
className={({ active }) =>
classNames(
active ? "bg-indigo-50" : "bg-white",
"cursor-pointer select-none px-3 py-2"
)
}
value={person.member.id}
>
<div
className={`flex items-center gap-x-1 ${
assignees.includes(
person.member.first_name
)
}
value={priority}
? "font-medium"
: "font-normal"
}`}
>
{priority}
</Listbox.Option>
))}
</Listbox.Options>
</Transition>
</div>
</>
)}
</Listbox>
</td>
) : (key as keyof Properties) === "assignee" ? (
<td className="px-3 py-4 text-sm font-medium text-gray-900 relative">
<Listbox
as="div"
value={issue.assignees}
onChange={(data: any) => {
const newData = issue.assignees ?? [];
if (newData.includes(data)) {
newData.splice(newData.indexOf(data), 1);
} else {
newData.push(data);
}
partialUpdateIssue(
{ assignees_list: newData },
issue.id
);
}}
className="flex-shrink-0"
>
{({ open }) => (
<>
<div>
<Listbox.Button className="rounded-full bg-gray-50 px-5 py-1 text-xs text-gray-500 hover:bg-gray-100 border">
{() => {
if (assignees.length > 0)
return (
<>
{assignees.map((assignee, index) => (
<div
key={index}
className={
"hidden truncate sm:block text-left"
}
>
{assignee}
</div>
))}
</>
);
else return <span>None</span>;
}}
</Listbox.Button>
{person.member.avatar &&
person.member.avatar !== "" ? (
<div className="relative w-4 h-4">
<Image
src={person.member.avatar}
alt="avatar"
className="rounded-full"
layout="fill"
objectFit="cover"
/>
</div>
) : (
<p>
{person.member.first_name.charAt(0)}
</p>
)}
<p>{person.member.first_name}</p>
</div>
</Listbox.Option>
))}
</Listbox.Options>
</Transition>
</div>
</>
)}
</Listbox>
</td>
) : (key as keyof Properties) === "state" ? (
<td className="px-3 py-4 text-sm font-medium text-gray-900 relative">
<Listbox
as="div"
value={issue.state}
onChange={(data: string) => {
partialUpdateIssue({ state: data }, issue.id);
}}
className="flex-shrink-0"
>
{({ open }) => (
<>
<div>
<Listbox.Button
className="inline-flex items-center whitespace-nowrap rounded-full px-2 py-1 text-xs font-medium text-gray-500 hover:bg-gray-100 border"
style={{
border: `2px solid ${issue.state_detail.color}`,
backgroundColor: `${issue.state_detail.color}20`,
}}
>
<span
className={classNames(
issue.state ? "" : "text-gray-900",
"hidden capitalize sm:block w-16"
)}
>
{addSpaceIfCamelCase(issue.state_detail.name)}
</span>
</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 mt-1 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">
{people?.map((person) => (
<Listbox.Option
key={person.id}
className={({ active }) =>
classNames(
active ? "bg-indigo-50" : "bg-white",
"cursor-pointer select-none px-3 py-2"
)
}
value={person.member.id}
>
<div
className={`flex items-center gap-x-1 ${
assignees.includes(
person.member.first_name
)
? "font-medium"
: "font-normal"
}`}
>
{person.member.avatar &&
person.member.avatar !== "" ? (
<div className="relative w-4 h-4">
<Image
src={person.member.avatar}
alt="avatar"
className="rounded-full"
layout="fill"
objectFit="cover"
/>
</div>
) : (
<p>
{person.member.first_name.charAt(0)}
</p>
)}
<p>{person.member.first_name}</p>
</div>
</Listbox.Option>
))}
</Listbox.Options>
</Transition>
</div>
</>
)}
</Listbox>
</td>
) : (key as keyof Properties) === "state" ? (
<td className="px-3 py-4 text-sm font-medium text-gray-900 relative">
<Listbox
as="div"
value={issue.state}
onChange={(data: string) => {
partialUpdateIssue({ state: data }, issue.id);
}}
className="flex-shrink-0"
>
{({ open }) => (
<>
<div>
<Listbox.Button
className="inline-flex items-center whitespace-nowrap rounded-full px-2 py-1 text-xs font-medium text-gray-500 hover:bg-gray-100 border"
style={{
border: `2px solid ${issue.state_detail.color}`,
backgroundColor: `${issue.state_detail.color}20`,
}}
>
<span
className={classNames(
issue.state ? "" : "text-gray-900",
"hidden capitalize sm:block w-16"
)}
>
{addSpaceIfCamelCase(issue.state_detail.name)}
</span>
</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 mt-1 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">
{states?.map((state) => (
<Listbox.Option
key={state.id}
className={({ active }) =>
classNames(
active ? "bg-indigo-50" : "bg-white",
"cursor-pointer select-none px-3 py-2"
)
}
value={state.id}
>
{addSpaceIfCamelCase(state.name)}
</Listbox.Option>
))}
</Listbox.Options>
</Transition>
</div>
</>
)}
</Listbox>
</td>
) : (key as keyof Properties) === "due_date" ? (
<td className="px-3 py-4 text-sm font-medium text-gray-900 whitespace-nowrap">
{issue.target_date
? renderShortNumericDateFormat(issue.target_date)
: "-"}
</td>
) : (
<td className="px-3 py-4 text-sm font-medium text-gray-900 relative capitalize">
{issue[key as keyof IIssue] ??
(issue[key as keyof IIssue] as any)?.name ??
"None"}
</td>
)}
</React.Fragment>
)
)}
<td className="px-3">
<div className="flex justify-end items-center gap-2">
<button
type="button"
className="flex items-center bg-blue-100 text-blue-600 hover:bg-blue-200 duration-300 font-medium px-2 py-1 rounded-md text-sm outline-none"
onClick={() => {
setSelectedIssue({
...issue,
actionType: "edit",
});
}}
>
<PencilIcon className="h-3 w-3" />
</button>
<button
type="button"
className="flex items-center bg-red-100 text-red-600 hover:bg-red-200 duration-300 font-medium px-2 py-1 rounded-md text-sm outline-none"
onClick={() => {
handleDeleteIssue(issue.id);
}}
>
<TrashIcon className="h-3 w-3" />
</button>
</div>
</td>
</tr>
);
})
: null}
</React.Fragment>
))}
</tbody>
</table>
<Transition
show={open}
as={React.Fragment}
leave="transition ease-in duration-100"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<Listbox.Options className="absolute z-10 mt-1 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">
{states?.map((state) => (
<Listbox.Option
key={state.id}
className={({ active }) =>
classNames(
active ? "bg-indigo-50" : "bg-white",
"cursor-pointer select-none px-3 py-2"
)
}
value={state.id}
>
{addSpaceIfCamelCase(state.name)}
</Listbox.Option>
))}
</Listbox.Options>
</Transition>
</div>
</>
)}
</Listbox>
</td>
) : (key as keyof Properties) === "target_date" ? (
<td className="px-3 py-4 text-sm font-medium text-gray-900 whitespace-nowrap">
{issue.target_date
? renderShortNumericDateFormat(issue.target_date)
: "-"}
</td>
) : (
<td className="px-3 py-4 text-sm font-medium text-gray-900 relative capitalize">
{issue[key as keyof IIssue] ??
(issue[key as keyof IIssue] as any)?.name ??
"None"}
</td>
)}
</React.Fragment>
)
)}
<td className="px-3">
<div className="flex justify-end items-center gap-2">
<button
type="button"
className="flex items-center bg-blue-100 text-blue-600 hover:bg-blue-200 duration-300 font-medium px-2 py-1 rounded-md text-sm outline-none"
onClick={() => {
setSelectedIssue({
...issue,
actionType: "edit",
});
}}
>
<PencilIcon className="h-3 w-3" />
</button>
<button
type="button"
className="flex items-center bg-red-100 text-red-600 hover:bg-red-200 duration-300 font-medium px-2 py-1 rounded-md text-sm outline-none"
onClick={() => {
handleDeleteIssue(issue.id);
}}
>
<TrashIcon className="h-3 w-3" />
</button>
</div>
</td>
</tr>
);
})
: null}
</tbody>
</table>
</div>
</div>
</div>
</div>
))}
</div>
);
};

View file

@ -1,138 +0,0 @@
// next
import { useRouter } from "next/router";
// react
import { Fragment } from "react";
// headless ui
import { Dialog, Transition } from "@headlessui/react";
// hooks
import useUser from "lib/hooks/useUser";
// services
import issuesServices from "lib/services/issues.services";
import projectService from "lib/services/project.service";
// swr
import useSWR from "swr";
// types
import { IIssue, ProjectMember } from "types";
// constants
import { PROJECT_ISSUES_DETAILS, PROJECT_MEMBERS } from "constants/fetch-keys";
import { Button } from "ui";
import { ChartBarIcon, Squares2X2Icon, TagIcon, UserIcon } from "@heroicons/react/24/outline";
type Props = {
isOpen: boolean;
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
issueId: string | null;
};
const IssuePreviewModal = ({ isOpen, setIsOpen, issueId }: Props) => {
const closeModal = () => {
setIsOpen(false);
};
const { activeWorkspace, activeProject } = useUser();
const router = useRouter();
const { data: issueDetails } = useSWR<IIssue | null>(
activeWorkspace && activeProject && issueId ? PROJECT_ISSUES_DETAILS(issueId) : null,
activeWorkspace && activeProject && issueId
? () => issuesServices.getIssue(activeWorkspace.slug, activeProject.id, issueId)
: null
);
const { data: users } = useSWR<ProjectMember[] | null>(
activeWorkspace && activeProject ? PROJECT_MEMBERS(activeProject.id) : null,
activeWorkspace && activeProject
? () => projectService.projectMembers(activeWorkspace.slug, activeProject.id)
: null
);
return (
<>
<Transition.Root appear show={isOpen} as={Fragment}>
<Dialog as="div" className="relative z-10" onClose={closeModal}>
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-black bg-opacity-25" />
</Transition.Child>
<div className="fixed inset-0 overflow-y-auto">
<div className="flex min-h-full items-center justify-center p-4 text-center">
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<Dialog.Panel className="w-full max-w-3xl transform overflow-hidden rounded-2xl bg-white p-6 text-left align-middle shadow-xl transition-all">
<Dialog.Title
as="h3"
className="text-xl flex flex-col gap-1 font-medium leading-6 text-gray-900"
>
{issueDetails?.project_detail.identifier}-{issueDetails?.sequence_id}{" "}
{issueDetails?.name}
<span className="text-sm text-gray-500 font-normal">
Created by{" "}
{users?.find((u) => u.id === issueDetails?.created_by)?.member.first_name}
</span>
</Dialog.Title>
<div className="mt-4">
<p className="text-sm text-gray-500">{issueDetails?.description}</p>
</div>
<div className="mt-4 flex flex-wrap gap-2">
<span className="flex items-center gap-1 hover:bg-gray-100 border rounded-md shadow-sm px-2 py-1 sm:text-sm">
<Squares2X2Icon className="h-3 w-3" />
{issueDetails?.state_detail.name}
</span>
<span className="flex items-center gap-1 hover:bg-gray-100 border rounded-md shadow-sm px-2 py-1 capitalize sm:text-sm">
<ChartBarIcon className="h-3 w-3" />
{issueDetails?.priority}
</span>
<span className="flex items-center gap-1 hover:bg-gray-100 border rounded-md shadow-sm px-2 py-1 capitalize sm:text-sm">
<TagIcon className="h-3 w-3" />
{issueDetails?.label_details && issueDetails.label_details.length > 0
? issueDetails.label_details.map((label) => (
<span key={label.id}>{label.name}</span>
))
: "None"}
</span>
<span className="flex items-center gap-1 hover:bg-gray-100 border rounded-md shadow-sm px-2 py-1 capitalize sm:text-sm">
<UserIcon className="h-3 w-3" />
{issueDetails?.assignee_details && issueDetails.assignee_details.length > 0
? issueDetails.assignee_details.map((assignee) => (
<span key={assignee.id}>{assignee.first_name}</span>
))
: "None"}
</span>
</div>
<div className="mt-4 flex gap-3 justify-end">
<Button
onClick={() =>
router.push(`/projects/${activeProject?.id}/issues/${issueId}`)
}
>
View in Detail
</Button>
<Button onClick={closeModal}>Close</Button>
</div>
</Dialog.Panel>
</Transition.Child>
</div>
</div>
</Dialog>
</Transition.Root>
</>
);
};
export default IssuePreviewModal;

View file

@ -4,13 +4,14 @@ import useSWR from "swr";
// headless ui
import { Listbox, Transition } from "@headlessui/react";
// react hook form
import { useForm, Controller } from "react-hook-form";
import { useForm, Controller, UseFormWatch } from "react-hook-form";
// services
import stateServices from "lib/services/state.services";
import issuesServices from "lib/services/issues.services";
import workspaceService from "lib/services/workspace.service";
// hooks
import useUser from "lib/hooks/useUser";
import useToast from "lib/hooks/useToast";
// fetching keys
import {
PROJECT_ISSUES_LIST,
@ -20,6 +21,7 @@ import {
} from "constants/fetch-keys";
// commons
import { classNames, copyTextToClipboard } from "constants/common";
import { PRIORITIES } from "constants/";
// ui
import { Input, Button, Spinner } from "ui";
import { Popover } from "@headlessui/react";
@ -38,25 +40,40 @@ import {
} from "@heroicons/react/24/outline";
// types
import type { Control } from "react-hook-form";
import type { IIssue, IIssueLabels, IssueResponse, IState, WorkspaceMember } from "types";
import type {
IIssue,
IIssueLabels,
IssueResponse,
IState,
NestedKeyOf,
WorkspaceMember,
} from "types";
import { TwitterPicker } from "react-color";
import useToast from "lib/hooks/useToast";
import IssuesListModal from "components/project/issues/IssuesListModal";
type Props = {
control: Control<IIssue, any>;
submitChanges: (formData: Partial<IIssue>) => void;
issueDetail: IIssue | undefined;
watch: UseFormWatch<IIssue>;
};
const PRIORITIES = ["high", "medium", "low"];
const defaultValues: Partial<IIssueLabels> = {
name: "",
colour: "#ff0000",
};
const IssueDetailSidebar: React.FC<Props> = ({ control, submitChanges, issueDetail }) => {
const { activeWorkspace, activeProject, cycles } = useUser();
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();
const { setToastAlert } = useToast();
@ -72,15 +89,6 @@ const IssueDetailSidebar: React.FC<Props> = ({ control, submitChanges, issueDeta
activeWorkspace ? () => workspaceService.workspaceMembers(activeWorkspace.slug) : null
);
const { data: projectIssues } = useSWR<IssueResponse>(
activeProject && activeWorkspace
? PROJECT_ISSUES_LIST(activeWorkspace.slug, activeProject.id)
: null,
activeProject && activeWorkspace
? () => issuesServices.getIssues(activeWorkspace.slug, activeProject.id)
: null
);
const { data: issueLabels, mutate: issueLabelMutate } = useSWR<IIssueLabels[]>(
activeProject && activeWorkspace ? PROJECT_ISSUE_LABELS(activeProject.id) : null,
activeProject && activeWorkspace
@ -110,7 +118,19 @@ const IssueDetailSidebar: React.FC<Props> = ({ control, submitChanges, issueDeta
});
};
const sidebarSections = [
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;
}>
> = [
[
{
label: "Status",
@ -121,6 +141,7 @@ const IssueDetailSidebar: React.FC<Props> = ({ control, submitChanges, issueDeta
label: state.name,
value: state.id,
})),
modal: false,
},
{
label: "Assignees",
@ -131,6 +152,7 @@ const IssueDetailSidebar: React.FC<Props> = ({ control, submitChanges, issueDeta
label: person.member.first_name,
value: person.member.id,
})),
modal: false,
},
{
label: "Priority",
@ -141,34 +163,52 @@ const IssueDetailSidebar: React.FC<Props> = ({ control, submitChanges, issueDeta
label: property,
value: property,
})),
modal: false,
},
],
[
{
label: "Blocker",
name: "blockers_list",
canSelectMultipleOptions: true,
label: "Parent",
name: "parent",
canSelectMultipleOptions: false,
icon: UserIcon,
options: projectIssues?.results?.map((issue) => ({
label: issue.name,
value: issue.id,
})),
issuesList:
issues?.results.filter(
(i) =>
i.id !== issueDetail?.id &&
i.id !== issueDetail?.parent &&
i.parent !== issueDetail?.id
) ?? [],
modal: true,
isOpen: isParentModalOpen,
setIsOpen: setIsParentModalOpen,
},
// {
// 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,
// },
{
label: "Blocked",
name: "blocked_list",
canSelectMultipleOptions: true,
icon: UserIcon,
options: projectIssues?.results?.map((issue) => ({
label: issue.name,
value: issue.id,
})),
},
{
label: "Due Date",
label: "Target Date",
name: "target_date",
canSelectMultipleOptions: true,
icon: CalendarDaysIcon,
modal: false,
},
],
[
@ -181,6 +221,7 @@ const IssueDetailSidebar: React.FC<Props> = ({ control, submitChanges, issueDeta
label: cycle.name,
value: cycle.id,
})),
modal: false,
},
],
];
@ -249,12 +290,12 @@ const IssueDetailSidebar: React.FC<Props> = ({ control, submitChanges, issueDeta
{sidebarSections.map((section, index) => (
<div key={index} className="py-1">
{section.map((item) => (
<div key={item.label} className="flex justify-between items-center gap-x-2 py-2">
<div className="flex items-center gap-x-2 text-sm">
<item.icon className="h-4 w-4" />
<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" />
<p>{item.label}</p>
</div>
<div>
<div className="sm:basis-1/2">
{item.name === "target_date" ? (
<Controller
control={control}
@ -262,15 +303,52 @@ const IssueDetailSidebar: React.FC<Props> = ({ control, submitChanges, issueDeta
render={({ field: { value, onChange } }) => (
<input
type="date"
value={""}
value={value ?? ""}
onChange={(e: any) => {
submitChanges({ target_date: e.target.value });
onChange(e.target.value);
}}
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"
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"
/>
)}
/>
) : 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>
</>
)}
/>
) : (
<Controller
control={control}
@ -288,11 +366,11 @@ const IssueDetailSidebar: React.FC<Props> = ({ control, submitChanges, issueDeta
>
{({ open }) => (
<div className="relative">
<Listbox.Button className="relative 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-sm duration-300">
<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">
<span
className={classNames(
value ? "" : "text-gray-900",
"hidden truncate sm:block w-16 text-left",
"hidden truncate sm:block text-left",
item.label === "Priority" ? "capitalize" : ""
)}
>
@ -419,12 +497,12 @@ const IssueDetailSidebar: React.FC<Props> = ({ control, submitChanges, issueDeta
+
</Button>
</form>
<div className="flex justify-between items-center gap-x-2">
<div className="flex items-center gap-x-2 text-sm">
<div className="flex justify-between items-center">
<div className="flex items-center gap-x-2 text-sm basis-1/2">
<TagIcon className="w-4 h-4" />
<p>Label</p>
</div>
<div>
<div className="basis-1/2">
<Controller
control={control}
name="labels_list"
@ -440,11 +518,11 @@ const IssueDetailSidebar: React.FC<Props> = ({ control, submitChanges, issueDeta
<>
<Listbox.Label className="sr-only">Label</Listbox.Label>
<div className="relative">
<Listbox.Button className="relative 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-sm duration-300">
<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">
<span
className={classNames(
value ? "" : "text-gray-900",
"hidden truncate capitalize sm:block w-16 text-left"
"hidden truncate capitalize sm:block text-left"
)}
>
{value && value.length > 0

View file

@ -64,14 +64,14 @@ const CommentCard: React.FC<Props> = ({ comment, onSubmit, handleCommentDeletion
<div key={comment.id}>
<div className="w-full h-full flex justify-between">
<div className="flex gap-x-2 w-full">
<div className="flex-shrink-0 -ml-1.5">
<div className="flex-shrink-0">
{comment.actor_detail.avatar && comment.actor_detail.avatar !== "" ? (
<Image
src={comment.actor_detail.avatar}
alt={comment.actor_detail.name}
height={30}
width={30}
className="rounded-full"
className="rounded"
/>
) : (
<div
@ -82,11 +82,7 @@ const CommentCard: React.FC<Props> = ({ comment, onSubmit, handleCommentDeletion
)}
</div>
<div className="w-full">
<p>
{comment.actor_detail.first_name} {comment.actor_detail.last_name}
</p>
<p className="text-xs text-gray-500">{timeAgo(comment.created_at)}</p>
<div className="w-full mt-2">
<div>
{isEditing ? (
<form className="flex flex-col gap-2" onSubmit={handleSubmit(onEnter)}>
<TextArea
@ -120,13 +116,19 @@ const CommentCard: React.FC<Props> = ({ comment, onSubmit, handleCommentDeletion
) : (
<>
{comment.comment.split("\n").map((item, index) => (
<p key={index} className="text-sm text-gray-600">
<p key={index} className="text-sm">
{item}
</p>
))}
</>
)}
</div>
<p className="text-xs text-gray-500 flex items-center gap-2 mt-1">
<span>
{comment.actor_detail.first_name} {comment.actor_detail.last_name}
</span>
<span>{timeAgo(comment.created_at)}</span>
</p>
</div>
</div>
{user?.id === comment.actor && (

View file

@ -72,7 +72,7 @@ const IssueCommentSection: React.FC<Props> = ({ comments, issueId, projectId, wo
return (
<div className="space-y-5">
<form onSubmit={handleSubmit(onSubmit)}>
<div className="p-2 bg-indigo-50 rounded-md">
<div className="bg-gray-100 rounded-md">
<div className="w-full">
<TextArea
id="comment"