Skip to content

Commit

Permalink
fix: renterd health partial slabs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Dec 8, 2023
1 parent 1bd5309 commit c99dcbc
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 46 deletions.
5 changes: 5 additions & 0 deletions .changeset/swift-tools-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siafoundation/react-renterd': minor
---

Updated the object partial slab response structure.
5 changes: 5 additions & 0 deletions .changeset/tender-peaches-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': minor
---

Fixed an issue with the file health popover and updated it to display more accurate information.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function FilesHealthColumnContents({
path,
isUploading,
type,
health: _health,
health,
size,
}: ObjectData) {
const isDirectory = type === 'directory'
Expand All @@ -31,7 +31,7 @@ export function FilesHealthColumnContents({
})

const { displayHealth, label } = useHealthLabel({
health: _health,
health,
size,
isDirectory,
})
Expand All @@ -57,53 +57,43 @@ export function FilesHealthColumnContents({
const slabs = sortBy(
obj.data.object.slabs.map((s) => ({
...s.slab,
contractSetShards: computeSlabContractSetShards({
totalShards: s.slab.shards.length,
minShards: s.slab.minShards,
health: s.slab.health,
}),
isPartialSlab: !!s.slab.shards,
contractSetShards: s.slab.shards?.length
? computeSlabContractSetShards({
totalShards: s.slab.shards.length,
minShards: s.slab.minShards,
health: s.slab.health,
})
: 0,
})),
'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
}
minShards={slabs.find((s) => s.minShards)?.minShards}
totalShards={slabs.find((s) => s.shards)?.shards.length}
>
{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>
))
)}
{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.isPartialSlab
? `${slab.contractSetShards}/${slab.shards.length}`
: 'partial slab'}
</Text>
</div>
))}
</Layout>
)
}
Expand Down
13 changes: 6 additions & 7 deletions libs/react-renterd/src/siaTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export type Slab = {
health: number
key: EncryptionKey
minShards: number
shards: Sector[]
// if no shards, then its a partial slab
shards?: Sector[]
}

export type SlabSlice = {
Expand All @@ -105,12 +106,10 @@ export type Obj = {
size: number
health: number
key: EncryptionKey
slabs?: SlabSlice[]
partialSlab?: {
minShards: number
totalShards: number
data?: string
}
eTag: string
mimeType: string
modTime: string
slabs: SlabSlice[]
}

export type ContractSetSettings = {
Expand Down

0 comments on commit c99dcbc

Please sign in to comment.