Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3e4b678

Browse files
fix: Workspace default filter on search bar (#4111)
1 parent 9196b39 commit 3e4b678

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

site/src/pages/WorkspacesPage/WorkspacesPage.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@ import { workspacesMachine } from "xServices/workspaces/workspacesXService"
88
import { WorkspacesPageView } from "./WorkspacesPageView"
99

1010
const WorkspacesPage: FC = () => {
11-
const [workspacesState, send] = useMachine(workspacesMachine)
1211
const [searchParams, setSearchParams] = useSearchParams()
12+
const filter = searchParams.get("filter")
13+
const defaultFilter = filter ?? workspaceFilterQuery.me
14+
const [workspacesState, send] = useMachine(workspacesMachine, {
15+
context: {
16+
filter: defaultFilter,
17+
},
18+
})
19+
1320
const { workspaceRefs } = workspacesState.context
1421

1522
// On page load, populate the table with workspaces
1623
useEffect(() => {
17-
const filter = searchParams.get("filter")
18-
const query = filter ?? workspaceFilterQuery.me
19-
2024
send({
2125
type: "GET_WORKSPACES",
22-
query,
26+
query: defaultFilter,
2327
})
2428
// eslint-disable-next-line react-hooks/exhaustive-deps
2529
}, [])

site/src/xServices/workspaces/workspacesXService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export type WorkspaceItemMachineRef = ActorRefFrom<typeof workspaceItemMachine>
187187

188188
interface WorkspacesContext {
189189
workspaceRefs?: WorkspaceItemMachineRef[]
190-
filter?: string
190+
filter: string
191191
getWorkspacesError?: Error | unknown
192192
}
193193

0 commit comments

Comments
 (0)