Skip to content

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

Fix renaming file not updating url when clicking get url in preview pane

Joshen Lim5c8bd6f587ca
diff --git a/studio/components/layouts/StorageLayout/StorageMenu.tsx b/studio/components/layouts/StorageLayout/StorageMenu.tsx
index 50a339a7fa5..bfbca13590a 100644
--- a/studio/components/layouts/StorageLayout/StorageMenu.tsx
+++ b/studio/components/layouts/StorageLayout/StorageMenu.tsx
@@ -3,7 +3,7 @@ import Link from 'next/link'
import { useRouter } from 'next/router'
import { observer } from 'mobx-react-lite'
import * as Tooltip from '@radix-ui/react-tooltip'
-import { Button, Menu, IconLoader, Alert, IconEdit } from 'ui'
+import { Button, Menu, Alert, IconEdit } from 'ui'
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { checkPermissions } from 'hooks'
@@ -13,6 +13,7 @@ import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStor
import { StorageBucket } from 'components/interfaces/Storage/Storage.types'
import EditBucketModal from 'components/interfaces/Storage/EditBucketModal'
import CreateBucketModal from 'components/interfaces/Storage/CreateBucketModal'
+import ShimmeringLoader from 'components/ui/ShimmeringLoader'
interface Props {}
@@ -78,9 +79,10 @@ const StorageMenu: FC<Props> = () => {
<div>
<Menu.Group title="All buckets" />
{!loaded ? (
- <div className="flex items-center space-x-2 py-2 px-2">
- <IconLoader className="animate-spin" size={14} strokeWidth={2} />
- <span className="text-sm">Loading buckets</span>
+ <div className="space-y-2">
+ <ShimmeringLoader className="!py-2.5" />
+ <ShimmeringLoader className="!py-2.5 w-3/4" />
+ <ShimmeringLoader className="!py-2.5 w-1/2" />
</div>
) : (
<>
diff --git a/studio/localStores/storageExplorer/StorageExplorerStore.js b/studio/localStores/storageExplorer/StorageExplorerStore.js
index 511af472229..f19e4c59faf 100644
--- a/studio/localStores/storageExplorer/StorageExplorerStore.js
+++ b/studio/localStores/storageExplorer/StorageExplorerStore.js
@@ -347,7 +347,8 @@ class StorageExplorerStore {
setFilePreview = async (file) => {
const size = file.metadata?.size
const mimeType = file.metadata?.mimetype
- if (mimeType && size && this.selectedFilePreview.id !== file.id) {
+
+ if (mimeType && size) {
// Skip fetching of file preview if file is too big
if (size > PREVIEW_SIZE_LIMIT) {
this.selectedFilePreview = { ...file, previewUrl: 'skipped' }
@@ -395,7 +396,7 @@ class StorageExplorerStore {
copyFileURLToClipboard = async (file, expiresIn = 0) => {
const filePreview = find(this.filePreviewCache, { id: file.id })
- if (filePreview && expiresIn === 0) {
+ if (filePreview !== undefined && expiresIn === 0) {
// Already generated signed URL
copyToClipboard(filePreview.url, () => {
this.ui.setNotification({
@@ -1128,14 +1129,25 @@ class StorageExplorerStore {
if (res.error) {
this.ui.setNotification({ category: 'error', message: res.error.message })
- }
- await this.refetchAllOpenedFolders()
+ } else {
+ this.ui.setNotification({
+ category: 'success',
+ message: `Successfully renamed "${originalName}" to "${newName}"`,
+ })
- // Clear file preview cache if the renamed file exists in the cache
- const updatedFilePreviewCache = this.filePreviewCache.filter(
- (fileCache) => fileCache.id !== file.id
- )
- this.filePreviewCache = updatedFilePreviewCache
+ // Clear file preview cache if the renamed file exists in the cache
+ const updatedFilePreviewCache = this.filePreviewCache.filter(
+ (fileCache) => fileCache.id !== file.id
+ )
+ this.filePreviewCache = updatedFilePreviewCache
+
+ if (this.selectedFilePreview.name === originalName) {
+ const { previewUrl, ...fileData } = file
+ this.setFilePreview({ ...fileData, name: newName })
+ }
+
+ await this.refetchAllOpenedFolders()
+ }
}
}