From a8f193cc3ce2abe38716cda57876e01bbdefca95 Mon Sep 17 00:00:00 2001 From: Terry Sutton Date: Fri, 25 Apr 2025 08:56:12 -0230 Subject: [PATCH] Fix storage explorer footer (#35036) * Fix storage explorer footer * Fix --------- Co-authored-by: Joshen Lim --- .../Storage/StorageExplorer/FileExplorer.tsx | 8 +- .../StorageExplorer/FileExplorerColumn.tsx | 236 +++++++++--------- .../StorageExplorer/StorageExplorer.tsx | 2 +- 3 files changed, 119 insertions(+), 127 deletions(-) diff --git a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorer.tsx b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorer.tsx index a99314b9b69..9d6612288a4 100644 --- a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorer.tsx +++ b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorer.tsx @@ -1,7 +1,8 @@ +import { noop } from 'lodash' import { observer } from 'mobx-react-lite' import { useEffect, useRef } from 'react' -import { noop } from 'lodash' +import { cn } from 'ui' import { CONTEXT_MENU_KEYS, STORAGE_VIEWS } from '../Storage.constants' import type { StorageColumn, StorageItem, StorageItemWithColumn } from '../Storage.types' import ColumnContextMenu from './ColumnContextMenu' @@ -46,7 +47,10 @@ const FileExplorer = ({ return (
diff --git a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.tsx b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.tsx index 3bb49eb2f85..95ccbb7455f 100644 --- a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.tsx +++ b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.tsx @@ -1,15 +1,15 @@ import { Transition } from '@headlessui/react' import { get, noop, sum } from 'lodash' +import { Upload } from 'lucide-react' import { useEffect, useRef, useState } from 'react' import { useContextMenu } from 'react-contexify' -import { Checkbox } from 'ui' import InfiniteList from 'components/ui/InfiniteList' import ShimmeringLoader from 'components/ui/ShimmeringLoader' import { BASE_PATH } from 'lib/constants' import { formatBytes } from 'lib/helpers' -import { Upload } from 'lucide-react' import { useStorageExplorerStateSnapshot } from 'state/storage-explorer' +import { Checkbox, cn } from 'ui' import { CONTEXT_MENU_KEYS, STORAGE_ROW_STATUS, @@ -142,145 +142,133 @@ const FileExplorerColumn = ({ ) return ( - <> -
{ - const eventTarget = get(event.target, ['className'], '') - if (typeof eventTarget === 'string' && eventTarget.includes('react-contexify')) return - onSelectColumnEmptySpace(index) - }} - > - {/* Checkbox selection for select all */} - {view === STORAGE_VIEWS.COLUMNS && ( -
event.stopPropagation()} - > - {columnFiles.length > 0 ? ( - <> - -

- Select all {columnFiles.length} files -

- - ) : ( -

No files available for selection

- )} -
- )} - - {/* List Interface Header */} - {view === STORAGE_VIEWS.LIST && ( -
-
+
{ + const eventTarget = get(event.target, ['className'], '') + if (typeof eventTarget === 'string' && eventTarget.includes('react-contexify')) return + onSelectColumnEmptySpace(index) + }} + > + {/* Checkbox selection for select all */} + {view === STORAGE_VIEWS.COLUMNS && ( +
event.stopPropagation()} + > + {columnFiles.length > 0 ? ( + <> -

Name

-
-

Size

-

Type

-

Created at

-

Last modified at

-
- )} +

Select all {columnFiles.length} files

+ + ) : ( +

No files available for selection

+ )} +
+ )} - {/* Shimmering loaders while fetching contents */} - {column.status === STORAGE_ROW_STATUS.LOADING && ( -
+
+ +

Name

+
+

Size

+

Type

+

Created at

+

Last modified at

+
+ )} + + {/* Shimmering loaders while fetching contents */} + {column.status === STORAGE_ROW_STATUS.LOADING && ( +
- - - + > + + + +
+ )} + + {/* Column Interface */} + (index !== 0 && index === columnItems.length ? 85 : 37)} + hasNextPage={column.status !== STORAGE_ROW_STATUS.LOADING && column.hasMoreItems} + isLoadingNextPage={column.isLoadingMoreItems} + onLoadNextPage={() => onColumnLoadMore(index, column)} + /> + + {/* Drag drop upload CTA for when column is empty */} + {!(snap.isSearching && itemSearchString.length > 0) && + column.items.length === 0 && + column.status !== STORAGE_ROW_STATUS.LOADING && ( +
+ storage-placeholder +

Drop your files here

+

+ Or upload them via the "Upload file" button above +

)} - {/* Column Interface */} - (index !== 0 && index === columnItems.length ? 85 : 37)} - hasNextPage={column.status !== STORAGE_ROW_STATUS.LOADING && column.hasMoreItems} - isLoadingNextPage={column.isLoadingMoreItems} - onLoadNextPage={() => onColumnLoadMore(index, column)} - /> + {snap.isSearching && + itemSearchString.length > 0 && + isEmpty && + column.status !== STORAGE_ROW_STATUS.LOADING && ( +
+

No results found in this folder

+

+ Your search for "{itemSearchString}" did not return any results +

+
+ )} - {/* Drag drop upload CTA for when column is empty */} - {!(snap.isSearching && itemSearchString.length > 0) && - column.items.length === 0 && - column.status !== STORAGE_ROW_STATUS.LOADING && ( -
- storage-placeholder -

Drop your files here

-

- Or upload them via the "Upload file" button above -

-
- )} + {/* Drag drop upload CTA for when column has files */} + setIsDraggedOver(false)} + onDrop={() => setIsDraggedOver(false)} + /> - {snap.isSearching && - itemSearchString.length > 0 && - isEmpty && - column.status !== STORAGE_ROW_STATUS.LOADING && ( -
-

No results found in this folder

-

- Your search for "{itemSearchString}" did not return any results -

-
- )} - - {/* Drag drop upload CTA for when column has files */} - setIsDraggedOver(false)} - onDrop={() => setIsDraggedOver(false)} - /> -
{/* List interface footer */} {view === STORAGE_VIEWS.LIST && ( -
+

{formatBytes(columnItemsSize)} for {columnItems.length} items

)} - +
) } diff --git a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.tsx b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.tsx index e55cb48a772..bc34848e6eb 100644 --- a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.tsx +++ b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.tsx @@ -1,8 +1,8 @@ -import { useParams } from 'common' import { compact, get, isEmpty, uniqBy } from 'lodash' import { observer } from 'mobx-react-lite' import { useEffect, useRef, useState } from 'react' +import { useParams } from 'common' import { useProjectStorageConfigQuery } from 'data/config/project-storage-config-query' import type { Bucket } from 'data/storage/buckets-query' import { IS_PLATFORM } from 'lib/constants'