Skip to content

refactor(site): Improve workspaces filtering #7681

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

Merged
merged 25 commits into from
May 30, 2023
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Add skeleton to the filter
  • Loading branch information
BrunoQuaresma committed May 24, 2023
commit d9858f59fa3ada50209f779ac96d243c860c43a7
30 changes: 30 additions & 0 deletions site/src/pages/WorkspacesPage/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import MenuList from "@mui/material/MenuList"
import { useSearchParams } from "react-router-dom"
import { useQuery } from "@tanstack/react-query"
import { getUsers, getTemplates } from "api/api"
import Skeleton, { SkeletonProps } from "@mui/material/Skeleton"

/** Filter */

Expand Down Expand Up @@ -258,6 +259,20 @@ type StatusAutocomplete = ReturnType<typeof useStatusAutocomplete>

/** Components */

const FilterSkeleton = (props: SkeletonProps) => {
return (
<Skeleton
variant="rectangular"
height={36}
{...props}
sx={{
bgcolor: (theme) => theme.palette.background.paperLight,
borderRadius: "6px",
}}
/>
)
}

export const Filter = ({
filter,
autocomplete,
Expand All @@ -270,6 +285,21 @@ export const Filter = ({
}
}) => {
const hasFilterQuery = filter.query !== ""
const isIinitializingFilters =
autocomplete.status.isInitializing ||
autocomplete.templates.isInitializing ||
autocomplete.users.isInitializing

if (isIinitializingFilters) {
return (
<Box display="flex" sx={{ gap: 1, mb: 2 }}>
<FilterSkeleton width="100%" />
<FilterSkeleton width={120} />
<FilterSkeleton width={120} />
<FilterSkeleton width={120} />
</Box>
)
}

return (
<Box display="flex" sx={{ gap: 1, mb: 2 }}>
Expand Down