Skip to content

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

fix: storage shortcuts (#45978)

Vaibhav1591e4135199
diff --git a/apps/studio/components/interfaces/Storage/FilesBuckets/useFilesBucketsShortcuts.ts b/apps/studio/components/interfaces/Storage/FilesBuckets/useFilesBucketsShortcuts.ts
index 6b6330b7d6c..e9b55b97d4b 100644
--- a/apps/studio/components/interfaces/Storage/FilesBuckets/useFilesBucketsShortcuts.ts
+++ b/apps/studio/components/interfaces/Storage/FilesBuckets/useFilesBucketsShortcuts.ts
@@ -1,6 +1,8 @@
+import { PermissionAction } from '@supabase/shared-types/out/constants'
import { Dispatch, RefObject, SetStateAction } from 'react'
import { STORAGE_BUCKET_SORT } from '../Storage.constants'
+import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
import { useShortcut } from '@/state/shortcuts/useShortcut'
@@ -21,6 +23,8 @@ export function useFilesBucketsShortcuts({
setCreateVisible,
onRefresh,
}: UseFilesBucketsShortcutsParams) {
+ const { can: canCreateBuckets } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*')
+
useShortcut(
SHORTCUT_IDS.LIST_PAGE_FOCUS_SEARCH,
() => {
@@ -32,6 +36,7 @@ export function useFilesBucketsShortcuts({
useShortcut(SHORTCUT_IDS.LIST_PAGE_NEW_ITEM, () => setCreateVisible(true), {
label: 'Create new bucket',
+ enabled: canCreateBuckets,
})
useShortcut(SHORTCUT_IDS.LIST_PAGE_RESET_FILTERS, () => {
diff --git a/apps/studio/components/interfaces/Storage/StorageExplorer/useStorageExplorerShortcuts.ts b/apps/studio/components/interfaces/Storage/StorageExplorer/useStorageExplorerShortcuts.ts
index 804c70a7bb6..cbc863da12f 100644
--- a/apps/studio/components/interfaces/Storage/StorageExplorer/useStorageExplorerShortcuts.ts
+++ b/apps/studio/components/interfaces/Storage/StorageExplorer/useStorageExplorerShortcuts.ts
@@ -32,13 +32,9 @@ export function useStorageExplorerShortcuts({ onClearSearch }: UseStorageExplore
const { can: canUpdateFiles } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*')
- useShortcut(
- SHORTCUT_IDS.STORAGE_EXPLORER_REFRESH,
- () => {
- refreshAll()
- },
- { enabled: selectedItems.length === 0 }
- )
+ useShortcut(SHORTCUT_IDS.STORAGE_EXPLORER_REFRESH, () => {
+ refreshAll()
+ })
useShortcut(
SHORTCUT_IDS.STORAGE_EXPLORER_DOWNLOAD_SELECTED,
@@ -61,7 +57,7 @@ export function useStorageExplorerShortcuts({ onClearSearch }: UseStorageExplore
useShortcut(
SHORTCUT_IDS.STORAGE_EXPLORER_DELETE_SELECTED,
() => setSelectedItemsToDelete(selectedItems),
- { enabled: selectedItems.length > 0 }
+ { enabled: selectedItems.length > 0 && canUpdateFiles }
)
useShortcut(SHORTCUT_IDS.STORAGE_EXPLORER_EXIT_SELECTION, () => clearSelectedItems(), {