mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 10:25:06 +03:00
* chore: cleanup packages - Avoid circular imports - Export API-types as types - pg-format without depending on Node internal Buffer (not browser-compatible) - Avoid importing from barrel files in ui dir * chore: avoid barrel file imports in studio (#27771) * chore: avoid barrel file imports - Removes some unused imports - Avoids barrel file import for faster builds + less memory * add eslint rule * type fixes * delete layouts barrel * delete components/grid barrel file * delete components/grid/utils barrel file * delete components/grid/components/common barrel file * delete components/grid/components/editor barrel file * delete components/grid/components/formatter barrel file * delete components/grid/components/grid barrel file * delete components/grid/components/header/filter barrel file * remote components/grid/store barrel file * remove components/interfaces/Auth/Policies barrel file * delete components/interfaces/Settings/Logs barrel file * delete components/ui/CodeEditor barrel file * delete components/ui/Forms barrel file * delete components/ui/Shimmers barrel file * delete data/analytics barrel file * delete hooks barrel file * cleanup lib/common/fetch barrel file * final * barral files cleanup * global react-data-grid styles * remove console.log --------- Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com> * fix build --------- Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
57 lines
1.7 KiB
TypeScript
57 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 } from 'hooks/misc/useSelectedProject'
|
|
import { withAuth } from 'hooks/misc/withAuth'
|
|
import { PROJECT_STATUS } from 'lib/constants'
|
|
import { useStorageStore } from 'localStores/storageExplorer/StorageExplorerStore'
|
|
import ProjectLayout from '../ProjectLayout/ProjectLayout'
|
|
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)
|