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

feat(platform): Add loading skeleton in the secrets page #423

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
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
34 changes: 34 additions & 0 deletions apps/platform/src/app/(main)/project/[project]/@secret/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ import {
TooltipProvider,
TooltipTrigger
} from '@/components/ui/tooltip'
import { Skeleton } from '@/components/ui/skeleton'

extend(relativeTime)

function SecretPage(): React.JSX.Element {
const [allSecrets, setAllSecrets] = useState<Secret[]>()
const [isLoading, setIsLoading] = useState<boolean>(true)
const pathname = usePathname()

useEffect(() => {
setIsLoading(true)
Secrets.getAllSecretbyProjectId(pathname.split('/')[2])
.then((data) => {
setAllSecrets(data)
Expand All @@ -44,8 +47,21 @@ function SecretPage(): React.JSX.Element {
// eslint-disable-next-line no-console -- we need to log the error
console.error(error)
})
.finally(() => {
setIsLoading(false)
})
}, [pathname])

if (isLoading) {
return (
<div className="space-y-4">
<SerectLoader />
<SerectLoader />
<SerectLoader />
</div>
)
}

return (
<ScrollArea className=" mb-4 h-[50rem]">
<Accordion
Expand Down Expand Up @@ -120,4 +136,22 @@ function SecretPage(): React.JSX.Element {
)
}

function SerectLoader(): React.JSX.Element {
return (
<div className=" rounded-xl bg-white/5 p-4">
<div className="flex justify-between">
<div className="flex items-center gap-x-6">
<Skeleton className=" h-6 w-32 rounded" />
<Skeleton className=" size-6 rounded" />
</div>
<div className="flex items-center gap-x-3">
<Skeleton className=" h-6 w-24 rounded" />
<Skeleton className=" h-6 w-16 rounded" />
<Skeleton className=" ml-5 size-4 rounded" />
</div>
</div>
</div>
)
}

export default SecretPage
18 changes: 18 additions & 0 deletions apps/platform/src/components/ui/skeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { cn } from '@/lib/utils'

function Skeleton({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element {
return (
<div
className={cn(
'animate-pulse rounded-md bg-white/20 dark:bg-zinc-800',
className
)}
{...props}
/>
)
}

export { Skeleton }