mirror of
https://github.com/supabase/supabase.git
synced 2026-10-18 23:59:08 +03:00
* Migrate all API calls to data folder. * Remove unused mutation. * MInor leftover type fixes. * chore: Make the `StorageExplorerStore` fully typed (#23397) * Migrate all API calls to data folder. * Convert the poor man enums into proper enums. * Add types to most of the methods. * Add types around the methods for uploading files. * Add types for file cache. * Add types for buckets. * Fix bunch of type errors. * Add types to all store methods. Fix all types in components related to the store. * Remove all anys from the Storage components. * Fix the multiple selection. * Fix the selected checkbox. * Set all private methods to private and delete some unneeded code. * Remove unneeded mutation. * Update all mutations for storage explorer to follow template syntax * Update apps/studio/components/to-be-cleaned/Storage/StorageExplorer/PreviewPane.tsx Co-authored-by: Alaister Young <alaister@users.noreply.github.com> --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> Co-authored-by: Alaister Young <alaister@users.noreply.github.com>
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import { useParams } from 'common'
|
|
import { ReactNode, useEffect } from 'react'
|
|
import toast from 'react-hot-toast'
|
|
|
|
import { AutoApiService, useProjectApiQuery } from 'data/config/project-api-query'
|
|
import { useSelectedProject, withAuth } from 'hooks'
|
|
import { PROJECT_STATUS } from 'lib/constants'
|
|
import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'
|
|
import { ProjectLayout } from '../'
|
|
import StorageMenu from './StorageMenu'
|
|
|
|
export interface StorageLayoutProps {
|
|
title: string
|
|
children: ReactNode
|
|
}
|
|
|
|
const StorageLayout = ({ title, children }: StorageLayoutProps) => {
|
|
const { ref: projectRef } = useParams()
|
|
const project = useSelectedProject()
|
|
const storageExplorerStore = useStorageStore()
|
|
|
|
const { data: settings, isLoading } = useProjectApiQuery({ projectRef })
|
|
const apiService = settings?.autoApiService
|
|
|
|
const isPaused = project?.status === PROJECT_STATUS.INACTIVE
|
|
|
|
useEffect(() => {
|
|
if (!isLoading && apiService) initializeStorageStore(apiService)
|
|
}, [isLoading, projectRef])
|
|
|
|
const initializeStorageStore = async (apiService: AutoApiService) => {
|
|
if (isPaused) return
|
|
|
|
if (apiService.endpoint) {
|
|
storageExplorerStore.initStore(
|
|
projectRef!,
|
|
apiService.endpoint,
|
|
apiService.serviceApiKey,
|
|
apiService.protocol
|
|
)
|
|
} else {
|
|
toast.error(
|
|
'Failed to fetch project configuration. Try refreshing your browser, or reach out to us at support@supabase.io'
|
|
)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<ProjectLayout title={title || 'Storage'} product="Storage" productMenu={<StorageMenu />}>
|
|
{children}
|
|
</ProjectLayout>
|
|
)
|
|
}
|
|
|
|
export default withAuth(StorageLayout)
|