From bdbc4d58823258b513262bdb15b96d5b737c2f3c Mon Sep 17 00:00:00 2001 From: Alex Freska Date: Fri, 21 Jun 2024 15:52:15 -0400 Subject: [PATCH] fix: renterd slab alert health and objects --- .changeset/brave-rivers-cry.md | 5 + .../Files/FileContextMenu/index.tsx | 14 ++- apps/renterd/contexts/alerts/data.tsx | 114 +++++++++++++----- 3 files changed, 95 insertions(+), 38 deletions(-) create mode 100644 .changeset/brave-rivers-cry.md diff --git a/.changeset/brave-rivers-cry.md b/.changeset/brave-rivers-cry.md new file mode 100644 index 000000000..ce9cb4faa --- /dev/null +++ b/.changeset/brave-rivers-cry.md @@ -0,0 +1,5 @@ +--- +'renterd': minor +--- + +The slab migration failed alert now shows health and an object IDs list that includes the file context menu for each object. Closes https://github.com/SiaFoundation/renterd/issues/1322 diff --git a/apps/renterd/components/Files/FileContextMenu/index.tsx b/apps/renterd/components/Files/FileContextMenu/index.tsx index c4e91244c..9d979f5cf 100644 --- a/apps/renterd/components/Files/FileContextMenu/index.tsx +++ b/apps/renterd/components/Files/FileContextMenu/index.tsx @@ -25,9 +25,11 @@ import { useFilesManager } from '../../../contexts/filesManager' type Props = { path: string + trigger?: React.ReactNode + contentProps?: React.ComponentProps['contentProps'] } -export function FileContextMenu({ path }: Props) { +export function FileContextMenu({ trigger, path, contentProps }: Props) { const { downloadFiles, getFileUrl, navigateToModeSpecificFiltering } = useFilesManager() const deleteFile = useFileDelete() @@ -36,11 +38,13 @@ export function FileContextMenu({ path }: Props) { return ( - - + trigger || ( + + ) } - contentProps={{ align: 'start' }} + contentProps={{ align: 'start', ...contentProps }} > Actions + + slab key + + + + ) + }, + }, + health: { + render: function OriginField({ value }: { value: string }) { + return ( +
+ + health + + + {value} + +
+ ) + }, + }, + objectIDs: { + render: function ObjectIdsField({ + value, + }: { + value: Record + }) { const { setActiveDirectory } = useFilesManager() const { closeDialog } = useDialog() - const objects = useSlabObjects({ - params: { - key: value, - }, - config: { - swr: { - revalidateOnFocus: false, - }, - }, - }) return (
- slab key + object IDs -
- {!!objects.data?.length && ( +
-
- {objects.data.map((o) => ( - { - setActiveDirectory(() => - getDirectorySegmentsFromPath(o.name) - ) - closeDialog() - }} - > - {o.name} - - ))} +
+ {Object.entries(value).map(([bucket, paths]) => + paths.map((path) => { + const fullPath = `${bucket}${path}` + return ( +
+ { + setActiveDirectory(() => + getDirectorySegmentsFromPath(fullPath) + ) + closeDialog() + }} + > + {fullPath} + + + + + } + /> +
+ ) + }) + )}
- )} +
) },