Skip to content

Commit

Permalink
feat: renterd health partial slab
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Aug 21, 2023
1 parent b8a5a3b commit 0ba9281
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-dots-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siafoundation/react-renterd': minor
---

useObject now includes partialSlab.
5 changes: 5 additions & 0 deletions .changeset/wise-phones-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

File health tooltip now includes redundancy info and supports partial slabs.
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,44 @@ export function FilesHealthColumnContents({
'contractSetShards'
)

const { partialSlab } = obj.data.object

return (
<Layout
className={slabs.length > 15 ? 'h-[300px]' : ''}
displayHealth={displayHealth}
label={label}
minShards={partialSlab ? partialSlab.minShards : slabs[0]?.minShards}
totalShards={
partialSlab ? partialSlab.totalShards : slabs[0]?.shards.length
}
>
{slabs.map((slab) => (
<div key={slab.key} className="flex justify-between gap-2">
<Text
size="12"
color="subtle"
className="flex items-center"
font="mono"
>
Slab {slab.key.replace('key:', '').slice(0, 4)}:
</Text>
<Text size="12" className="flex items-center">
{slab.contractSetShards}/{slab.shards.length}
</Text>
</div>
))}
{partialSlab ? (
<Text
size="12"
color="verySubtle"
className="flex items-center justify-center my-2"
font="mono"
>
partial slab
</Text>
) : (
slabs.map((slab) => (
<div key={slab.key} className="flex justify-between gap-2">
<Text
size="12"
color="subtle"
className="flex items-center"
font="mono"
>
Slab {slab.key.replace('key:', '').slice(0, 4)}:
</Text>
<Text size="12" className="flex items-center">
{slab.contractSetShards}/{slab.shards.length}
</Text>
</div>
))
)}
</Layout>
)
}
Expand All @@ -96,11 +113,15 @@ function Layout({
displayHealth,
label,
children,
minShards,
totalShards,
}: {
className?: string
children: React.ReactNode
displayHealth: number
label: string
minShards?: number
totalShards?: number
}) {
return (
<div
Expand All @@ -110,6 +131,16 @@ function Layout({
<Text size="12">{label}</Text>
<Text size="12">{(displayHealth * 100).toFixed(0)}%</Text>
</div>
{minShards && totalShards ? (
<div className="flex justify-between gap-2 pt-0.5 pb-px px-2">
<Text size="12" color="subtle">
redundancy
</Text>
<Text size="12" color="subtle">
{minShards} of {totalShards}
</Text>
</div>
) : null}
<div className="px-2">
<Separator className="w-full my-1" />
</div>
Expand Down
5 changes: 5 additions & 0 deletions libs/react-renterd/src/siaTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ export interface Obj {
health: number
key: EncryptionKey
slabs?: SlabSlice[]
partialSlab?: {
minShards: number
totalShards: number
data?: string
}
}

export interface AddObjectRequest {
Expand Down

0 comments on commit 0ba9281

Please sign in to comment.