Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[projects] add missing search filter #5318

Merged
merged 1 commit into from
Aug 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions components/dashboard/src/projects/Projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -30,6 +29,8 @@ export default function () {

const { isDark } = useContext(ThemeContext);

const [searchFilter, setSearchFilter] = useState<string | undefined>();

useEffect(() => {
updateProjects();
}, [ teams ]);
Expand All @@ -55,7 +56,6 @@ export default function () {
}

const newProjectUrl = !!team ? `/new?team=${team.slug}` : '/new';
const onSearchProjects = (searchString: string) => { }
const onNewProject = () => {
history.push(newProjectUrl);
}
Expand All @@ -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 <>
<Header title="Projects" subtitle="Manage recently added projects." />
{projects.length < 1 && (
Expand All @@ -90,23 +97,16 @@ export default function () {
<div className="py-4">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16" width="16" height="16"><path fill="#A8A29E" d="M6 2a4 4 0 100 8 4 4 0 000-8zM0 6a6 6 0 1110.89 3.477l4.817 4.816a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 010 6z" /></svg>
</div>
<input type="search" placeholder="Search Projects" onChange={(e) => onSearchProjects(e.target.value)} />
<input type="search" placeholder="Search Projects" onChange={e => setSearchFilter(e.target.value)} />
AlexTugarev marked this conversation as resolved.
Show resolved Hide resolved
</div>
<div className="flex-1" />
<div className="py-3 pl-3">
<DropDown prefix="Status: " contextMenuWidth="w-32" activeEntry={'Recent'} entries={[{
title: 'Recent',
onClick: () => { /* TODO */ }
}, {
title: 'All',
onClick: () => { /* TODO */ }
}]} />
</div>
<Link to="./members" className="flex"><button className="ml-2 secondary">Invite Members</button></Link>
<button className="ml-2" onClick={() => onNewProject()}>New Project</button>
</div>
<div className="mt-4 grid grid-cols-3 gap-4">
{projects.map(p => (<div key={`project-${p.id}`} className="h-48">
{projects.filter(filter).map(p => (<div key={`project-${p.id}`} className="h-48">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Could we hide the New Project card when there's no search result? Ideally, a minimal empty state like the one in #5022 with a link to create a new project could suffice. Sounds good also as a follow up issue. 🏓

Screenshot 2021-08-23 at 3 34 52 PM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not showing the New Project card on active search sounds great in general.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi: Added follow up issue in #5343.

<div className="h-5/6 border border-gray-200 dark:border-gray-800 rounded-t-xl">
<div className="h-3/4 p-6">
<div className="flex self-center text-base text-gray-900 dark:text-gray-50 font-medium">
Expand Down Expand Up @@ -141,14 +141,16 @@ export default function () {
</div>)}
</div>
</div>))}
<div key="new-project"
className="h-48 border-dashed border-2 border-gray-200 dark:border-gray-800 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-xl focus:bg-gitpod-kumquat-light transition ease-in-out group">
<Link to={newProjectUrl}>
<div className="flex h-full">
<div className="m-auto">New Project</div>
</div>
</Link>
</div>
{!searchFilter && (
<div key="new-project"
className="h-48 border-dashed border-2 border-gray-200 dark:border-gray-800 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-xl focus:bg-gitpod-kumquat-light transition ease-in-out group">
<Link to={newProjectUrl}>
<div className="flex h-full">
<div className="m-auto">New Project</div>
</div>
</Link>
</div>
)}
</div>
</div>
)}
Expand Down