Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/workspaces/WorkspacesSearchBar.tsx
2500 views
1
/**
2
* Copyright (c) 2023 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
import { FunctionComponent } from "react";
8
import { StartWorkspaceModalKeyBinding } from "../App";
9
import DropDown from "../components/DropDown";
10
import search from "../icons/search.svg";
11
import { LinkButton } from "@podkit/buttons/LinkButton";
12
import { useInstallationConfiguration } from "../data/installation/installation-config-query";
13
14
type WorkspacesSearchBarProps = {
15
searchTerm: string;
16
limit: number;
17
onSearchTermUpdated(s: string): void;
18
onLimitUpdated(limit: number): void;
19
};
20
21
export const WorkspacesSearchBar: FunctionComponent<WorkspacesSearchBarProps> = ({
22
searchTerm,
23
limit,
24
onSearchTermUpdated,
25
onLimitUpdated,
26
}) => {
27
const { data: installationConfig } = useInstallationConfiguration();
28
const isDedicatedInstallation = !!installationConfig?.isDedicatedInstallation;
29
30
return (
31
<div className={!isDedicatedInstallation ? "app-container xl:!pr-4 py-5 flex" : "py-5 flex"}>
32
<div className="flex relative h-10 my-auto">
33
<img src={search} title="Search" className="filter-grayscale absolute top-3 left-3" alt="search icon" />
34
<input
35
type="search"
36
className="w-64 pl-9 border-0"
37
placeholder="Filter Workspaces"
38
value={searchTerm}
39
onChange={(v) => {
40
onSearchTermUpdated(v.target.value);
41
}}
42
/>
43
</div>
44
<div className="flex-1" />
45
<div className="py-2"></div>
46
<div className="py-2 pl-3">
47
<DropDown
48
prefix="Limit: "
49
customClasses="w-32"
50
activeEntry={`${limit}`}
51
entries={[
52
{
53
title: "50",
54
onClick: () => {
55
onLimitUpdated(50);
56
},
57
},
58
{
59
title: "100",
60
onClick: () => {
61
onLimitUpdated(100);
62
},
63
},
64
{
65
title: "200",
66
onClick: () => {
67
onLimitUpdated(200);
68
},
69
},
70
]}
71
/>
72
</div>
73
<LinkButton href={"/new"} className="ml-2 gap-1.5 h-10">
74
New Workspace <span className="opacity-60 hidden md:inline">{StartWorkspaceModalKeyBinding}</span>
75
</LinkButton>
76
</div>
77
);
78
};
79
80