Files
supabase/apps/studio/pages/project/_/[[...routeSlug]].tsx
Alaister YoungandKevin Grüneberg 70da0f1d1d chore: cleanup packages (#27770)
* 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>
2024-07-04 14:48:10 +08:00

68 lines
2.0 KiB
TypeScript

import { NextPage } from 'next'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { ProjectList } from 'components/interfaces/Home/ProjectList'
import { withAuth } from 'hooks/misc/withAuth'
import { BASE_PATH } from 'lib/constants'
const Header = () => {
return (
<div className="border-default border-b p-3">
<div className="flex items-center space-x-2">
<Link href="/projects">
<img
src={`${BASE_PATH}/img/supabase-logo.svg`}
alt="Supabase"
className="border-default rounded border p-1 hover:border-white"
style={{ height: 24 }}
/>
</Link>
</div>
</div>
)
}
// [Joshen] I'd say we don't do route validation here, this page will act more
// like a proxy to the project specific pages, and we let those pages handle
// any route validation logic instead
const GenericProjectPage: NextPage = () => {
const router = useRouter()
const { routeSlug, ...queryParams } = router.query
const query = Object.keys(queryParams).length
? `?${new URLSearchParams(queryParams as Record<string, string>)}`
: undefined
const urlRewriterFactory = (slug: string | string[] | undefined) => {
return (projectRef: string) => {
const hash = location.hash
if (!Array.isArray(slug)) {
return [`/project/${projectRef}`, query, hash].filter(Boolean).join('')
}
const slugPath = slug.join('/')
return [`/project/${projectRef}/${slugPath}`, query, hash].filter(Boolean).join('')
}
}
return (
<>
<Header />
<div className="flex flex-col mx-auto w-full max-w-5xl">
<h1 className="mt-8 text-2xl">Select a project to continue</h1>
<div
className="flex-grow py-6 space-y-8 overflow-y-auto"
style={{ maxHeight: 'calc(100vh - 49px - 64px)' }}
>
<ProjectList rewriteHref={urlRewriterFactory(routeSlug)} search="" />
</div>
</div>
</>
)
}
export default withAuth(GenericProjectPage)