mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
parent
bdca84bd09
commit
3d28cde91d
@ -20,9 +20,10 @@ import { copyTextToClipboard } from "helpers/string.helper";
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
module: IModule;
|
module: IModule;
|
||||||
|
handleEditModule: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SingleModuleCard: React.FC<Props> = ({ module }) => {
|
export const SingleModuleCard: React.FC<Props> = ({ module, handleEditModule }) => {
|
||||||
const [moduleDeleteModal, setModuleDeleteModal] = useState(false);
|
const [moduleDeleteModal, setModuleDeleteModal] = useState(false);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -64,6 +65,7 @@ export const SingleModuleCard: React.FC<Props> = ({ module }) => {
|
|||||||
<div className="absolute top-4 right-4 ">
|
<div className="absolute top-4 right-4 ">
|
||||||
<CustomMenu width="auto" ellipsis>
|
<CustomMenu width="auto" ellipsis>
|
||||||
<CustomMenu.MenuItem onClick={handleCopyText}>Copy module link</CustomMenu.MenuItem>
|
<CustomMenu.MenuItem onClick={handleCopyText}>Copy module link</CustomMenu.MenuItem>
|
||||||
|
<CustomMenu.MenuItem onClick={handleEditModule}>Edit module</CustomMenu.MenuItem>
|
||||||
<CustomMenu.MenuItem onClick={handleDeleteModule}>
|
<CustomMenu.MenuItem onClick={handleDeleteModule}>
|
||||||
Delete module permanently
|
Delete module permanently
|
||||||
</CustomMenu.MenuItem>
|
</CustomMenu.MenuItem>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
@ -12,13 +12,13 @@ import { requiredAuth } from "lib/auth";
|
|||||||
import projectService from "services/project.service";
|
import projectService from "services/project.service";
|
||||||
import modulesService from "services/modules.service";
|
import modulesService from "services/modules.service";
|
||||||
// components
|
// components
|
||||||
import { SingleModuleCard } from "components/modules";
|
import { CreateUpdateModuleModal, SingleModuleCard } from "components/modules";
|
||||||
// ui
|
// ui
|
||||||
import { EmptySpace, EmptySpaceItem, HeaderButton, Loader } from "components/ui";
|
import { EmptySpace, EmptySpaceItem, HeaderButton, Loader } from "components/ui";
|
||||||
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
||||||
// icons
|
// icons
|
||||||
// types
|
// types
|
||||||
import { IModule } from "types/modules";
|
import { IModule, SelectModuleType } from "types/modules";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
import type { NextPage, NextPageContext } from "next";
|
import type { NextPage, NextPageContext } from "next";
|
||||||
import { MODULE_LIST, PROJECT_DETAILS } from "constants/fetch-keys";
|
import { MODULE_LIST, PROJECT_DETAILS } from "constants/fetch-keys";
|
||||||
@ -26,6 +26,8 @@ import { MODULE_LIST, PROJECT_DETAILS } from "constants/fetch-keys";
|
|||||||
const ProjectModules: NextPage = () => {
|
const ProjectModules: NextPage = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug, projectId } = router.query;
|
const { workspaceSlug, projectId } = router.query;
|
||||||
|
const [selectedModule, setSelectedModule] = useState<SelectModuleType>();
|
||||||
|
const [createUpdateModule, setCreateUpdateModule] = useState(false);
|
||||||
|
|
||||||
const { data: activeProject } = useSWR(
|
const { data: activeProject } = useSWR(
|
||||||
workspaceSlug && projectId ? PROJECT_DETAILS(projectId as string) : null,
|
workspaceSlug && projectId ? PROJECT_DETAILS(projectId as string) : null,
|
||||||
@ -41,6 +43,19 @@ const ProjectModules: NextPage = () => {
|
|||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleEditModule = (module: IModule) => {
|
||||||
|
setSelectedModule({ ...module, actionType: "edit" });
|
||||||
|
setCreateUpdateModule(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (createUpdateModule) return;
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
setSelectedModule(undefined);
|
||||||
|
clearTimeout(timer);
|
||||||
|
}, 500);
|
||||||
|
}, [createUpdateModule]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppLayout
|
<AppLayout
|
||||||
meta={{
|
meta={{
|
||||||
@ -65,12 +80,22 @@ const ProjectModules: NextPage = () => {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
<CreateUpdateModuleModal
|
||||||
|
isOpen={createUpdateModule}
|
||||||
|
// handleClose={() => setCreateUpdateModule(false)}
|
||||||
|
setIsOpen={setCreateUpdateModule}
|
||||||
|
data={selectedModule}
|
||||||
|
/>
|
||||||
{modules ? (
|
{modules ? (
|
||||||
modules.length > 0 ? (
|
modules.length > 0 ? (
|
||||||
<div className="space-y-5">
|
<div className="space-y-5">
|
||||||
<div className="grid grid-cols-1 gap-2 md:grid-cols-2 lg:grid-cols-3">
|
<div className="grid grid-cols-1 gap-2 md:grid-cols-2 lg:grid-cols-3">
|
||||||
{modules.map((module) => (
|
{modules.map((module) => (
|
||||||
<SingleModuleCard key={module.id} module={module} />
|
<SingleModuleCard
|
||||||
|
key={module.id}
|
||||||
|
module={module}
|
||||||
|
handleEditModule={() => handleEditModule(module)}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user