forked from github/plane
feat: edit, delete project/workspaces member workflow, order issues by priority
This commit is contained in:
parent
b757609161
commit
7ad10e8e1e
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 }) => {
|
||||||
|
@ -174,10 +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]">
|
|
||||||
{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
|
||||||
@ -388,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");
|
||||||
<PlusIcon className="w-5 h-5" />
|
}}
|
||||||
<span>Create Workspace</span>
|
className="w-full"
|
||||||
</a>
|
>
|
||||||
</Link>
|
{({ 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" />
|
||||||
|
<span>Create Workspace</span>
|
||||||
|
</a>
|
||||||
)}
|
)}
|
||||||
</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) =>
|
||||||
<CustomMenu.MenuItem
|
groupByProperty === "priority" &&
|
||||||
key={option.key}
|
option.key === "priority" ? null : (
|
||||||
onClick={() => setOrderBy(option.key)}
|
<CustomMenu.MenuItem
|
||||||
>
|
key={option.key}
|
||||||
{option.name}
|
onClick={() => setOrderBy(option.key)}
|
||||||
</CustomMenu.MenuItem>
|
>
|
||||||
))}
|
{option.name}
|
||||||
|
</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,14 +189,55 @@ 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">
|
||||||
Accepted
|
Active
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<span className="p-0.5 px-2 text-sm bg-yellow-400 text-black rounded-full">
|
<span className="p-0.5 px-2 text-sm bg-yellow-400 text-black rounded-full">
|
||||||
@ -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
|
||||||
|
@ -252,6 +252,11 @@ const ProjectSettings: NextPage = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex justify-end">
|
||||||
|
<Button type="submit" disabled={isSubmitting}>
|
||||||
|
{isSubmitting ? "Updating Project..." : "Update Project"}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</Tab.Panel>
|
</Tab.Panel>
|
||||||
<Tab.Panel>
|
<Tab.Panel>
|
||||||
|
@ -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,16 +187,51 @@ 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">
|
<span className="p-0.5 px-2 text-sm bg-green-700 text-white rounded-full">
|
||||||
Accepted
|
Active
|
||||||
</span>
|
|
||||||
) : member.status ? (
|
|
||||||
<span className="p-0.5 px-2 text-sm bg-green-700 text-white rounded-full">
|
|
||||||
Accepted
|
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<span className="p-0.5 px-2 text-sm bg-yellow-400 text-black rounded-full">
|
<span className="p-0.5 px-2 text-sm bg-yellow-400 text-black rounded-full">
|
||||||
@ -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