The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Revert "implement infinite scrolling for search functionality"
Beng Eu0f1a1c58408e
diff --git a/studio/components/to-be-cleaned/Storage/README.md b/studio/components/to-be-cleaned/Storage/README.mddeleted file mode 100644index a3b03939136..00000000000--- a/studio/components/to-be-cleaned/Storage/README.md+++ /dev/null@@ -1,6 +0,0 @@-## What to clean for Storage--- Convert files from javascript to typescript-- Not use mobx store for UI related states, these could simply be done via react's useState or useReducer- - Involves some heavy surgery nonetheless as 90% of the explorer logic is written a mobx store StorageExplorerStore- - If anyone is able to get to it before I do, please feel free to take this on and perhaps even write it more simply 🙏diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorer.js b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorer.jsindex 3123b00ef11..6e2d898a22b 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorer.js+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorer.js@@ -12,6 +12,8 @@ const FileExplorer = ({openedFolders = [],selectedItems = [],selectedFilePreview = {},+ isSearching = false,+ itemSearchString = '',onCheckItem = () => {},onSelectItemDelete = () => {},onSelectItemRename = () => {},@@ -106,6 +108,8 @@ const FileExplorer = ({column={columns[columns.length - 1]}selectedItems={selectedItems}selectedFilePreview={selectedFilePreview}+ isSearching={isSearching}+ itemSearchString={itemSearchString}onCheckItem={onCheckItem}onSelectFile={onSelectFile}onRenameFile={onRenameFile}diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.js b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.jsindex 727e53c17a4..d3477176aa9 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.js+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerColumn.js@@ -56,6 +56,8 @@ const FileExplorerColumn = ({openedFolders = [],selectedItems = [],selectedFilePreview = {},+ isSearching = false,+ itemSearchString = '',onCheckItem = () => {},onSelectItemDelete = () => {},onSelectItemRename = () => {},@@ -92,7 +94,12 @@ const FileExplorerColumn = ({(item) => item.type === STORAGE_ROW_TYPES.FILE)- const columnItems = column.items+ const columnItems = isSearching+ ? column.items.filter((item) =>+ item.name.toLowerCase().includes(itemSearchString.toLowerCase())+ )+ : column.items+const columnItemsSize = sum(columnItems.map((item) => get(item, ['metadata', 'size'], 0)))const { show } = useContextMenu()@@ -201,7 +208,8 @@ const FileExplorerColumn = ({<divclassName={`${fullWidth ? 'w-full' : 'w-64 border-r border-gray-500'}- flex-shrink-0 overflow-auto flex flex-col space-y-1 my-1+ ${view === STORAGE_VIEWS.COLUMNS ? 'my-1' : 'mb-1'}+ flex-shrink-0 overflow-auto flex flex-col space-y-1`}><ShimmeringLoader />@@ -238,6 +246,11 @@ const FileExplorerColumn = ({onLoadNextPage={() => onColumnLoadMore(index, column)}/>+ {/* Search empty state */}+ {isSearching && columnItems.length === 0 && column.items.length > 0 && (+ <div className="text-sm mx-3 my-2 opacity-50">No results found based on your search</div>+ )}+{/* Drag drop upload CTA for when column is empty */}{column.items.length === 0 && column.status !== STORAGE_ROW_STATUS.LOADING && (<div className="h-full w-full flex flex-col items-center justify-center">diff --git a/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.js b/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.jsindex 0e5a662ff48..0360e7cdd89 100644--- a/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.js+++ b/studio/components/to-be-cleaned/Storage/StorageExplorer/StorageExplorer.js@@ -1,4 +1,4 @@-import { useEffect, useState, useRef } from 'react'+import { FC, useEffect, useState, useRef } from 'react'import { observer } from 'mobx-react-lite'import { compact, find, isEmpty, uniqBy, get } from 'lodash'@@ -67,28 +67,16 @@ const StorageExplorer = observer(({ bucket }) => {// I'm keeping them outside of the mobx store as I feel that the store should contain persistent data// Things like showing results from a search filter is "temporary", hence we use react state to manageconst [isSearching, setIsSearching] = useState(false)++ // [TODO JOSHEN FOR INFINITE SCROLLING]+ // Probably need a useEffect for this to use fetchFolderContents and fetchMoreFolderContents in store+ // instead of doing a client side filtering in FileExplorerColumn, pending Alaister to update js libraryconst [itemSearchString, setItemSearchString] = useState('')const previewPaneWidth = 450// Requires a fixed height to ensure that explorer is constrained to the viewportconst fileExplorerHeight = window.innerHeight - 122- useEffect(async () => {- const currentFolderIdx = openedFolders.length - 1- const currentFolder = openedFolders[currentFolderIdx]-- if (itemSearchString) {- await fetchFolderContents(- currentFolder.id,- currentFolder.name,- currentFolderIdx,- itemSearchString- )- } else if (currentFolder) {- await fetchFolderContents(currentFolder.id, currentFolder.name, currentFolderIdx)- }- }, [itemSearchString])-useEffect(() => {// Load user preferences (view and sort)loadExplorerPreferences()@@ -260,9 +248,7 @@ const StorageExplorer = observer(({ bucket }) => {const onToggleSearch = (bool) => {setIsSearching(bool)- if (bool === false) {- setItemSearchString('')- }+ if (bool === false) setItemSearchString('')}return (@@ -308,6 +294,8 @@ const StorageExplorer = observer(({ bucket }) => {openedFolders={openedFolders}selectedItems={selectedItems}selectedFilePreview={selectedFilePreview}+ isSearching={isSearching}+ itemSearchString={itemSearchString}onCheckItem={onCheckItem}onSelectFile={onSelectFile}onRenameFile={onRenameFile}@@ -325,9 +313,7 @@ const StorageExplorer = observer(({ bucket }) => {onSelectCreateFolder={onSelectCreateFolder}onChangeView={onChangeView}onChangeSortBy={onChangeSortBy}- onColumnLoadMore={(index, column) =>- fetchMoreFolderContents(index, column, itemSearchString)- }+ onColumnLoadMore={fetchMoreFolderContents}/><PreviewPaneisOpen={!isEmpty(selectedFilePreview)}diff --git a/studio/localStores/storageExplorer/StorageExplorerStore.js b/studio/localStores/storageExplorer/StorageExplorerStore.jsindex 3eb66d6d031..9acb2433b8e 100644--- a/studio/localStores/storageExplorer/StorageExplorerStore.js+++ b/studio/localStores/storageExplorer/StorageExplorerStore.js@@ -924,29 +924,28 @@ class StorageExplorerStore {/* Folders CRUD */- fetchFolderContents = async (folderId, folderName, index, searchString = '') => {+ fetchFolderContents = async (folderId, folderName, index, showLoading = true) => {this.abortApiCalls()- this.updateRowStatus(folderName, STORAGE_ROW_STATUS.LOADING, index)- this.pushColumnAtIndex(- { id: folderId, name: folderName, status: STORAGE_ROW_STATUS.LOADING, items: [] },- index- )+ if (showLoading) {+ this.updateRowStatus(folderName, STORAGE_ROW_STATUS.LOADING, index)+ this.pushColumnAtIndex(+ { id: folderId, name: folderName, status: STORAGE_ROW_STATUS.LOADING, items: [] },+ index+ )+ }const prefix = this.openedFolders.map((folder) => folder.name).join('/')- const options = {- limit: LIMIT,- offset: OFFSET,- search: searchString,- sortBy: { column: this.sortBy, order: 'asc' },- }+ const options = { limit: LIMIT, offset: OFFSET, sortBy: { column: this.sortBy, order: 'asc' } }const parameters = { signal: this.abortController.signal }const { data: items, error } = await this.supabaseClient.storage.from(this.selectedBucket.name).list(prefix, options, parameters)- this.updateRowStatus(folderName, STORAGE_ROW_STATUS.READY, index)+ if (showLoading) {+ this.updateRowStatus(folderName, STORAGE_ROW_STATUS.READY, index)+ }if (!error) {const formattedItems = this.formatFolderItems(items)@@ -963,14 +962,15 @@ class StorageExplorerStore {}}- fetchMoreFolderContents = async (index, column, searchString = '') => {+ fetchMoreFolderContents = async (index, column) => {this.setColumnIsLoadingMore(index)+ // [Joshen] Bug on the backend that sorting will not be respected+ // when we fetch more contents, but its okay, not blocking frontendconst prefix = this.openedFolders.map((folder) => folder.name).join('/')const options = {limit: LIMIT,offset: column.items.length,- search: searchString,sortBy: { column: this.sortBy, order: 'asc' },}const parameters = { signal: this.abortController.signal }