From 5bdda33ea5fbf34e0575774c07bbe1694bf77030 Mon Sep 17 00:00:00 2001 From: Alex Tugarev Date: Mon, 23 Aug 2021 13:31:57 +0000 Subject: [PATCH] [projects] add missing search filter fixes https://github.com/gitpod-io/gitpod/issues/4972 --- .../dashboard/src/projects/Projects.tsx | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/components/dashboard/src/projects/Projects.tsx b/components/dashboard/src/projects/Projects.tsx index f89c6bfb36ab7e..36986f48dd0585 100644 --- a/components/dashboard/src/projects/Projects.tsx +++ b/components/dashboard/src/projects/Projects.tsx @@ -15,7 +15,6 @@ import { getGitpodService } from "../service/service"; import { getCurrentTeam, TeamsContext } from "../teams/teams-context"; import { ThemeContext } from "../theme-context"; import { PrebuildInfo, Project } from "@gitpod/gitpod-protocol"; -import DropDown from "../components/DropDown"; import { toRemoteURL } from "./render-utils"; import ContextMenu from "../components/ContextMenu"; @@ -30,6 +29,8 @@ export default function () { const { isDark } = useContext(ThemeContext); + const [searchFilter, setSearchFilter] = useState(); + useEffect(() => { updateProjects(); }, [ teams ]); @@ -55,7 +56,6 @@ export default function () { } const newProjectUrl = !!team ? `/new?team=${team.slug}` : '/new'; - const onSearchProjects = (searchString: string) => { } const onNewProject = () => { history.push(newProjectUrl); } @@ -69,6 +69,13 @@ export default function () { await updateProjects(); } + const filter = (project: Project) => { + if (searchFilter && `${project.name}`.toLowerCase().includes(searchFilter.toLowerCase()) === false) { + return false; + } + return true; + } + return <>
{projects.length < 1 && ( @@ -90,23 +97,16 @@ export default function () {
- onSearchProjects(e.target.value)} /> + setSearchFilter(e.target.value)} />
- { /* TODO */ } - }, { - title: 'All', - onClick: () => { /* TODO */ } - }]} />
- {projects.map(p => (
+ {projects.filter(filter).map(p => (
@@ -141,14 +141,16 @@ export default function () {
)}
))} -
- -
-
New Project
-
- -
+ {!searchFilter && ( +
+ +
+
New Project
+
+ +
+ )}
)}