mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: project search added in project list page (#1837)
This commit is contained in:
parent
e2b5657c3e
commit
762ef422ca
@ -16,7 +16,7 @@ import { WorkspaceAuthorizationLayout } from "layouts/auth-layout";
|
|||||||
import { JoinProjectModal } from "components/project/join-project-modal";
|
import { JoinProjectModal } from "components/project/join-project-modal";
|
||||||
import { DeleteProjectModal, SingleProjectCard } from "components/project";
|
import { DeleteProjectModal, SingleProjectCard } from "components/project";
|
||||||
// ui
|
// ui
|
||||||
import { EmptyState, Loader, PrimaryButton } from "components/ui";
|
import { EmptyState, Icon, Loader, PrimaryButton } from "components/ui";
|
||||||
import { Breadcrumbs, BreadcrumbItem } from "components/breadcrumbs";
|
import { Breadcrumbs, BreadcrumbItem } from "components/breadcrumbs";
|
||||||
// icons
|
// icons
|
||||||
import { PlusIcon } from "@heroicons/react/24/outline";
|
import { PlusIcon } from "@heroicons/react/24/outline";
|
||||||
@ -34,6 +34,8 @@ const ProjectsPage: NextPage = () => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug } = router.query;
|
const { workspaceSlug } = router.query;
|
||||||
|
|
||||||
|
const [query, setQuery] = useState("");
|
||||||
|
|
||||||
const { user } = useUserAuth();
|
const { user } = useUserAuth();
|
||||||
// context data
|
// context data
|
||||||
const { activeWorkspace } = useWorkspaces();
|
const { activeWorkspace } = useWorkspaces();
|
||||||
@ -42,6 +44,15 @@ const ProjectsPage: NextPage = () => {
|
|||||||
const [deleteProject, setDeleteProject] = useState<string | null>(null);
|
const [deleteProject, setDeleteProject] = useState<string | null>(null);
|
||||||
const [selectedProjectToJoin, setSelectedProjectToJoin] = useState<string | null>(null);
|
const [selectedProjectToJoin, setSelectedProjectToJoin] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const filteredProjectList =
|
||||||
|
query === ""
|
||||||
|
? projects
|
||||||
|
: projects?.filter(
|
||||||
|
(project) =>
|
||||||
|
project.name.toLowerCase().includes(query.toLowerCase()) ||
|
||||||
|
project.identifier.toLowerCase().includes(query.toLowerCase())
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WorkspaceAuthorizationLayout
|
<WorkspaceAuthorizationLayout
|
||||||
breadcrumbs={
|
breadcrumbs={
|
||||||
@ -53,8 +64,19 @@ const ProjectsPage: NextPage = () => {
|
|||||||
</Breadcrumbs>
|
</Breadcrumbs>
|
||||||
}
|
}
|
||||||
right={
|
right={
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<div className="flex w-full gap-1 items-center justify-start rounded-md px-2 py-1.5 border border-custom-border-300 bg-custom-background-90">
|
||||||
|
<Icon iconName="search" className="!text-xl !leading-5 !text-custom-sidebar-text-400" />
|
||||||
|
<input
|
||||||
|
className="w-full border-none bg-transparent text-xs text-custom-text-200 focus:outline-none"
|
||||||
|
value={query}
|
||||||
|
onChange={(e) => setQuery(e.target.value)}
|
||||||
|
placeholder="Search"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<PrimaryButton
|
<PrimaryButton
|
||||||
className="flex items-center gap-2"
|
className="flex items-center gap-2 flex-shrink-0"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const e = new KeyboardEvent("keydown", { key: "p" });
|
const e = new KeyboardEvent("keydown", { key: "p" });
|
||||||
document.dispatchEvent(e);
|
document.dispatchEvent(e);
|
||||||
@ -63,6 +85,7 @@ const ProjectsPage: NextPage = () => {
|
|||||||
<PlusIcon className="h-4 w-4" />
|
<PlusIcon className="h-4 w-4" />
|
||||||
Add Project
|
Add Project
|
||||||
</PrimaryButton>
|
</PrimaryButton>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<JoinProjectModal
|
<JoinProjectModal
|
||||||
@ -91,12 +114,12 @@ const ProjectsPage: NextPage = () => {
|
|||||||
data={projects?.find((item) => item.id === deleteProject) ?? null}
|
data={projects?.find((item) => item.id === deleteProject) ?? null}
|
||||||
user={user}
|
user={user}
|
||||||
/>
|
/>
|
||||||
{projects ? (
|
{filteredProjectList ? (
|
||||||
<div className="h-full w-full overflow-hidden">
|
<div className="h-full w-full overflow-hidden">
|
||||||
{projects.length > 0 ? (
|
{filteredProjectList.length > 0 ? (
|
||||||
<div className="h-full p-8 overflow-y-auto">
|
<div className="h-full p-8 overflow-y-auto">
|
||||||
<div className="grid grid-cols-1 gap-9 md:grid-cols-2 lg:grid-cols-3">
|
<div className="grid grid-cols-1 gap-9 md:grid-cols-2 lg:grid-cols-3">
|
||||||
{projects.map((project) => (
|
{filteredProjectList.map((project) => (
|
||||||
<SingleProjectCard
|
<SingleProjectCard
|
||||||
key={project.id}
|
key={project.id}
|
||||||
project={project}
|
project={project}
|
||||||
|
Loading…
Reference in New Issue
Block a user