mirror of
https://github.com/supabase/supabase.git
synced 2026-10-14 05:39:11 +03:00
branch stat
This commit is contained in:
1 parent
b4d76322f1
commit
6d1932bfb5
1 file changed
+27
-16
@@ -7,15 +7,19 @@ import { useMigrationsQuery } from 'data/database/migrations-query'
|
||||
import { useBackupsQuery } from 'data/database/backups-query'
|
||||
import { Skeleton } from 'ui'
|
||||
import { ServiceStatus } from './ServiceStatus'
|
||||
import { GitBranch } from 'lucide-react'
|
||||
|
||||
export default function ActivityStats() {
|
||||
export function ActivityStats() {
|
||||
const { data: project } = useSelectedProjectQuery()
|
||||
const { ref } = useParams()
|
||||
|
||||
const { data: branchesData, isLoading: isLoadingBranches } = useBranchesQuery({
|
||||
projectRef: project?.parent_project_ref ?? project?.ref,
|
||||
})
|
||||
const latestBranch = (branchesData ?? [])
|
||||
const isDefaultProject = project?.parent_project_ref === undefined
|
||||
const currentBranch = (branchesData ?? []).find((b) => b.project_ref === ref)
|
||||
const latestNonDefaultBranch = (branchesData ?? [])
|
||||
.filter((b) => !b.is_default)
|
||||
.slice()
|
||||
.sort(
|
||||
(a, b) =>
|
||||
@@ -45,20 +49,6 @@ export default function ActivityStats() {
|
||||
<ServiceStatus />
|
||||
</div>
|
||||
</div>
|
||||
<Link href={`/project/${ref}/branches`} className="block">
|
||||
<h4 className="heading-meta text-foreground-light mb-1">Last branch</h4>
|
||||
<p className="text-foreground">
|
||||
{isLoadingBranches ? (
|
||||
<Skeleton className="h-4 w-16 mt-2" />
|
||||
) : latestBranch?.created_at ? (
|
||||
dayjs(latestBranch.created_at).fromNow()
|
||||
) : latestBranch?.updated_at ? (
|
||||
dayjs(latestBranch.updated_at).fromNow()
|
||||
) : (
|
||||
'No branches'
|
||||
)}
|
||||
</p>
|
||||
</Link>
|
||||
<Link href={`/project/${ref}/database/migrations`} className="block">
|
||||
<p className="heading-meta text-foreground-light mb-1">Last migration</p>
|
||||
<p className="text-foreground">
|
||||
@@ -85,7 +75,28 @@ export default function ActivityStats() {
|
||||
)}
|
||||
</p>
|
||||
</Link>
|
||||
<Link href={`/project/${ref}/branches`} className="block">
|
||||
<h4 className="heading-meta text-foreground-light mb-1">
|
||||
{isDefaultProject ? 'Recent branch' : 'Branch Created'}
|
||||
</h4>
|
||||
<p className="text-foreground">
|
||||
{isLoadingBranches ? (
|
||||
<Skeleton className="h-4 w-24 mt-2" />
|
||||
) : isDefaultProject ? (
|
||||
<div className="flex items-center gap-2">
|
||||
<GitBranch size={16} strokeWidth={1.5} className="text-foreground-muted" />
|
||||
{latestNonDefaultBranch?.name ?? 'No branches'}
|
||||
</div>
|
||||
) : currentBranch?.created_at ? (
|
||||
dayjs(currentBranch.created_at).fromNow()
|
||||
) : (
|
||||
'Unknown'
|
||||
)}
|
||||
</p>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ActivityStats
|
||||
Reference in new issue
Block a user