Skip to content

Commit 9728631

Browse files
committed
Add filter behind an experiment
1 parent 161a8af commit 9728631

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

site/src/pages/WorkspacesPage/WorkspacesPage.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
useStatusAutocomplete,
1313
} from "./filter/autocompletes"
1414
import { useSearchParams } from "react-router-dom"
15+
import { useDashboard } from "components/Dashboard/DashboardProvider"
1516

1617
const WorkspacesPage: FC = () => {
1718
const orgId = useOrganizationId()
@@ -47,6 +48,7 @@ const WorkspacesPage: FC = () => {
4748
filter.values.status,
4849
(option) => filter.update({ ...filter.values, status: option?.value }),
4950
)
51+
const dashboard = useDashboard()
5052

5153
return (
5254
<>
@@ -55,6 +57,7 @@ const WorkspacesPage: FC = () => {
5557
</Helmet>
5658

5759
<WorkspacesPageView
60+
useNewFilter={dashboard.experiments.includes("workspace_filter")}
5861
workspaces={data?.workspaces}
5962
error={error}
6063
count={data?.count}

site/src/pages/WorkspacesPage/WorkspacesPageView.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { ImpendingDeletionBanner, Count } from "components/WorkspaceDeletion"
1919
import { ErrorAlert } from "components/Alert/ErrorAlert"
2020
import { Filter } from "./filter/filter"
2121
import { hasError, isApiValidationError } from "api/errors"
22+
import { workspaceFilterQuery } from "utils/filters"
23+
import { SearchBarWithFilter } from "components/SearchBarWithFilter/SearchBarWithFilter"
2224

2325
export const Language = {
2426
pageTitle: "Workspaces",
@@ -29,10 +31,24 @@ export const Language = {
2931
template: "Template",
3032
}
3133

34+
const presetFilters = [
35+
{ query: workspaceFilterQuery.me, name: Language.yourWorkspacesButton },
36+
{ query: workspaceFilterQuery.all, name: Language.allWorkspacesButton },
37+
{
38+
query: workspaceFilterQuery.running,
39+
name: Language.runningWorkspacesButton,
40+
},
41+
{
42+
query: workspaceFilterQuery.failed,
43+
name: "Failed workspaces",
44+
},
45+
]
46+
3247
export interface WorkspacesPageViewProps {
3348
error: unknown
3449
workspaces?: Workspace[]
3550
count?: number
51+
useNewFilter?: boolean
3652
page: number
3753
limit: number
3854
filterProps: ComponentProps<typeof Filter>
@@ -45,12 +61,13 @@ export const WorkspacesPageView: FC<
4561
> = ({
4662
workspaces,
4763
error,
48-
page,
4964
limit,
5065
count,
5166
filterProps,
5267
onPageChange,
5368
onUpdateWorkspace,
69+
useNewFilter,
70+
page,
5471
}) => {
5572
const { saveLocal, getLocal } = useLocalStorage()
5673

@@ -115,7 +132,16 @@ export const WorkspacesPageView: FC<
115132
count={Count.Multiple}
116133
/>
117134

118-
<Filter error={error} {...filterProps} />
135+
{useNewFilter ? (
136+
<Filter error={error} {...filterProps} />
137+
) : (
138+
<SearchBarWithFilter
139+
filter={filterProps.filter.query}
140+
onFilter={filterProps.filter.debounceUpdate}
141+
presetFilters={presetFilters}
142+
error={error}
143+
/>
144+
)}
119145
</Stack>
120146
<WorkspacesTable
121147
workspaces={workspaces}

site/yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@
10831083
resolved "https://registry.yarnpkg.com/@emoji-mart/react/-/react-1.0.1.tgz#46b6a2e92faf16fa9b7f9471f137fa2e3d1e8ac3"
10841084
integrity sha512-ALhLD96BOL5w+a4NI5NpmfqfF1aVjjj2qJE0dLst/OhjBfVmpteWNgn/h8LZy9ulU6AnbeS+13KnPFzDjCvRRw==
10851085

1086-
"@emotion/babel-plugin@^11.10.8":
1086+
"@emotion/babel-plugin@^11.10.8", "@emotion/babel-plugin@^11.11.0":
10871087
version "11.11.0"
10881088
resolved "https://registry.yarnpkg.com/@emotion/babel-plugin/-/babel-plugin-11.11.0.tgz#c2d872b6a7767a9d176d007f5b31f7d504bb5d6c"
10891089
integrity sha512-m4HEDZleaaCH+XgDDsPF15Ht6wTLsgDTeR3WYj9Q/k76JtWhrJjcP4+/XlG8LGT/Rol9qUfOIztXeA84ATpqPQ==
@@ -1121,7 +1121,7 @@
11211121
resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.9.1.tgz#4ffb0055f7ef676ebc3a5a91fb621393294e2f43"
11221122
integrity sha512-gJB6HLm5rYwSLI6PQa+X1t5CFGrv1J1TWG+sOyMCeKz2ojaj6Fnl/rZEspogG+cvqbt4AE/2eIyD2QfLKTBNlQ==
11231123

1124-
"@emotion/is-prop-valid@^1.2.0":
1124+
"@emotion/is-prop-valid@^1.2.0", "@emotion/is-prop-valid@^1.2.1":
11251125
version "1.2.1"
11261126
resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-1.2.1.tgz#23116cf1ed18bfeac910ec6436561ecb1a3885cc"
11271127
integrity sha512-61Mf7Ufx4aDxx1xlDeOm8aFFigGHE4z+0sKCa+IHCeZKiyP9RLD0Mmx7m8b9/Cf37f7NAvQOOJAbQQGVr5uERw==
@@ -1185,7 +1185,7 @@
11851185
resolved "https://registry.yarnpkg.com/@emotion/unitless/-/unitless-0.8.1.tgz#182b5a4704ef8ad91bde93f7a860a88fd92c79a3"
11861186
integrity sha512-KOEGMu6dmJZtpadb476IsZBclKvILjopjUii3V+7MnXIQCYh8W3NgNcgwo21n9LXZX6EDIKvqfjYxXebDwxKmQ==
11871187

1188-
"@emotion/use-insertion-effect-with-fallbacks@^1.0.0":
1188+
"@emotion/use-insertion-effect-with-fallbacks@^1.0.0", "@emotion/use-insertion-effect-with-fallbacks@^1.0.1":
11891189
version "1.0.1"
11901190
resolved "https://registry.yarnpkg.com/@emotion/use-insertion-effect-with-fallbacks/-/use-insertion-effect-with-fallbacks-1.0.1.tgz#08de79f54eb3406f9daaf77c76e35313da963963"
11911191
integrity sha512-jT/qyKZ9rzLErtrjGgdkMBn2OP8wl0G3sQlBb3YPryvKHsjvINUhVaPFfP+fpBcOkmrVOVEEHQFJ7nbj2TH2gw==

0 commit comments

Comments
 (0)