mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
- Most changes are related to either types or `useRef` usages (it now requires an initial value). - also updated `vaul` to its latest version and haven't noticed any change ([design-system demo](https://design-system-git-react-19-supabase.vercel.app/design-system/docs/components/drawer)) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Upgraded workspace to React 19. * **Bug Fixes** * Improved null-safety and ref handling across editors, UI components, shortcuts, and markdown/image rendering to reduce runtime errors. * Safer event/timeout/interval cleanup and more robust command/context handling. * **Chores** * Bumped vaul dependency versions. * **Documentation** * Type and TypeScript accuracy improvements for clearer developer feedback. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/45886) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
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'
|
|
|
|
interface UseFilesBucketsShortcutsParams {
|
|
searchInputRef: RefObject<HTMLInputElement | null>
|
|
setFilterString: Dispatch<SetStateAction<string>>
|
|
sortBucket: STORAGE_BUCKET_SORT
|
|
setSortBucket: (value: STORAGE_BUCKET_SORT) => void
|
|
setCreateVisible: (value: boolean) => void
|
|
onRefresh: () => void
|
|
}
|
|
|
|
export function useFilesBucketsShortcuts({
|
|
searchInputRef,
|
|
setFilterString,
|
|
sortBucket,
|
|
setSortBucket,
|
|
setCreateVisible,
|
|
onRefresh,
|
|
}: UseFilesBucketsShortcutsParams) {
|
|
const { can: canCreateBuckets } = useAsyncCheckPermissions(PermissionAction.STORAGE_WRITE, '*')
|
|
|
|
useShortcut(
|
|
SHORTCUT_IDS.LIST_PAGE_FOCUS_SEARCH,
|
|
() => {
|
|
searchInputRef.current?.focus()
|
|
searchInputRef.current?.select()
|
|
},
|
|
{ label: 'Search buckets' }
|
|
)
|
|
|
|
useShortcut(SHORTCUT_IDS.LIST_PAGE_NEW_ITEM, () => setCreateVisible(true), {
|
|
label: 'Create new bucket',
|
|
enabled: canCreateBuckets,
|
|
})
|
|
|
|
useShortcut(SHORTCUT_IDS.LIST_PAGE_RESET_FILTERS, () => {
|
|
setFilterString('')
|
|
})
|
|
|
|
useShortcut(SHORTCUT_IDS.STORAGE_BUCKETS_REFRESH, onRefresh)
|
|
|
|
useShortcut(
|
|
SHORTCUT_IDS.STORAGE_BUCKETS_CLEAR_SORT,
|
|
() => setSortBucket(STORAGE_BUCKET_SORT.CREATED_AT),
|
|
{ enabled: sortBucket !== STORAGE_BUCKET_SORT.CREATED_AT }
|
|
)
|
|
}
|