Skip to content

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

Scaffold nav layout change

Joshen Limb104c6c8ab4d
diff --git a/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx b/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
index 20bf8488a3a..ad3689be4f9 100644
--- a/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
+++ b/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx
@@ -24,7 +24,7 @@ const ProjectCard = ({ project, rewriteHref }: ProjectCardProps) => {
const isRestoring = project.status === PROJECT_STATUS.RESTORING
return (
- <li className="col-span-1">
+ <li className="col-span-1 list-none">
<CardButton
linkHref={rewriteHref ? rewriteHref : `/project/${projectRef}`}
title={
diff --git a/studio/components/layouts/AppLayout/AppLayout.tsx b/studio/components/layouts/AppLayout/AppLayout.tsx
new file mode 100644
index 00000000000..a14f74d752c
--- /dev/null
+++ b/studio/components/layouts/AppLayout/AppLayout.tsx
@@ -0,0 +1,16 @@
+import Image from 'next/image'
+import Link from 'next/link'
+import { PropsWithChildren } from 'react'
+
+import HeaderBar from './HeaderBar'
+
+const AppLayout = ({ children }: PropsWithChildren<{}>) => {
+ return (
+ <div>
+ <HeaderBar />
+ {children}
+ </div>
+ )
+}
+
+export default AppLayout
diff --git a/studio/components/layouts/AppLayout/HeaderBar.tsx b/studio/components/layouts/AppLayout/HeaderBar.tsx
new file mode 100644
index 00000000000..543159b4785
--- /dev/null
+++ b/studio/components/layouts/AppLayout/HeaderBar.tsx
@@ -0,0 +1,47 @@
+import Link from 'next/link'
+import { useRouter } from 'next/router'
+import FeedbackDropdown from '../ProjectLayout/LayoutHeader/FeedbackDropdown'
+import { Button, Dropdown, IconHelpCircle, IconInbox } from 'ui'
+import { useProfile } from 'lib/profile'
+import OrganizationDropdown from './OrganizationDropdown'
+
+const HeaderBar = () => {
+ const router = useRouter()
+ const { profile } = useProfile()
+
+ return (
+ <div className="flex items-center justify-between px-4 py-2 bg-scale-100 shadow-md">
+ {/* Organization + Project */}
+ <div className="flex items-center space-x-4">
+ <Link href="/projects-v2">
+ <a className="block">
+ <img
+ src={`${router.basePath}/img/supabase-logo.svg`}
+ alt="Supabase"
+ className="mx-auto h-[40px] w-6 cursor-pointer rounded"
+ />
+ </a>
+ </Link>
+ <OrganizationDropdown />
+ </div>
+
+ {/* Account, Settings, etc */}
+ <div className="flex items-center space-x-4">
+ <FeedbackDropdown />
+ <Button type="text" className="px-1" icon={<IconInbox size={18} />} />
+ <Button type="text" className="px-1" icon={<IconHelpCircle size={18} />} />
+ <Dropdown
+ align="end"
+ side="bottom"
+ overlay={[<Dropdown.Item key="test">Hello</Dropdown.Item>]}
+ >
+ <div className="flex items-center justify-center border rounded-full h-7 w-7 text-scale-1100">
+ {profile?.first_name[0]}
+ </div>
+ </Dropdown>
+ </div>
+ </div>
+ )
+}
+
+export default HeaderBar
diff --git a/studio/components/layouts/AppLayout/OrganizationDropdown.tsx b/studio/components/layouts/AppLayout/OrganizationDropdown.tsx
new file mode 100644
index 00000000000..b5e5a9426df
--- /dev/null
+++ b/studio/components/layouts/AppLayout/OrganizationDropdown.tsx
@@ -0,0 +1,78 @@
+import { useRouter } from 'next/router'
+import { Button, Dropdown, IconChevronDown, IconChevronsDown, IconPlus } from 'ui'
+
+import { useOrganizationsQuery } from 'data/organizations/organizations-query'
+import { useFlag, useSelectedOrganization, useStore } from 'hooks'
+import { IS_PLATFORM } from 'lib/constants'
+
+const OrganizationDropdown = () => {
+ const router = useRouter()
+ const { ui } = useStore()
+ const { data: organizations } = useOrganizationsQuery()
+ const selectedOrganization = useSelectedOrganization()
+ const orgCreationV2 = useFlag('orgcreationv2')
+
+ return IS_PLATFORM ? (
+ <Dropdown
+ side="bottom"
+ align="start"
+ overlay={
+ <>
+ {organizations
+ ?.sort((a, b) => a.name.localeCompare(b.name))
+ .map((x) => {
+ const slug = x.slug
+
+ return (
+ <Dropdown.Item
+ key={slug}
+ onClick={() => {
+ if (!slug) {
+ // The user should not see this error as the page should
+ // be rerendered with the value of slug before they can click.
+ // It is just here in case they are the flash.
+ return ui.setNotification({
+ category: 'error',
+ message:
+ 'Could not navigate to organization settings, please try again or contact support',
+ })
+ }
+
+ router.push({
+ pathname: `/org/[slug]/general`,
+ query: { slug },
+ hash: router.asPath.split('#')[1]?.toLowerCase(),
+ })
+ }}
+ >
+ {x.name}
+ </Dropdown.Item>
+ )
+ })}
+ <Dropdown.Separator />
+ <Dropdown.Item icon={<IconPlus size="tiny" />} onClick={() => router.push(`/new`)}>
+ New organization
+ </Dropdown.Item>
+ {orgCreationV2 && (
+ <Dropdown.Item
+ icon={<IconPlus size="tiny" />}
+ onClick={() => router.push(`/new-with-subscription`)}
+ >
+ New organization V2
+ </Dropdown.Item>
+ )}
+ </>
+ }
+ >
+ <Button type="text" iconRight={<IconChevronDown />}>
+ <span className="text-sm">{selectedOrganization?.name}</span>
+ </Button>
+ </Dropdown>
+ ) : (
+ <Button type="text">
+ <span className="text-sm">{selectedOrganization?.name}</span>
+ </Button>
+ )
+}
+
+export default OrganizationDropdown
diff --git a/studio/pages/org/[slug]/index.tsx b/studio/pages/org/[slug]/index.tsx
new file mode 100644
index 00000000000..0daf06e04b4
--- /dev/null
+++ b/studio/pages/org/[slug]/index.tsx
@@ -0,0 +1,63 @@
+import ProjectCard from 'components/interfaces/Home/ProjectList/ProjectCard'
+import ShimmeringCard from 'components/interfaces/Home/ProjectList/ShimmeringCard'
+import AppLayout from 'components/layouts/AppLayout/AppLayout'
+import { ScaffoldContainer, ScaffoldSection } from 'components/layouts/Scaffold'
+import AlertError from 'components/ui/AlertError'
+import { useProjectsQuery } from 'data/projects/projects-query'
+import { useSelectedOrganization } from 'hooks'
+import Link from 'next/link'
+import { NextPageWithLayout } from 'types'
+import { Button, IconPlus } from 'ui'
+
+const ProjectsPage: NextPageWithLayout = () => {
+ const {
+ data: allProjects,
+ error: projectsError,
+ isLoading: isLoadingProjects,
+ isError: isErrorProjects,
+ isSuccess: isSuccessProjects,
+ } = useProjectsQuery()
+ const organization = useSelectedOrganization()
+ const projects = allProjects?.filter((project) => project.organization_id === organization?.id)
+
+ if (!organization) {
+ // Return a 404 page
+ }
+
+ return (
+ <ScaffoldContainer>
+ <ScaffoldSection>
+ <div className="col-span-12 space-y-4">
+ <div className="flex items-center space-x-6">
+ <h4 className="text-lg">Projects</h4>
+ <Link href={`/new/${organization?.slug}`}>
+ <a>
+ <Button icon={<IconPlus />}>New project</Button>
+ </a>
+ </Link>
+ </div>
+ {isLoadingProjects && (
+ <ul className="mx-auto grid grid-cols-1 gap-4 sm:grid-cols-1 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3">
+ <ShimmeringCard />
+ <ShimmeringCard />
+ </ul>
+ )}
+ {isErrorProjects && (
+ <AlertError error={projectsError} subject="Failed to retrieve projects" />
+ )}
+ {isSuccessProjects && (
+ <ul className="mx-auto grid grid-cols-1 gap-4 sm:grid-cols-1 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3">
+ {projects?.map((project) => (
+ <ProjectCard key={project.ref} project={project} />
+ ))}
+ </ul>
+ )}
+ </div>
+ </ScaffoldSection>
+ </ScaffoldContainer>
+ )
+}
+
+ProjectsPage.getLayout = (page) => <AppLayout>{page}</AppLayout>
+
+export default ProjectsPage