Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fix rendering of explorer row when name is very long

Joshen Lim2a556ade4fe2
diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.js b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.js
index e9fe16f01b3..8972c794999 100644
--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.js
+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.js
@@ -121,6 +121,7 @@ const FileExplorerColumn = ({
const SelectAllCheckbox = () => (
<Checkbox
label=""
+ className="-mt-0.5"
checked={columnFiles.length !== 0 && selectedFilesFromColumn.length === columnFiles.length}
disabled={columnFiles.length === 0}
onChange={() => onSelectAllItemsInColumn(index)}
@@ -176,23 +177,14 @@ const FileExplorerColumn = ({
border-b border-panel-border-light dark:border-panel-border-dark
"
>
- <SelectAllCheckbox />
- <p className="text-sm" style={{ width: '33%', minWidth: '250px' }}>
- Name
- </p>
- <p className="text-sm" style={{ width: '12%', minWidth: '100px' }}>
- Size
- </p>
- <p className="text-sm" style={{ width: '15%', minWidth: '100px' }}>
- Type
- </p>
- <p className="text-sm" style={{ width: '20%', minWidth: '180px' }}>
- Created at
- </p>
- <p className="text-sm" style={{ width: '20%', minWidth: '180px' }}>
- Last modified at
- </p>
- <div className="w-3" />
+ <div className="flex items-center w-[40%] min-w-[250px]">
+ <SelectAllCheckbox />
+ <p className="text-sm">Name</p>
+ </div>
+ <p className="text-sm w-[11%] min-w-[100px]">Size</p>
+ <p className="text-sm w-[14%] min-w-[100px]">Type</p>
+ <p className="text-sm w-[15%] min-w-[160px]">Created at</p>
+ <p className="text-sm w-[15%] min-w-[160px]">Last modified at</p>
</div>
)}
diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.js b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.js
index 0417e89ff88..3deedb6faa9 100644
--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.js
+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRow.js
@@ -17,6 +17,7 @@ import {
IconMove,
} from '@supabase/ui'
import SVG from 'react-inlinesvg'
+import * as Tooltip from '@radix-ui/react-tooltip'
import { useContextMenu } from 'react-contexify'
import {
STORAGE_VIEWS,
@@ -198,9 +199,16 @@ const FileExplorerRow = ({
})
}
+ const nameWidth =
+ view === STORAGE_VIEWS.LIST && item.isCorrupted
+ ? `calc(100% - 60px)`
+ : view === STORAGE_VIEWS.LIST && !item.isCorrupted
+ ? `calc(100% - 50px)`
+ : '100%'
+
return (
<div
- className="border-b dark:border-dark"
+ className="border-b dark:border-dark h-full"
onContextMenu={(event) => {
event.stopPropagation()
item.type === STORAGE_ROW_TYPES.FILE
@@ -210,16 +218,28 @@ const FileExplorerRow = ({
>
<div
className={[
- 'storage-row px-2.5 flex items-center justify-between group',
+ 'storage-row px-2.5 flex items-center group h-full',
'hover:bg-panel-footer-light dark:hover:bg-panel-footer-dark',
`${isOpened ? 'bg-scale-400' : ''}`,
`${isPreviewed ? 'bg-green-500 hover:bg-green-500 dark:hover:bg-green-500' : ''}`,
- `${view === STORAGE_VIEWS.LIST ? 'min-w-min' : ''}`,
`${item.status !== STORAGE_ROW_STATUS.LOADING ? 'cursor-pointer' : ''}`,
].join(' ')}
+ onClick={(event) => {
+ event.stopPropagation()
+ event.preventDefault()
+ if (item.status !== STORAGE_ROW_STATUS.LOADING && !isOpened && !isPreviewed) {
+ item.type === STORAGE_ROW_TYPES.FOLDER || item.type === STORAGE_ROW_TYPES.BUCKET
+ ? onSelectFolder(columnIndex, item)
+ : onSelectFile(columnIndex, item)
+ }
+ }}
>
- <div className="w-full flex flex-grow items-center">
- {/* Row Checkbox / Row Icon */}
+ <div
+ className={[
+ 'flex items-center',
+ view === STORAGE_VIEWS.LIST ? 'w-[40%] min-w-[250px]' : 'w-[90%]',
+ ].join(' ')}
+ >
<div className="relative w-[30px]" onClick={(event) => event.stopPropagation()}>
{!isSelected && (
<div
@@ -242,42 +262,51 @@ const FileExplorerRow = ({
isSelected ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'
}`}
checked={isSelected}
- onChange={() => onCheckItem(itemWithColumnIndex)}
+ onChange={(event) => {
+ event.stopPropagation()
+ onCheckItem(itemWithColumnIndex)
+ }}
/>
</div>
+ <p title={item.name} className="text-sm truncate" style={{ width: nameWidth }}>
+ {item.name}
+ </p>
+ {item.isCorrupted && (
+ <Tooltip.Root delayDuration={0}>
+ <Tooltip.Trigger>
+ <IconAlertCircle size={18} strokeWidth={2} className="text-scale-1000" />
+ </Tooltip.Trigger>
+ <Tooltip.Content side="bottom">
+ <Tooltip.Arrow className="radix-tooltip-arrow" />
+ <div
+ className={[
+ 'bg-scale-100 rounded py-1 px-2 leading-none shadow',
+ 'border-scale-200 border',
+ ].join(' ')}
+ >
+ <span className="text-scale-1200 text-xs">
+ File is corrupted, please delete and reupload again.
+ </span>
+ </div>
+ </Tooltip.Content>
+ </Tooltip.Root>
+ )}
+ </div>
- {/* Row Text */}
- <div
- className="flex items-center h-full py-2 flex-grow"
- style={{ width: view === STORAGE_VIEWS.COLUMNS ? '80%' : '100%' }}
- onClick={(event) => {
- event.stopPropagation()
- event.preventDefault()
- if (item.status !== STORAGE_ROW_STATUS.LOADING && !isOpened && !isPreviewed) {
- item.type === STORAGE_ROW_TYPES.FOLDER || item.type === STORAGE_ROW_TYPES.BUCKET
- ? onSelectFolder(columnIndex, item)
- : onSelectFile(columnIndex, item)
- }
- }}
- >
- {view === STORAGE_VIEWS.COLUMNS ? (
- <div className="flex items-center space-x-1 w-full">
- <p className="text-sm w-full truncate">{item.name}</p>
- {item.isCorrupted && (
- <IconAlertCircle size={18} strokeWidth={2} className="text-scale-1000" />
- )}
- </div>
- ) : (
- <>
- <p className="text-sm truncate w-[33%] min-w-[250px]">{item.name}</p>
- <p className="text-sm truncate w-[12%] min-w-[100px]">{size}</p>
- <p className="text-sm truncate w-[15%] min-w-[100px]">{mimeType}</p>
- <p className="text-sm truncate w-[20%] min-w-[180px]">{createdAt}</p>
- <p className="text-sm truncate w-[20%] min-w-[175px]">{updatedAt}</p>
- {/* The 175px here is intentional due to the irregular width of the header checkbox and row icon */}
- </>
- )}
- </div>
+ {view === STORAGE_VIEWS.LIST && (
+ <>
+ <p className="text-sm truncate w-[11%] min-w-[100px]">{size}</p>
+ <p className="text-sm truncate w-[14%] min-w-[100px]">{mimeType}</p>
+ <p className="text-sm truncate w-[15%] min-w-[160px]">{createdAt}</p>
+ <p className="text-sm truncate w-[15%] min-w-[160px]">{updatedAt}</p>
+ </>
+ )}
+
+ <div
+ className={`flex items-center justify-end ${
+ view === STORAGE_VIEWS.LIST ? 'flex-grow' : 'w-[10%]'
+ }`}
+ >
{item.status === STORAGE_ROW_STATUS.LOADING ? (
<IconLoader
className={`animate-spin ${view === STORAGE_VIEWS.LIST ? 'invisible' : ''}`}