mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
Merge pull request #25 from dakshesh14/main
feat: edit, delete project/workspaces member workflow, order issues by priority
This commit is contained in:
commit
f6c12ad93a
116
apps/app/components/project/ConfirmProjectMemberRemove.tsx
Normal file
116
apps/app/components/project/ConfirmProjectMemberRemove.tsx
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
import React, { useRef, useState } from "react";
|
||||||
|
// headless ui
|
||||||
|
import { Dialog, Transition } from "@headlessui/react";
|
||||||
|
// icons
|
||||||
|
import { ExclamationTriangleIcon } from "@heroicons/react/24/outline";
|
||||||
|
// ui
|
||||||
|
import { Button } from "ui";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
handleDelete: () => void;
|
||||||
|
data?: any;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ConfirmProjectMemberRemove: React.FC<Props> = ({ isOpen, onClose, data, handleDelete }) => {
|
||||||
|
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
|
||||||
|
|
||||||
|
const cancelButtonRef = useRef(null);
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
onClose();
|
||||||
|
setIsDeleteLoading(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeletion = async () => {
|
||||||
|
setIsDeleteLoading(true);
|
||||||
|
handleDelete();
|
||||||
|
handleClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Transition.Root show={isOpen} as={React.Fragment}>
|
||||||
|
<Dialog
|
||||||
|
as="div"
|
||||||
|
className="relative z-10"
|
||||||
|
initialFocus={cancelButtonRef}
|
||||||
|
onClose={handleClose}
|
||||||
|
>
|
||||||
|
<Transition.Child
|
||||||
|
as={React.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-gray-500 bg-opacity-75 transition-opacity" />
|
||||||
|
</Transition.Child>
|
||||||
|
|
||||||
|
<div className="fixed inset-0 z-10 overflow-y-auto">
|
||||||
|
<div className="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
|
||||||
|
<Transition.Child
|
||||||
|
as={React.Fragment}
|
||||||
|
enter="ease-out duration-300"
|
||||||
|
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
||||||
|
enterTo="opacity-100 translate-y-0 sm:scale-100"
|
||||||
|
leave="ease-in duration-200"
|
||||||
|
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
|
||||||
|
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
||||||
|
>
|
||||||
|
<Dialog.Panel className="relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg">
|
||||||
|
<div className="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
|
||||||
|
<div className="sm:flex sm:items-start">
|
||||||
|
<div className="mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10">
|
||||||
|
<ExclamationTriangleIcon
|
||||||
|
className="h-6 w-6 text-red-600"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">
|
||||||
|
<Dialog.Title as="h3" className="text-lg font-medium leading-6 text-gray-900">
|
||||||
|
Remove {data?.email}?
|
||||||
|
</Dialog.Title>
|
||||||
|
<div className="mt-2">
|
||||||
|
<p className="text-sm text-gray-500">
|
||||||
|
Are you sure you want to remove member - {`"`}
|
||||||
|
<span className="italic">{data?.email}</span>
|
||||||
|
{`"`} ? They will no longer have access to this project. This action
|
||||||
|
cannot be undone.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="bg-gray-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6">
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
onClick={handleDeletion}
|
||||||
|
theme="danger"
|
||||||
|
disabled={isDeleteLoading}
|
||||||
|
className="inline-flex sm:ml-3"
|
||||||
|
>
|
||||||
|
{isDeleteLoading ? "Removing..." : "Remove"}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
theme="secondary"
|
||||||
|
className="inline-flex sm:ml-3"
|
||||||
|
onClick={handleClose}
|
||||||
|
ref={cancelButtonRef}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Dialog.Panel>
|
||||||
|
</Transition.Child>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
</Transition.Root>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ConfirmProjectMemberRemove;
|
@ -12,6 +12,7 @@ import useToast from "lib/hooks/useToast";
|
|||||||
import projectService from "lib/services/project.service";
|
import projectService from "lib/services/project.service";
|
||||||
import workspaceService from "lib/services/workspace.service";
|
import workspaceService from "lib/services/workspace.service";
|
||||||
// constants
|
// constants
|
||||||
|
import { ROLE } from "constants/";
|
||||||
import { PROJECT_INVITATIONS, WORKSPACE_MEMBERS } from "constants/fetch-keys";
|
import { PROJECT_INVITATIONS, WORKSPACE_MEMBERS } from "constants/fetch-keys";
|
||||||
// ui
|
// ui
|
||||||
import { Button, Select, TextArea } from "ui";
|
import { Button, Select, TextArea } from "ui";
|
||||||
@ -30,13 +31,9 @@ type Props = {
|
|||||||
const defaultValues: Partial<ProjectMember> = {
|
const defaultValues: Partial<ProjectMember> = {
|
||||||
email: "",
|
email: "",
|
||||||
message: "",
|
message: "",
|
||||||
};
|
role: 5,
|
||||||
|
member_id: "",
|
||||||
const ROLE = {
|
user_id: "",
|
||||||
5: "Guest",
|
|
||||||
10: "Viewer",
|
|
||||||
15: "Member",
|
|
||||||
20: "Admin",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const SendProjectInvitationModal: React.FC<Props> = ({ isOpen, setIsOpen, members }) => {
|
const SendProjectInvitationModal: React.FC<Props> = ({ isOpen, setIsOpen, members }) => {
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
// react
|
// react
|
||||||
import React, { useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
// next
|
// next
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import dynamic from "next/dynamic";
|
|
||||||
// swr
|
// swr
|
||||||
import useSWR, { mutate } from "swr";
|
import useSWR, { mutate } from "swr";
|
||||||
// ui
|
// ui
|
||||||
@ -11,7 +10,7 @@ import { Listbox, Transition } from "@headlessui/react";
|
|||||||
// icons
|
// icons
|
||||||
import { PencilIcon, TrashIcon } from "@heroicons/react/24/outline";
|
import { PencilIcon, TrashIcon } from "@heroicons/react/24/outline";
|
||||||
// types
|
// types
|
||||||
import { IIssue, IssueResponse, NestedKeyOf, Properties, WorkspaceMember } from "types";
|
import { IIssue, IssueResponse, IState, NestedKeyOf, Properties, WorkspaceMember } from "types";
|
||||||
// hooks
|
// hooks
|
||||||
import useUser from "lib/hooks/useUser";
|
import useUser from "lib/hooks/useUser";
|
||||||
// fetch keys
|
// fetch keys
|
||||||
@ -48,7 +47,7 @@ const ListView: React.FC<Props> = ({
|
|||||||
const [issuePreviewModal, setIssuePreviewModal] = useState(false);
|
const [issuePreviewModal, setIssuePreviewModal] = useState(false);
|
||||||
const [previewModalIssueId, setPreviewModalIssueId] = useState<string | null>(null);
|
const [previewModalIssueId, setPreviewModalIssueId] = useState<string | null>(null);
|
||||||
|
|
||||||
const { activeWorkspace, activeProject, states, issues } = useUser();
|
const { activeWorkspace, activeProject, states } = useUser();
|
||||||
|
|
||||||
const partialUpdateIssue = (formData: Partial<IIssue>, issueId: string) => {
|
const partialUpdateIssue = (formData: Partial<IIssue>, issueId: string) => {
|
||||||
if (!activeWorkspace || !activeProject) return;
|
if (!activeWorkspace || !activeProject) return;
|
||||||
@ -70,10 +69,6 @@ const ListView: React.FC<Props> = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const LexicalViewer = dynamic(() => import("components/lexical/viewer"), {
|
|
||||||
ssr: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { data: people } = useSWR<WorkspaceMember[]>(
|
const { data: people } = useSWR<WorkspaceMember[]>(
|
||||||
activeWorkspace ? WORKSPACE_MEMBERS : null,
|
activeWorkspace ? WORKSPACE_MEMBERS : null,
|
||||||
activeWorkspace ? () => workspaceService.workspaceMembers(activeWorkspace.slug) : null
|
activeWorkspace ? () => workspaceService.workspaceMembers(activeWorkspace.slug) : null
|
||||||
@ -179,14 +174,6 @@ const ListView: React.FC<Props> = ({
|
|||||||
<td className="px-3 py-4 font-medium text-gray-900 text-xs whitespace-nowrap">
|
<td className="px-3 py-4 font-medium text-gray-900 text-xs whitespace-nowrap">
|
||||||
{activeProject?.identifier}-{issue.sequence_id}
|
{activeProject?.identifier}-{issue.sequence_id}
|
||||||
</td>
|
</td>
|
||||||
) : (key as keyof Properties) === "description" ? (
|
|
||||||
<td className="px-3 py-4 font-medium text-gray-900 truncate text-xs max-w-[15rem]">
|
|
||||||
{/* <LexicalViewer
|
|
||||||
id={`descriptionViewer-${issue.id}`}
|
|
||||||
value={issue.description}
|
|
||||||
/> */}
|
|
||||||
{issue.description}
|
|
||||||
</td>
|
|
||||||
) : (key as keyof Properties) === "priority" ? (
|
) : (key as keyof Properties) === "priority" ? (
|
||||||
<td className="px-3 py-4 text-sm font-medium text-gray-900 relative">
|
<td className="px-3 py-4 text-sm font-medium text-gray-900 relative">
|
||||||
<Listbox
|
<Listbox
|
||||||
@ -218,7 +205,7 @@ const ListView: React.FC<Props> = ({
|
|||||||
leaveFrom="opacity-100"
|
leaveFrom="opacity-100"
|
||||||
leaveTo="opacity-0"
|
leaveTo="opacity-0"
|
||||||
>
|
>
|
||||||
<Listbox.Options className="fixed 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">
|
<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) => (
|
{PRIORITIES?.map((priority) => (
|
||||||
<Listbox.Option
|
<Listbox.Option
|
||||||
key={priority}
|
key={priority}
|
||||||
@ -290,14 +277,14 @@ const ListView: React.FC<Props> = ({
|
|||||||
leaveFrom="opacity-100"
|
leaveFrom="opacity-100"
|
||||||
leaveTo="opacity-0"
|
leaveTo="opacity-0"
|
||||||
>
|
>
|
||||||
<Listbox.Options className="fixed 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">
|
<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) => (
|
{people?.map((person) => (
|
||||||
<Listbox.Option
|
<Listbox.Option
|
||||||
key={person.id}
|
key={person.id}
|
||||||
className={({ active }) =>
|
className={({ active }) =>
|
||||||
classNames(
|
classNames(
|
||||||
active ? "bg-indigo-50" : "bg-white",
|
active ? "bg-indigo-50" : "bg-white",
|
||||||
"cursor-pointer select-none p-2"
|
"cursor-pointer select-none px-3 py-2"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
value={person.member.id}
|
value={person.member.id}
|
||||||
@ -305,15 +292,15 @@ const ListView: React.FC<Props> = ({
|
|||||||
<div
|
<div
|
||||||
className={`flex items-center gap-x-1 ${
|
className={`flex items-center gap-x-1 ${
|
||||||
assignees.includes(
|
assignees.includes(
|
||||||
person.member.email
|
person.member.first_name
|
||||||
)
|
)
|
||||||
? "font-medium"
|
? "font-medium"
|
||||||
: "text-gray-500"
|
: "font-normal"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{person.member.avatar &&
|
{person.member.avatar &&
|
||||||
person.member.avatar !== "" ? (
|
person.member.avatar !== "" ? (
|
||||||
<div className="relative h-4 w-4">
|
<div className="relative w-4 h-4">
|
||||||
<Image
|
<Image
|
||||||
src={person.member.avatar}
|
src={person.member.avatar}
|
||||||
alt="avatar"
|
alt="avatar"
|
||||||
@ -323,11 +310,11 @@ const ListView: React.FC<Props> = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<span className="h-4 w-4 grid place-items-center bg-gray-700 text-white rounded-full">
|
<p>
|
||||||
{person.member.first_name.charAt(0)}
|
{person.member.first_name.charAt(0)}
|
||||||
</span>
|
</p>
|
||||||
)}
|
)}
|
||||||
{person.member.first_name}
|
<p>{person.member.first_name}</p>
|
||||||
</div>
|
</div>
|
||||||
</Listbox.Option>
|
</Listbox.Option>
|
||||||
))}
|
))}
|
||||||
@ -375,24 +362,18 @@ const ListView: React.FC<Props> = ({
|
|||||||
leaveFrom="opacity-100"
|
leaveFrom="opacity-100"
|
||||||
leaveTo="opacity-0"
|
leaveTo="opacity-0"
|
||||||
>
|
>
|
||||||
<Listbox.Options className="fixed 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">
|
<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) => (
|
{states?.map((state) => (
|
||||||
<Listbox.Option
|
<Listbox.Option
|
||||||
key={state.id}
|
key={state.id}
|
||||||
className={({ active }) =>
|
className={({ active }) =>
|
||||||
classNames(
|
classNames(
|
||||||
active ? "bg-indigo-50" : "bg-white",
|
active ? "bg-indigo-50" : "bg-white",
|
||||||
"flex items-center gap-2 cursor-pointer select-none p-2"
|
"cursor-pointer select-none px-3 py-2"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
value={state.id}
|
value={state.id}
|
||||||
>
|
>
|
||||||
<span
|
|
||||||
className={`h-1.5 w-1.5 block rounded-full`}
|
|
||||||
style={{
|
|
||||||
backgroundColor: state.color,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{addSpaceIfCamelCase(state.name)}
|
{addSpaceIfCamelCase(state.name)}
|
||||||
</Listbox.Option>
|
</Listbox.Option>
|
||||||
))}
|
))}
|
||||||
@ -403,10 +384,6 @@ const ListView: React.FC<Props> = ({
|
|||||||
)}
|
)}
|
||||||
</Listbox>
|
</Listbox>
|
||||||
</td>
|
</td>
|
||||||
) : (key as keyof Properties) === "children" ? (
|
|
||||||
<td className="px-3 py-4 text-sm font-medium text-gray-900">
|
|
||||||
No children.
|
|
||||||
</td>
|
|
||||||
) : (key as keyof Properties) === "target_date" ? (
|
) : (key as keyof Properties) === "target_date" ? (
|
||||||
<td className="px-3 py-4 text-sm font-medium text-gray-900 whitespace-nowrap">
|
<td className="px-3 py-4 text-sm font-medium text-gray-900 whitespace-nowrap">
|
||||||
{issue.target_date
|
{issue.target_date
|
||||||
|
116
apps/app/components/workspace/ConfirmWorkspaceMemberRemove.tsx
Normal file
116
apps/app/components/workspace/ConfirmWorkspaceMemberRemove.tsx
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
import React, { useRef, useState } from "react";
|
||||||
|
// headless ui
|
||||||
|
import { Dialog, Transition } from "@headlessui/react";
|
||||||
|
// icons
|
||||||
|
import { ExclamationTriangleIcon } from "@heroicons/react/24/outline";
|
||||||
|
// ui
|
||||||
|
import { Button } from "ui";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
handleDelete: () => void;
|
||||||
|
data?: any;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ConfirmWorkspaceMemberRemove: React.FC<Props> = ({ isOpen, onClose, data, handleDelete }) => {
|
||||||
|
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
|
||||||
|
|
||||||
|
const cancelButtonRef = useRef(null);
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
onClose();
|
||||||
|
setIsDeleteLoading(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeletion = async () => {
|
||||||
|
setIsDeleteLoading(true);
|
||||||
|
handleDelete();
|
||||||
|
handleClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Transition.Root show={isOpen} as={React.Fragment}>
|
||||||
|
<Dialog
|
||||||
|
as="div"
|
||||||
|
className="relative z-10"
|
||||||
|
initialFocus={cancelButtonRef}
|
||||||
|
onClose={handleClose}
|
||||||
|
>
|
||||||
|
<Transition.Child
|
||||||
|
as={React.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-gray-500 bg-opacity-75 transition-opacity" />
|
||||||
|
</Transition.Child>
|
||||||
|
|
||||||
|
<div className="fixed inset-0 z-10 overflow-y-auto">
|
||||||
|
<div className="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
|
||||||
|
<Transition.Child
|
||||||
|
as={React.Fragment}
|
||||||
|
enter="ease-out duration-300"
|
||||||
|
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
||||||
|
enterTo="opacity-100 translate-y-0 sm:scale-100"
|
||||||
|
leave="ease-in duration-200"
|
||||||
|
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
|
||||||
|
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
||||||
|
>
|
||||||
|
<Dialog.Panel className="relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg">
|
||||||
|
<div className="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
|
||||||
|
<div className="sm:flex sm:items-start">
|
||||||
|
<div className="mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10">
|
||||||
|
<ExclamationTriangleIcon
|
||||||
|
className="h-6 w-6 text-red-600"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">
|
||||||
|
<Dialog.Title as="h3" className="text-lg font-medium leading-6 text-gray-900">
|
||||||
|
Remove {data?.email}?
|
||||||
|
</Dialog.Title>
|
||||||
|
<div className="mt-2">
|
||||||
|
<p className="text-sm text-gray-500">
|
||||||
|
Are you sure you want to remove member - {`"`}
|
||||||
|
<span className="italic">{data?.email}</span>
|
||||||
|
{`"`} ? They will no longer have access to this workspace. This action
|
||||||
|
cannot be undone.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="bg-gray-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6">
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
onClick={handleDeletion}
|
||||||
|
theme="danger"
|
||||||
|
disabled={isDeleteLoading}
|
||||||
|
className="inline-flex sm:ml-3"
|
||||||
|
>
|
||||||
|
{isDeleteLoading ? "Removing..." : "Remove"}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
theme="secondary"
|
||||||
|
className="inline-flex sm:ml-3"
|
||||||
|
onClick={handleClose}
|
||||||
|
ref={cancelButtonRef}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Dialog.Panel>
|
||||||
|
</Transition.Child>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
</Transition.Root>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ConfirmWorkspaceMemberRemove;
|
@ -1 +1,8 @@
|
|||||||
export const PRIORITIES = ["urgent", "high", "medium", "low"];
|
export const PRIORITIES = ["urgent", "high", "medium", "low"];
|
||||||
|
|
||||||
|
export const ROLE = {
|
||||||
|
5: "Guest",
|
||||||
|
10: "Viewer",
|
||||||
|
15: "Member",
|
||||||
|
20: "Admin",
|
||||||
|
};
|
||||||
|
@ -298,14 +298,22 @@ const Sidebar: React.FC = () => {
|
|||||||
) : (
|
) : (
|
||||||
<p>No workspace found!</p>
|
<p>No workspace found!</p>
|
||||||
)}
|
)}
|
||||||
<Menu.Item>
|
<Menu.Item
|
||||||
{(active) => (
|
as="button"
|
||||||
<Link href="/create-workspace">
|
onClick={() => {
|
||||||
<a className="flex items-center gap-x-1 p-2 w-full text-left text-gray-900 hover:bg-theme hover:text-white rounded-md text-sm">
|
router.push("/create-workspace");
|
||||||
|
}}
|
||||||
|
className="w-full"
|
||||||
|
>
|
||||||
|
{({ active }) => (
|
||||||
|
<a
|
||||||
|
className={`flex items-center gap-x-1 p-2 w-full text-left text-gray-900 hover:bg-theme hover:text-white rounded-md text-sm ${
|
||||||
|
active ? "bg-theme text-white" : "text-gray-900"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
<PlusIcon className="w-5 h-5" />
|
<PlusIcon className="w-5 h-5" />
|
||||||
<span>Create Workspace</span>
|
<span>Create Workspace</span>
|
||||||
</a>
|
</a>
|
||||||
</Link>
|
|
||||||
)}
|
)}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</>
|
</>
|
||||||
|
@ -11,19 +11,12 @@ import useUser from "./useUser";
|
|||||||
import { IssuePriorities, Properties } from "types";
|
import { IssuePriorities, Properties } from "types";
|
||||||
|
|
||||||
const initialValues: Properties = {
|
const initialValues: Properties = {
|
||||||
name: true,
|
|
||||||
key: true,
|
key: true,
|
||||||
parent: false,
|
|
||||||
project: false,
|
|
||||||
state: true,
|
state: true,
|
||||||
assignee: true,
|
assignee: true,
|
||||||
description: false,
|
|
||||||
priority: false,
|
priority: false,
|
||||||
start_date: false,
|
start_date: false,
|
||||||
target_date: false,
|
target_date: false,
|
||||||
sequence_id: false,
|
|
||||||
attachments: false,
|
|
||||||
children: false,
|
|
||||||
cycle: false,
|
cycle: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,12 +124,14 @@ class ProjectServices extends APIService {
|
|||||||
throw error?.response?.data;
|
throw error?.response?.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateProjectMember(
|
async updateProjectMember(
|
||||||
workspace_slug: string,
|
workspace_slug: string,
|
||||||
project_id: string,
|
project_id: string,
|
||||||
memberId: string
|
memberId: string,
|
||||||
|
data: any
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
return this.put(PROJECT_MEMBER_DETAIL(workspace_slug, project_id, memberId))
|
return this.put(PROJECT_MEMBER_DETAIL(workspace_slug, project_id, memberId), data)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
return response?.data;
|
return response?.data;
|
||||||
})
|
})
|
||||||
@ -137,6 +139,7 @@ class ProjectServices extends APIService {
|
|||||||
throw error?.response?.data;
|
throw error?.response?.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteProjectMember(
|
async deleteProjectMember(
|
||||||
workspace_slug: string,
|
workspace_slug: string,
|
||||||
project_id: string,
|
project_id: string,
|
||||||
|
@ -111,8 +111,9 @@ class WorkspaceService extends APIService {
|
|||||||
throw error?.response?.data;
|
throw error?.response?.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async updateWorkspaceMember(workspace_slug: string, memberId: string): Promise<any> {
|
|
||||||
return this.put(WORKSPACE_MEMBER_DETAIL(workspace_slug, memberId))
|
async updateWorkspaceMember(workspace_slug: string, memberId: string, data: any): Promise<any> {
|
||||||
|
return this.put(WORKSPACE_MEMBER_DETAIL(workspace_slug, memberId), data)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
return response?.data;
|
return response?.data;
|
||||||
})
|
})
|
||||||
@ -120,6 +121,7 @@ class WorkspaceService extends APIService {
|
|||||||
throw error?.response?.data;
|
throw error?.response?.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteWorkspaceMember(workspace_slug: string, memberId: string): Promise<any> {
|
async deleteWorkspaceMember(workspace_slug: string, memberId: string): Promise<any> {
|
||||||
return this.delete(WORKSPACE_MEMBER_DETAIL(workspace_slug, memberId))
|
return this.delete(WORKSPACE_MEMBER_DETAIL(workspace_slug, memberId))
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
@ -36,15 +36,17 @@ import { PlusIcon, Squares2X2Icon } from "@heroicons/react/20/solid";
|
|||||||
// types
|
// types
|
||||||
import type { IIssue, Properties, NestedKeyOf, ProjectMember } from "types";
|
import type { IIssue, Properties, NestedKeyOf, ProjectMember } from "types";
|
||||||
|
|
||||||
const groupByOptions: Array<{ name: string; key: NestedKeyOf<IIssue> }> = [
|
const groupByOptions: Array<{ name: string; key: NestedKeyOf<IIssue> | null }> = [
|
||||||
{ name: "State", key: "state_detail.name" },
|
{ name: "State", key: "state_detail.name" },
|
||||||
{ name: "Priority", key: "priority" },
|
{ name: "Priority", key: "priority" },
|
||||||
{ name: "Created By", key: "created_by" },
|
{ name: "Created By", key: "created_by" },
|
||||||
|
{ name: "None", key: null },
|
||||||
];
|
];
|
||||||
|
|
||||||
const orderByOptions: Array<{ name: string; key: NestedKeyOf<IIssue> }> = [
|
const orderByOptions: Array<{ name: string; key: NestedKeyOf<IIssue> }> = [
|
||||||
{ name: "Created", key: "created_at" },
|
{ name: "Created", key: "created_at" },
|
||||||
{ name: "Update", key: "updated_at" },
|
{ name: "Update", key: "updated_at" },
|
||||||
|
{ name: "Priority", key: "priority" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const filterIssueOptions: Array<{
|
const filterIssueOptions: Array<{
|
||||||
@ -222,14 +224,17 @@ const ProjectIssues: NextPage = () => {
|
|||||||
"Select"
|
"Select"
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{orderByOptions.map((option) => (
|
{orderByOptions.map((option) =>
|
||||||
|
groupByProperty === "priority" &&
|
||||||
|
option.key === "priority" ? null : (
|
||||||
<CustomMenu.MenuItem
|
<CustomMenu.MenuItem
|
||||||
key={option.key}
|
key={option.key}
|
||||||
onClick={() => setOrderBy(option.key)}
|
onClick={() => setOrderBy(option.key)}
|
||||||
>
|
>
|
||||||
{option.name}
|
{option.name}
|
||||||
</CustomMenu.MenuItem>
|
</CustomMenu.MenuItem>
|
||||||
))}
|
)
|
||||||
|
)}
|
||||||
</CustomMenu>
|
</CustomMenu>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
// next
|
// next
|
||||||
import { useRouter } from "next/router";
|
import Image from "next/image";
|
||||||
import type { NextPage } from "next";
|
import type { NextPage } from "next";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
// swr
|
// swr
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
// headless ui
|
// headless ui
|
||||||
@ -10,19 +11,20 @@ import { Menu } from "@headlessui/react";
|
|||||||
import projectService from "lib/services/project.service";
|
import projectService from "lib/services/project.service";
|
||||||
// hooks
|
// hooks
|
||||||
import useUser from "lib/hooks/useUser";
|
import useUser from "lib/hooks/useUser";
|
||||||
|
import useToast from "lib/hooks/useToast";
|
||||||
// fetching keys
|
// fetching keys
|
||||||
import { PROJECT_MEMBERS, PROJECT_INVITATIONS } from "constants/fetch-keys";
|
import { PROJECT_MEMBERS, PROJECT_INVITATIONS } from "constants/fetch-keys";
|
||||||
// layouts
|
// layouts
|
||||||
import AdminLayout from "layouts/AdminLayout";
|
import AdminLayout from "layouts/AdminLayout";
|
||||||
// components
|
// components
|
||||||
import SendProjectInvitationModal from "components/project/SendProjectInvitationModal";
|
import SendProjectInvitationModal from "components/project/SendProjectInvitationModal";
|
||||||
|
import ConfirmProjectMemberRemove from "components/project/ConfirmProjectMemberRemove";
|
||||||
// ui
|
// ui
|
||||||
import { Spinner, Button } from "ui";
|
import { Spinner, CustomListbox } from "ui";
|
||||||
// icons
|
// icons
|
||||||
import { PlusIcon, EllipsisHorizontalIcon } from "@heroicons/react/20/solid";
|
import { PlusIcon, EllipsisHorizontalIcon } from "@heroicons/react/20/solid";
|
||||||
import HeaderButton from "ui/HeaderButton";
|
import HeaderButton from "ui/HeaderButton";
|
||||||
import { BreadcrumbItem, Breadcrumbs } from "ui/Breadcrumbs";
|
import { BreadcrumbItem, Breadcrumbs } from "ui/Breadcrumbs";
|
||||||
import Image from "next/image";
|
|
||||||
|
|
||||||
const ROLE = {
|
const ROLE = {
|
||||||
5: "Guest",
|
5: "Guest",
|
||||||
@ -33,8 +35,16 @@ const ROLE = {
|
|||||||
|
|
||||||
const ProjectMembers: NextPage = () => {
|
const ProjectMembers: NextPage = () => {
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
|
||||||
|
const [selectedMember, setSelectedMember] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const [selectedRemoveMember, setSelectedRemoveMember] = useState<string | null>(null);
|
||||||
|
const [selectedInviteRemoveMember, setSelectedInviteRemoveMember] = useState<string | null>(null);
|
||||||
|
|
||||||
const { activeWorkspace, activeProject } = useUser();
|
const { activeWorkspace, activeProject } = useUser();
|
||||||
|
|
||||||
|
const { setToastAlert } = useToast();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const { projectId } = router.query;
|
const { projectId } = router.query;
|
||||||
@ -75,6 +85,48 @@ const ProjectMembers: NextPage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<AdminLayout>
|
<AdminLayout>
|
||||||
|
<ConfirmProjectMemberRemove
|
||||||
|
isOpen={Boolean(selectedRemoveMember) || Boolean(selectedInviteRemoveMember)}
|
||||||
|
onClose={() => {
|
||||||
|
setSelectedRemoveMember(null);
|
||||||
|
setSelectedInviteRemoveMember(null);
|
||||||
|
}}
|
||||||
|
data={members.find(
|
||||||
|
(item) => item.id === selectedRemoveMember || item.id === selectedInviteRemoveMember
|
||||||
|
)}
|
||||||
|
handleDelete={async () => {
|
||||||
|
if (!activeWorkspace || !projectId) return;
|
||||||
|
if (selectedRemoveMember) {
|
||||||
|
await projectService.deleteProjectMember(
|
||||||
|
activeWorkspace.slug,
|
||||||
|
projectId as string,
|
||||||
|
selectedRemoveMember
|
||||||
|
);
|
||||||
|
mutateMembers(
|
||||||
|
(prevData: any[]) =>
|
||||||
|
prevData?.filter((item: any) => item.id !== selectedRemoveMember),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (selectedInviteRemoveMember) {
|
||||||
|
await projectService.deleteProjectInvitation(
|
||||||
|
activeWorkspace.slug,
|
||||||
|
projectId as string,
|
||||||
|
selectedInviteRemoveMember
|
||||||
|
);
|
||||||
|
mutateInvitations(
|
||||||
|
(prevData: any[]) =>
|
||||||
|
prevData?.filter((item: any) => item.id !== selectedInviteRemoveMember),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
setToastAlert({
|
||||||
|
type: "success",
|
||||||
|
message: "Member removed successfully",
|
||||||
|
title: "Success",
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<SendProjectInvitationModal isOpen={isOpen} setIsOpen={setIsOpen} members={members} />
|
<SendProjectInvitationModal isOpen={isOpen} setIsOpen={setIsOpen} members={members} />
|
||||||
{!projectMembers || !projectInvitations ? (
|
{!projectMembers || !projectInvitations ? (
|
||||||
<div className="h-full w-full grid place-items-center px-4 sm:px-0">
|
<div className="h-full w-full grid place-items-center px-4 sm:px-0">
|
||||||
@ -137,12 +189,53 @@ const ProjectMembers: NextPage = () => {
|
|||||||
{member.email ?? "No email has been added."}
|
{member.email ?? "No email has been added."}
|
||||||
</td>
|
</td>
|
||||||
<td className="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">
|
<td className="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">
|
||||||
{ROLE[member.role as keyof typeof ROLE] ?? "None"}
|
{selectedMember === member.id ? (
|
||||||
|
<CustomListbox
|
||||||
|
options={Object.keys(ROLE).map((key) => ({
|
||||||
|
value: key,
|
||||||
|
display: ROLE[parseInt(key) as keyof typeof ROLE],
|
||||||
|
}))}
|
||||||
|
title={ROLE[member.role as keyof typeof ROLE] ?? "Select Role"}
|
||||||
|
value={member.role}
|
||||||
|
onChange={(value) => {
|
||||||
|
if (!activeWorkspace || !projectId) return;
|
||||||
|
projectService
|
||||||
|
.updateProjectMember(
|
||||||
|
activeWorkspace.slug,
|
||||||
|
projectId as string,
|
||||||
|
member.id,
|
||||||
|
{
|
||||||
|
role: value,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then((res) => {
|
||||||
|
setToastAlert({
|
||||||
|
type: "success",
|
||||||
|
message: "Member role updated successfully.",
|
||||||
|
title: "Success",
|
||||||
|
});
|
||||||
|
mutateMembers(
|
||||||
|
(prevData: any) =>
|
||||||
|
prevData.map((m: any) => {
|
||||||
|
return m.id === selectedMember
|
||||||
|
? { ...m, ...res, role: value }
|
||||||
|
: m;
|
||||||
|
}),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
setSelectedMember(null);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
ROLE[member.role as keyof typeof ROLE] ?? "None"
|
||||||
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500 sm:pl-6">
|
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500 sm:pl-6">
|
||||||
{member?.member ? (
|
{member.status ? (
|
||||||
"Member"
|
|
||||||
) : member.status ? (
|
|
||||||
<span className="p-0.5 px-2 text-sm bg-green-700 text-white rounded-full">
|
<span className="p-0.5 px-2 text-sm bg-green-700 text-white rounded-full">
|
||||||
Active
|
Active
|
||||||
</span>
|
</span>
|
||||||
@ -167,7 +260,17 @@ const ProjectMembers: NextPage = () => {
|
|||||||
<button
|
<button
|
||||||
className="w-full text-left py-2 pl-2"
|
className="w-full text-left py-2 pl-2"
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => {}}
|
onClick={() => {
|
||||||
|
if (!member.status) {
|
||||||
|
setToastAlert({
|
||||||
|
type: "error",
|
||||||
|
message: "You can't edit a pending invitation.",
|
||||||
|
title: "Error",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setSelectedMember(member.id);
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Edit
|
Edit
|
||||||
</button>
|
</button>
|
||||||
@ -178,20 +281,12 @@ const ProjectMembers: NextPage = () => {
|
|||||||
<button
|
<button
|
||||||
className="w-full text-left py-2 pl-2"
|
className="w-full text-left py-2 pl-2"
|
||||||
type="button"
|
type="button"
|
||||||
onClick={async () => {
|
onClick={() => {
|
||||||
member.member
|
if (member.status) {
|
||||||
? (await projectService.deleteProjectMember(
|
setSelectedRemoveMember(member.id);
|
||||||
activeWorkspace?.slug as string,
|
} else {
|
||||||
projectId as any,
|
setSelectedInviteRemoveMember(member.id);
|
||||||
member.id
|
}
|
||||||
),
|
|
||||||
await mutateMembers())
|
|
||||||
: (await projectService.deleteProjectInvitation(
|
|
||||||
activeWorkspace?.slug as string,
|
|
||||||
projectId as any,
|
|
||||||
member.id
|
|
||||||
),
|
|
||||||
await mutateInvitations());
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Remove
|
Remove
|
||||||
|
@ -1,55 +1,52 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useCallback, useState } from "react";
|
||||||
// next
|
// next
|
||||||
import type { NextPage } from "next";
|
import type { NextPage } from "next";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import dynamic from "next/dynamic";
|
|
||||||
// swr
|
// swr
|
||||||
import useSWR, { mutate } from "swr";
|
import { mutate } from "swr";
|
||||||
|
// swr
|
||||||
|
import useSWR from "swr";
|
||||||
// react hook form
|
// react hook form
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm, Controller } from "react-hook-form";
|
||||||
// headless ui
|
// headless ui
|
||||||
import { Tab } from "@headlessui/react";
|
import { Listbox, Tab, Transition } from "@headlessui/react";
|
||||||
// layouts
|
// layouts
|
||||||
import AdminLayout from "layouts/AdminLayout";
|
import AdminLayout from "layouts/AdminLayout";
|
||||||
// service
|
// service
|
||||||
import projectServices from "lib/services/project.service";
|
import projectServices from "lib/services/project.service";
|
||||||
|
import workspaceService from "lib/services/workspace.service";
|
||||||
// hooks
|
// hooks
|
||||||
import useUser from "lib/hooks/useUser";
|
import useUser from "lib/hooks/useUser";
|
||||||
import useToast from "lib/hooks/useToast";
|
import useToast from "lib/hooks/useToast";
|
||||||
// fetch keys
|
// fetch keys
|
||||||
import { PROJECT_DETAILS, PROJECTS_LIST } from "constants/fetch-keys";
|
import { PROJECT_DETAILS, PROJECTS_LIST, WORKSPACE_MEMBERS } from "constants/fetch-keys";
|
||||||
|
// commons
|
||||||
|
import { addSpaceIfCamelCase, debounce } from "constants/common";
|
||||||
|
// components
|
||||||
|
import CreateUpdateStateModal from "components/project/issues/BoardView/state/CreateUpdateStateModal";
|
||||||
// ui
|
// ui
|
||||||
import { Spinner } from "ui";
|
import { Spinner, Button, Input, TextArea, Select } from "ui";
|
||||||
import { Breadcrumbs, BreadcrumbItem } from "ui/Breadcrumbs";
|
import { Breadcrumbs, BreadcrumbItem } from "ui/Breadcrumbs";
|
||||||
|
// icons
|
||||||
|
import {
|
||||||
|
ChevronDownIcon,
|
||||||
|
CheckIcon,
|
||||||
|
PlusIcon,
|
||||||
|
PencilSquareIcon,
|
||||||
|
RectangleGroupIcon,
|
||||||
|
PencilIcon,
|
||||||
|
} from "@heroicons/react/24/outline";
|
||||||
// types
|
// types
|
||||||
import type { IProject, IWorkspace } from "types";
|
import type { IProject, IWorkspace, WorkspaceMember } from "types";
|
||||||
|
|
||||||
const defaultValues: Partial<IProject> = {
|
const defaultValues: Partial<IProject> = {
|
||||||
name: "",
|
name: "",
|
||||||
description: "",
|
description: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const NETWORK_CHOICES = { "0": "Secret", "2": "Public" };
|
||||||
|
|
||||||
const ProjectSettings: NextPage = () => {
|
const ProjectSettings: NextPage = () => {
|
||||||
const GeneralSettings = dynamic(() => import("components/project/settings/GeneralSettings"), {
|
|
||||||
loading: () => <p>Loading...</p>,
|
|
||||||
ssr: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const ControlSettings = dynamic(() => import("components/project/settings/ControlSettings"), {
|
|
||||||
loading: () => <p>Loading...</p>,
|
|
||||||
ssr: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const StatesSettings = dynamic(() => import("components/project/settings/StatesSettings"), {
|
|
||||||
loading: () => <p>Loading...</p>,
|
|
||||||
ssr: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const LabelsSettings = dynamic(() => import("components/project/settings/LabelsSettings"), {
|
|
||||||
loading: () => <p>Loading...</p>,
|
|
||||||
ssr: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@ -61,11 +58,15 @@ const ProjectSettings: NextPage = () => {
|
|||||||
defaultValues,
|
defaultValues,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [isCreateStateModalOpen, setIsCreateStateModalOpen] = useState(false);
|
||||||
|
const [selectedState, setSelectedState] = useState<string | undefined>();
|
||||||
|
const [newGroupForm, setNewGroupForm] = useState(false);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const { projectId } = router.query;
|
const { projectId } = router.query;
|
||||||
|
|
||||||
const { activeWorkspace, activeProject } = useUser();
|
const { activeWorkspace, activeProject, states } = useUser();
|
||||||
|
|
||||||
const { setToastAlert } = useToast();
|
const { setToastAlert } = useToast();
|
||||||
|
|
||||||
@ -76,6 +77,11 @@ const ProjectSettings: NextPage = () => {
|
|||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { data: people } = useSWR<WorkspaceMember[]>(
|
||||||
|
activeWorkspace ? WORKSPACE_MEMBERS : null,
|
||||||
|
activeWorkspace ? () => workspaceService.workspaceMembers(activeWorkspace.slug) : null
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
projectDetails &&
|
projectDetails &&
|
||||||
reset({
|
reset({
|
||||||
@ -124,9 +130,28 @@ const ProjectSettings: NextPage = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkIdentifier = (slug: string, value: string) => {
|
||||||
|
projectServices.checkProjectIdentifierAvailability(slug, value).then((response) => {
|
||||||
|
console.log(response);
|
||||||
|
if (response.exists) setError("identifier", { message: "Identifier already exists" });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
const checkIdentifierAvailability = useCallback(debounce(checkIdentifier, 1500), []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AdminLayout>
|
<AdminLayout>
|
||||||
<div className="space-y-5 mb-5">
|
<div className="space-y-5 mb-5">
|
||||||
|
<CreateUpdateStateModal
|
||||||
|
isOpen={isCreateStateModalOpen || Boolean(selectedState)}
|
||||||
|
handleClose={() => {
|
||||||
|
setSelectedState(undefined);
|
||||||
|
setIsCreateStateModalOpen(false);
|
||||||
|
}}
|
||||||
|
projectId={projectId as string}
|
||||||
|
data={selectedState ? states?.find((state) => state.id === selectedState) : undefined}
|
||||||
|
/>
|
||||||
<Breadcrumbs>
|
<Breadcrumbs>
|
||||||
<BreadcrumbItem title="Projects" link="/projects" />
|
<BreadcrumbItem title="Projects" link="/projects" />
|
||||||
<BreadcrumbItem title={`${activeProject?.name ?? "Project"} Settings`} />
|
<BreadcrumbItem title={`${activeProject?.name ?? "Project"} Settings`} />
|
||||||
@ -134,13 +159,14 @@ const ProjectSettings: NextPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
{projectDetails ? (
|
{projectDetails ? (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
|
<form onSubmit={handleSubmit(onSubmit)} className="mt-3">
|
||||||
<Tab.Group>
|
<Tab.Group>
|
||||||
<Tab.List className="flex items-center gap-x-4 gap-y-2 flex-wrap mb-8">
|
<Tab.List className="flex items-center gap-x-4 gap-y-2 flex-wrap">
|
||||||
{["General", "Control", "States", "Labels"].map((tab, index) => (
|
{["General", "Control", "States", "Labels"].map((tab, index) => (
|
||||||
<Tab
|
<Tab
|
||||||
key={index}
|
key={index}
|
||||||
className={({ selected }) =>
|
className={({ selected }) =>
|
||||||
`px-6 py-2 border-2 border-theme hover:bg-theme hover:text-white text-xs font-medium rounded-md outline-none duration-300 ${
|
`px-6 py-2 border-2 border-theme hover:bg-theme hover:text-white text-xs font-medium rounded-md duration-300 ${
|
||||||
selected ? "bg-theme text-white" : ""
|
selected ? "bg-theme text-white" : ""
|
||||||
}`
|
}`
|
||||||
}
|
}
|
||||||
@ -149,23 +175,362 @@ const ProjectSettings: NextPage = () => {
|
|||||||
</Tab>
|
</Tab>
|
||||||
))}
|
))}
|
||||||
</Tab.List>
|
</Tab.List>
|
||||||
<Tab.Panels>
|
<Tab.Panels className="mt-8">
|
||||||
<form onSubmit={handleSubmit(onSubmit)}>
|
|
||||||
<Tab.Panel>
|
<Tab.Panel>
|
||||||
<GeneralSettings register={register} errors={errors} setError={setError} />
|
<section className="space-y-5">
|
||||||
|
<div>
|
||||||
|
<h3 className="text-lg font-medium leading-6 text-gray-900">General</h3>
|
||||||
|
<p className="mt-1 text-sm text-gray-500">
|
||||||
|
This information will be displayed to every member of the project.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-4 gap-3">
|
||||||
|
<div className="col-span-2">
|
||||||
|
<Input
|
||||||
|
id="name"
|
||||||
|
name="name"
|
||||||
|
error={errors.name}
|
||||||
|
register={register}
|
||||||
|
placeholder="Project Name"
|
||||||
|
label="Name"
|
||||||
|
validations={{
|
||||||
|
required: "Name is required",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Select
|
||||||
|
name="network"
|
||||||
|
id="network"
|
||||||
|
options={Object.keys(NETWORK_CHOICES).map((key) => ({
|
||||||
|
value: key,
|
||||||
|
label: NETWORK_CHOICES[key as keyof typeof NETWORK_CHOICES],
|
||||||
|
}))}
|
||||||
|
label="Network"
|
||||||
|
register={register}
|
||||||
|
validations={{
|
||||||
|
required: "Network is required",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Input
|
||||||
|
id="identifier"
|
||||||
|
name="identifier"
|
||||||
|
error={errors.identifier}
|
||||||
|
register={register}
|
||||||
|
placeholder="Enter identifier"
|
||||||
|
label="Identifier"
|
||||||
|
onChange={(e: any) => {
|
||||||
|
if (!activeWorkspace || !e.target.value) return;
|
||||||
|
checkIdentifierAvailability(activeWorkspace.slug, e.target.value);
|
||||||
|
}}
|
||||||
|
validations={{
|
||||||
|
required: "Identifier is required",
|
||||||
|
minLength: {
|
||||||
|
value: 1,
|
||||||
|
message: "Identifier must at least be of 1 character",
|
||||||
|
},
|
||||||
|
maxLength: {
|
||||||
|
value: 9,
|
||||||
|
message: "Identifier must at most be of 9 characters",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<TextArea
|
||||||
|
id="description"
|
||||||
|
name="description"
|
||||||
|
error={errors.description}
|
||||||
|
register={register}
|
||||||
|
label="Description"
|
||||||
|
placeholder="Enter project description"
|
||||||
|
validations={{
|
||||||
|
required: "Description is required",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex justify-end">
|
||||||
|
<Button type="submit" disabled={isSubmitting}>
|
||||||
|
{isSubmitting ? "Updating Project..." : "Update Project"}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
</Tab.Panel>
|
</Tab.Panel>
|
||||||
<Tab.Panel>
|
<Tab.Panel>
|
||||||
<ControlSettings control={control} isSubmitting={isSubmitting} />
|
<section className="space-y-5">
|
||||||
</Tab.Panel>
|
<div>
|
||||||
</form>
|
<h3 className="text-lg font-medium leading-6 text-gray-900">Control</h3>
|
||||||
<Tab.Panel>
|
<p className="mt-1 text-sm text-gray-500">Set the control for the project.</p>
|
||||||
<StatesSettings projectId={projectId} />
|
</div>
|
||||||
|
<div className="flex justify-between gap-3">
|
||||||
|
<div className="w-full md:w-1/2">
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="project_lead"
|
||||||
|
render={({ field: { onChange, value } }) => (
|
||||||
|
<Listbox value={value} onChange={onChange}>
|
||||||
|
{({ open }) => (
|
||||||
|
<>
|
||||||
|
<Listbox.Label>
|
||||||
|
<div className="text-gray-500 mb-2">Project Lead</div>
|
||||||
|
</Listbox.Label>
|
||||||
|
<div className="relative">
|
||||||
|
<Listbox.Button className="bg-white relative w-full border border-gray-300 rounded-md shadow-sm pl-3 pr-10 py-2 text-left cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||||
|
<span className="block truncate">
|
||||||
|
{people?.find((person) => person.member.id === value)
|
||||||
|
?.member.first_name ?? "Select Lead"}
|
||||||
|
</span>
|
||||||
|
<span className="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none">
|
||||||
|
<ChevronDownIcon
|
||||||
|
className="h-5 w-5 text-gray-400"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</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 w-full bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm">
|
||||||
|
{people?.map((person) => (
|
||||||
|
<Listbox.Option
|
||||||
|
key={person.id}
|
||||||
|
className={({ active }) =>
|
||||||
|
`${
|
||||||
|
active ? "text-white bg-theme" : "text-gray-900"
|
||||||
|
} cursor-default select-none relative py-2 pl-3 pr-9`
|
||||||
|
}
|
||||||
|
value={person.member.id}
|
||||||
|
>
|
||||||
|
{({ selected, active }) => (
|
||||||
|
<>
|
||||||
|
<span
|
||||||
|
className={`${
|
||||||
|
selected ? "font-semibold" : "font-normal"
|
||||||
|
} block truncate`}
|
||||||
|
>
|
||||||
|
{person.member.first_name}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{selected ? (
|
||||||
|
<span
|
||||||
|
className={`absolute inset-y-0 right-0 flex items-center pr-4 ${
|
||||||
|
active ? "text-white" : "text-indigo-600"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<CheckIcon
|
||||||
|
className="h-5 w-5"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Listbox.Option>
|
||||||
|
))}
|
||||||
|
</Listbox.Options>
|
||||||
|
</Transition>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Listbox>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="w-full md:w-1/2">
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="default_assignee"
|
||||||
|
render={({ field: { value, onChange } }) => (
|
||||||
|
<Listbox value={value} onChange={onChange}>
|
||||||
|
{({ open }) => (
|
||||||
|
<>
|
||||||
|
<Listbox.Label>
|
||||||
|
<div className="text-gray-500 mb-2">Default Assignee</div>
|
||||||
|
</Listbox.Label>
|
||||||
|
<div className="relative">
|
||||||
|
<Listbox.Button className="bg-white relative w-full border border-gray-300 rounded-md shadow-sm pl-3 pr-10 py-2 text-left cursor-default focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||||
|
<span className="block truncate">
|
||||||
|
{people?.find((p) => p.member.id === value)?.member
|
||||||
|
.first_name ?? "Select Default Assignee"}
|
||||||
|
</span>
|
||||||
|
<span className="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none">
|
||||||
|
<ChevronDownIcon
|
||||||
|
className="h-5 w-5 text-gray-400"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</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 w-full bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm">
|
||||||
|
{people?.map((person) => (
|
||||||
|
<Listbox.Option
|
||||||
|
key={person.id}
|
||||||
|
className={({ active }) =>
|
||||||
|
`${
|
||||||
|
active ? "text-white bg-theme" : "text-gray-900"
|
||||||
|
} cursor-default select-none relative py-2 pl-3 pr-9`
|
||||||
|
}
|
||||||
|
value={person.member.id}
|
||||||
|
>
|
||||||
|
{({ selected, active }) => (
|
||||||
|
<>
|
||||||
|
<span
|
||||||
|
className={`${
|
||||||
|
selected ? "font-semibold" : "font-normal"
|
||||||
|
} block truncate`}
|
||||||
|
>
|
||||||
|
{person.member.first_name}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{selected ? (
|
||||||
|
<span
|
||||||
|
className={`absolute inset-y-0 right-0 flex items-center pr-4 ${
|
||||||
|
active ? "text-white" : "text-indigo-600"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<CheckIcon
|
||||||
|
className="h-5 w-5"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Listbox.Option>
|
||||||
|
))}
|
||||||
|
</Listbox.Options>
|
||||||
|
</Transition>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Listbox>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex justify-end">
|
||||||
|
<Button type="submit" disabled={isSubmitting}>
|
||||||
|
{isSubmitting ? "Updating Project..." : "Update Project"}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
</Tab.Panel>
|
</Tab.Panel>
|
||||||
<Tab.Panel>
|
<Tab.Panel>
|
||||||
<LabelsSettings />
|
<section className="space-y-5">
|
||||||
|
<div>
|
||||||
|
<h3 className="text-lg font-medium leading-6 text-gray-900">State</h3>
|
||||||
|
<p className="mt-1 text-sm text-gray-500">
|
||||||
|
Manage the state of this project.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="flex justify-between gap-3">
|
||||||
|
<div className="w-full space-y-5">
|
||||||
|
{states?.map((state) => (
|
||||||
|
<div
|
||||||
|
key={state.id}
|
||||||
|
className="bg-white px-4 py-2 rounded flex justify-between items-center"
|
||||||
|
>
|
||||||
|
<div className="flex items-center gap-x-2">
|
||||||
|
<div
|
||||||
|
className="w-3 h-3 rounded-full"
|
||||||
|
style={{
|
||||||
|
backgroundColor: state.color,
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
|
<h4>{addSpaceIfCamelCase(state.name)}</h4>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button type="button" onClick={() => setSelectedState(state.id)}>
|
||||||
|
<PencilSquareIcon className="h-5 w-5 text-gray-400" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
className="flex items-center gap-x-1"
|
||||||
|
onClick={() => setIsCreateStateModalOpen(true)}
|
||||||
|
>
|
||||||
|
<PlusIcon className="h-4 w-4" />
|
||||||
|
<span>Add State</span>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</Tab.Panel>
|
||||||
|
<Tab.Panel>
|
||||||
|
<section className="space-y-5">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<h3 className="text-lg font-medium leading-6 text-gray-900">Labels</h3>
|
||||||
|
<p className="mt-1 text-sm text-gray-500">
|
||||||
|
Manage the labels of this project.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
className="flex items-center gap-x-1"
|
||||||
|
onClick={() => setNewGroupForm(true)}
|
||||||
|
>
|
||||||
|
<PlusIcon className="h-4 w-4" />
|
||||||
|
New group
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-5">
|
||||||
|
<div
|
||||||
|
className={`bg-white px-4 py-2 flex items-center gap-2 ${
|
||||||
|
newGroupForm ? "" : "hidden"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<Input type="text" name="groupName" />
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
theme="secondary"
|
||||||
|
onClick={() => setNewGroupForm(false)}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button type="button">Save</Button>
|
||||||
|
</div>
|
||||||
|
{["", ""].map((group, index) => (
|
||||||
|
<div key={index} className="bg-white p-4 text-gray-900 rounded-md">
|
||||||
|
<h3 className="font-medium leading-5 flex items-center gap-2">
|
||||||
|
<RectangleGroupIcon className="h-5 w-5" />
|
||||||
|
This is the label group title
|
||||||
|
</h3>
|
||||||
|
<div className="pl-5 mt-4">
|
||||||
|
<div className="group text-sm flex justify-between items-center p-2 hover:bg-gray-100 rounded">
|
||||||
|
<h5 className="flex items-center gap-2">
|
||||||
|
<div className="w-2 h-2 bg-red-600 rounded-full"></div>
|
||||||
|
This is the label title
|
||||||
|
</h5>
|
||||||
|
<div className="hidden group-hover:block">
|
||||||
|
<PencilIcon className="h-3 w-3" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
</Tab.Panel>
|
</Tab.Panel>
|
||||||
</Tab.Panels>
|
</Tab.Panels>
|
||||||
</Tab.Group>
|
</Tab.Group>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="h-full w-full flex justify-center items-center">
|
<div className="h-full w-full flex justify-center items-center">
|
||||||
|
@ -14,7 +14,7 @@ import useUser from "lib/hooks/useUser";
|
|||||||
// layouts
|
// layouts
|
||||||
import DefaultLayout from "layouts/DefaultLayout";
|
import DefaultLayout from "layouts/DefaultLayout";
|
||||||
// ui
|
// ui
|
||||||
import { Button } from "ui";
|
import { Button, Spinner } from "ui";
|
||||||
// icons
|
// icons
|
||||||
import {
|
import {
|
||||||
ChartBarIcon,
|
ChartBarIcon,
|
||||||
@ -35,8 +35,9 @@ const WorkspaceInvitation: NextPage = () => {
|
|||||||
|
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
|
|
||||||
const { data: invitationDetail, error } = useSWR(WORKSPACE_INVITATION, () =>
|
const { data: invitationDetail, error } = useSWR(
|
||||||
workspaceService.getWorkspaceInvitation(invitationId as string)
|
invitationId && WORKSPACE_INVITATION,
|
||||||
|
() => invitationId && workspaceService.getWorkspaceInvitation(invitationId as string)
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleAccept = () => {
|
const handleAccept = () => {
|
||||||
@ -93,7 +94,7 @@ const WorkspaceInvitation: NextPage = () => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : error ? (
|
||||||
<EmptySpace
|
<EmptySpace
|
||||||
title="This invitation link is not active anymore."
|
title="This invitation link is not active anymore."
|
||||||
description="Your workspace is where you'll create projects, collaborate on your issues, and organize different streams of work in your Plane account."
|
description="Your workspace is where you'll create projects, collaborate on your issues, and organize different streams of work in your Plane account."
|
||||||
@ -131,6 +132,10 @@ const WorkspaceInvitation: NextPage = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</EmptySpace>
|
</EmptySpace>
|
||||||
|
) : (
|
||||||
|
<div className="w-full h-full flex justify-center items-center">
|
||||||
|
<Spinner />
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</DefaultLayout>
|
</DefaultLayout>
|
||||||
|
@ -8,9 +8,11 @@ import useSWR from "swr";
|
|||||||
import { Menu } from "@headlessui/react";
|
import { Menu } from "@headlessui/react";
|
||||||
// hooks
|
// hooks
|
||||||
import useUser from "lib/hooks/useUser";
|
import useUser from "lib/hooks/useUser";
|
||||||
|
import useToast from "lib/hooks/useToast";
|
||||||
// services
|
// services
|
||||||
import workspaceService from "lib/services/workspace.service";
|
import workspaceService from "lib/services/workspace.service";
|
||||||
// constants
|
// constants
|
||||||
|
import { ROLE } from "constants/";
|
||||||
import { WORKSPACE_INVITATIONS, WORKSPACE_MEMBERS } from "constants/fetch-keys";
|
import { WORKSPACE_INVITATIONS, WORKSPACE_MEMBERS } from "constants/fetch-keys";
|
||||||
// hoc
|
// hoc
|
||||||
import withAuthWrapper from "lib/hoc/withAuthWrapper";
|
import withAuthWrapper from "lib/hoc/withAuthWrapper";
|
||||||
@ -18,26 +20,26 @@ import withAuthWrapper from "lib/hoc/withAuthWrapper";
|
|||||||
import AdminLayout from "layouts/AdminLayout";
|
import AdminLayout from "layouts/AdminLayout";
|
||||||
// components
|
// components
|
||||||
import SendWorkspaceInvitationModal from "components/workspace/SendWorkspaceInvitationModal";
|
import SendWorkspaceInvitationModal from "components/workspace/SendWorkspaceInvitationModal";
|
||||||
|
import ConfirmWorkspaceMemberRemove from "components/workspace/ConfirmWorkspaceMemberRemove";
|
||||||
// ui
|
// ui
|
||||||
import { Spinner, Button } from "ui";
|
import { Spinner, CustomListbox } from "ui";
|
||||||
// icons
|
// icons
|
||||||
import { PlusIcon, EllipsisHorizontalIcon } from "@heroicons/react/20/solid";
|
import { PlusIcon, EllipsisHorizontalIcon } from "@heroicons/react/20/solid";
|
||||||
import HeaderButton from "ui/HeaderButton";
|
import HeaderButton from "ui/HeaderButton";
|
||||||
import { BreadcrumbItem, Breadcrumbs } from "ui/Breadcrumbs";
|
import { BreadcrumbItem, Breadcrumbs } from "ui/Breadcrumbs";
|
||||||
// types
|
|
||||||
|
|
||||||
const ROLE = {
|
|
||||||
5: "Guest",
|
|
||||||
10: "Viewer",
|
|
||||||
15: "Member",
|
|
||||||
20: "Admin",
|
|
||||||
};
|
|
||||||
|
|
||||||
const WorkspaceInvite: NextPage = () => {
|
const WorkspaceInvite: NextPage = () => {
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
|
||||||
|
const [selectedMember, setSelectedMember] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const [selectedRemoveMember, setSelectedRemoveMember] = useState<string | null>(null);
|
||||||
|
const [selectedInviteRemoveMember, setSelectedInviteRemoveMember] = useState<string | null>(null);
|
||||||
|
|
||||||
const { activeWorkspace } = useUser();
|
const { activeWorkspace } = useUser();
|
||||||
|
|
||||||
|
const { setToastAlert } = useToast();
|
||||||
|
|
||||||
const { data: workspaceMembers, mutate: mutateMembers } = useSWR<any[]>(
|
const { data: workspaceMembers, mutate: mutateMembers } = useSWR<any[]>(
|
||||||
activeWorkspace ? WORKSPACE_MEMBERS : null,
|
activeWorkspace ? WORKSPACE_MEMBERS : null,
|
||||||
activeWorkspace ? () => workspaceService.workspaceMembers(activeWorkspace.slug) : null
|
activeWorkspace ? () => workspaceService.workspaceMembers(activeWorkspace.slug) : null
|
||||||
@ -74,6 +76,50 @@ const WorkspaceInvite: NextPage = () => {
|
|||||||
title: "Plane - Workspace Invite",
|
title: "Plane - Workspace Invite",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<ConfirmWorkspaceMemberRemove
|
||||||
|
isOpen={Boolean(selectedRemoveMember) || Boolean(selectedInviteRemoveMember)}
|
||||||
|
onClose={() => {
|
||||||
|
setSelectedRemoveMember(null);
|
||||||
|
setSelectedInviteRemoveMember(null);
|
||||||
|
}}
|
||||||
|
data={
|
||||||
|
selectedRemoveMember
|
||||||
|
? members.find((item) => item.id === selectedRemoveMember)
|
||||||
|
: selectedInviteRemoveMember
|
||||||
|
? members.find((item) => item.id === selectedInviteRemoveMember)
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
handleDelete={async () => {
|
||||||
|
if (!activeWorkspace) return;
|
||||||
|
if (selectedRemoveMember) {
|
||||||
|
await workspaceService.deleteWorkspaceMember(
|
||||||
|
activeWorkspace.slug,
|
||||||
|
selectedRemoveMember
|
||||||
|
);
|
||||||
|
mutateMembers(
|
||||||
|
(prevData) => prevData?.filter((item) => item.id !== selectedRemoveMember),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (selectedInviteRemoveMember) {
|
||||||
|
await workspaceService.deleteWorkspaceInvitations(
|
||||||
|
activeWorkspace.slug,
|
||||||
|
selectedInviteRemoveMember
|
||||||
|
);
|
||||||
|
mutateInvitations(
|
||||||
|
(prevData) => prevData?.filter((item) => item.id !== selectedInviteRemoveMember),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
setToastAlert({
|
||||||
|
type: "success",
|
||||||
|
title: "Success",
|
||||||
|
message: "Member removed successfully",
|
||||||
|
});
|
||||||
|
setSelectedRemoveMember(null);
|
||||||
|
setSelectedInviteRemoveMember(null);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<SendWorkspaceInvitationModal
|
<SendWorkspaceInvitationModal
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
setIsOpen={setIsOpen}
|
setIsOpen={setIsOpen}
|
||||||
@ -141,14 +187,49 @@ const WorkspaceInvite: NextPage = () => {
|
|||||||
{member.email ?? "No email has been added."}
|
{member.email ?? "No email has been added."}
|
||||||
</td>
|
</td>
|
||||||
<td className="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">
|
<td className="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">
|
||||||
{ROLE[member.role as keyof typeof ROLE] ?? "None"}
|
{selectedMember === member.id ? (
|
||||||
|
<CustomListbox
|
||||||
|
options={Object.keys(ROLE).map((key) => ({
|
||||||
|
display: ROLE[parseInt(key) as keyof typeof ROLE],
|
||||||
|
value: key,
|
||||||
|
}))}
|
||||||
|
title={ROLE[member.role as keyof typeof ROLE] ?? "None"}
|
||||||
|
value={member.role}
|
||||||
|
onChange={(value) => {
|
||||||
|
workspaceService
|
||||||
|
.updateWorkspaceMember(activeWorkspace?.slug as string, member.id, {
|
||||||
|
role: value,
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
mutateMembers(
|
||||||
|
(prevData) =>
|
||||||
|
prevData?.map((m) => {
|
||||||
|
return m.id === selectedMember ? { ...m, role: value } : m;
|
||||||
|
}),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
setToastAlert({
|
||||||
|
title: "Success",
|
||||||
|
type: "success",
|
||||||
|
message: "Member role updated successfully.",
|
||||||
|
});
|
||||||
|
setSelectedMember(null);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
setToastAlert({
|
||||||
|
title: "Error",
|
||||||
|
type: "error",
|
||||||
|
message: "An error occurred while updating member role.",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
ROLE[member.role as keyof typeof ROLE] ?? "None"
|
||||||
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500 sm:pl-6">
|
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500 sm:pl-6">
|
||||||
{member?.member ? (
|
{member.status ? (
|
||||||
<span className="p-0.5 px-2 text-sm bg-green-700 text-white rounded-full">
|
|
||||||
Active
|
|
||||||
</span>
|
|
||||||
) : member.status ? (
|
|
||||||
<span className="p-0.5 px-2 text-sm bg-green-700 text-white rounded-full">
|
<span className="p-0.5 px-2 text-sm bg-green-700 text-white rounded-full">
|
||||||
Active
|
Active
|
||||||
</span>
|
</span>
|
||||||
@ -173,7 +254,18 @@ const WorkspaceInvite: NextPage = () => {
|
|||||||
<button
|
<button
|
||||||
className="w-full text-left py-2 pl-2"
|
className="w-full text-left py-2 pl-2"
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => {}}
|
onClick={() => {
|
||||||
|
if (!member.status || !member.member) {
|
||||||
|
setToastAlert({
|
||||||
|
type: "error",
|
||||||
|
title: "Error",
|
||||||
|
message: "You can't edit this member.",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
setSelectedMember(member.id);
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Edit
|
Edit
|
||||||
</button>
|
</button>
|
||||||
@ -184,26 +276,12 @@ const WorkspaceInvite: NextPage = () => {
|
|||||||
<button
|
<button
|
||||||
className="w-full text-left py-2 pl-2"
|
className="w-full text-left py-2 pl-2"
|
||||||
type="button"
|
type="button"
|
||||||
onClick={async () => {
|
onClick={() => {
|
||||||
member.member
|
if (member.status) {
|
||||||
? (await workspaceService.deleteWorkspaceMember(
|
setSelectedRemoveMember(member.id);
|
||||||
activeWorkspace?.slug as string,
|
} else {
|
||||||
member.id
|
setSelectedInviteRemoveMember(member.id);
|
||||||
),
|
}
|
||||||
await mutateMembers((prevData) => [
|
|
||||||
...(prevData ?? [])?.filter(
|
|
||||||
(m: any) => m.id !== member.id
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
false)
|
|
||||||
: (await workspaceService.deleteWorkspaceInvitations(
|
|
||||||
activeWorkspace?.slug as string,
|
|
||||||
member.id
|
|
||||||
),
|
|
||||||
await mutateInvitations((prevData) => [
|
|
||||||
...(prevData ?? []).filter((m) => m.id !== member.id),
|
|
||||||
false,
|
|
||||||
]));
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Remove
|
Remove
|
||||||
|
7
apps/app/types/issues.d.ts
vendored
7
apps/app/types/issues.d.ts
vendored
@ -98,18 +98,11 @@ export type IssuePriorities = {
|
|||||||
|
|
||||||
export type Properties = {
|
export type Properties = {
|
||||||
key: boolean;
|
key: boolean;
|
||||||
name: boolean;
|
|
||||||
parent: boolean;
|
|
||||||
project: boolean;
|
|
||||||
state: boolean;
|
state: boolean;
|
||||||
assignee: boolean;
|
assignee: boolean;
|
||||||
description: boolean;
|
|
||||||
priority: boolean;
|
priority: boolean;
|
||||||
start_date: boolean;
|
start_date: boolean;
|
||||||
target_date: boolean;
|
target_date: boolean;
|
||||||
sequence_id: boolean;
|
|
||||||
attachments: boolean;
|
|
||||||
children: boolean;
|
|
||||||
cycle: boolean;
|
cycle: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,11 +10,19 @@ import { classNames } from "constants/common";
|
|||||||
// types
|
// types
|
||||||
import type { MenuItemProps, Props } from "./types";
|
import type { MenuItemProps, Props } from "./types";
|
||||||
|
|
||||||
const CustomMenu = ({ children, label }: Props) => {
|
const CustomMenu = ({ children, label, textAlignment }: Props) => {
|
||||||
return (
|
return (
|
||||||
<Menu as="div" className="relative inline-block text-left">
|
<Menu as="div" className="relative inline-block text-left">
|
||||||
<div>
|
<div>
|
||||||
<Menu.Button className="inline-flex w-32 justify-between gap-x-4 rounded-md border border-gray-300 bg-white px-4 py-1 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:ring-offset-gray-100">
|
<Menu.Button
|
||||||
|
className={`inline-flex w-32 justify-between gap-x-4 rounded-md border border-gray-300 bg-white px-4 py-1 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:ring-offset-gray-100 ${
|
||||||
|
textAlignment === "right"
|
||||||
|
? "text-right"
|
||||||
|
: textAlignment === "center"
|
||||||
|
? "text-center"
|
||||||
|
: "text-left"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
<span className="truncate w-20">{label}</span>
|
<span className="truncate w-20">{label}</span>
|
||||||
<ChevronDownIcon className="-mr-1 ml-2 h-5 w-5" aria-hidden="true" />
|
<ChevronDownIcon className="-mr-1 ml-2 h-5 w-5" aria-hidden="true" />
|
||||||
</Menu.Button>
|
</Menu.Button>
|
||||||
|
1
apps/app/ui/CustomMenu/types.d.ts
vendored
1
apps/app/ui/CustomMenu/types.d.ts
vendored
@ -1,6 +1,7 @@
|
|||||||
export type Props = {
|
export type Props = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
label: string;
|
label: string;
|
||||||
|
textAlignment?: "left" | "center" | "right";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type MenuItemProps = {
|
export type MenuItemProps = {
|
||||||
|
Loading…
Reference in New Issue
Block a user