The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Implement organization and project menu items
Joshen Lim167326b47428
diff --git a/packages/ui/index.tsx b/packages/ui/index.tsxindex f1c481e4a50..da0f15fe962 100644--- a/packages/ui/index.tsx+++ b/packages/ui/index.tsx@@ -135,6 +135,13 @@ export {PopoverContent as PopoverContent_Shadcn_,} from './src/components/shadcn/ui/popover'+export {+ Accordion as Accordion_Shadcn_,+ AccordionItem as AccordionItem_Shadcn_,+ AccordionTrigger as AccordionTrigger_Shadcn_,+ AccordionContent as AccordionContent_Shadcn_,+} from './src/components/shadcn/ui/accordion'+// linksexport * from './src/components/TextLink'diff --git a/packages/ui/src/components/shadcn/ui/accordion.tsx b/packages/ui/src/components/shadcn/ui/accordion.tsxindex c5950299253..c5d5ec3dc15 100644--- a/packages/ui/src/components/shadcn/ui/accordion.tsx+++ b/packages/ui/src/components/shadcn/ui/accordion.tsx@@ -16,8 +16,8 @@ AccordionItem.displayName = 'AccordionItem'const AccordionTrigger = React.forwardRef<React.ElementRef<typeof AccordionPrimitive.Trigger>,- React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>->(({ className, children, ...props }, ref) => (+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger> & { hideIcon?: boolean }+>(({ className, children, hideIcon, ...props }, ref) => (<AccordionPrimitive.Header className="flex"><AccordionPrimitive.Triggerref={ref}@@ -28,7 +28,7 @@ const AccordionTrigger = React.forwardRef<{...props}>{children}- <ChevronDown className="h-4 w-4 transition-transform duration-200" />+ {!hideIcon && <ChevronDown className="h-4 w-4 transition-transform duration-200" />}</AccordionPrimitive.Trigger></AccordionPrimitive.Header>))diff --git a/studio/components/layouts/SettingsLayout/OrganizationSettingsMenu.tsx b/studio/components/layouts/SettingsLayout/OrganizationSettingsMenu.tsxindex 809c030ae02..42591bae660 100644--- a/studio/components/layouts/SettingsLayout/OrganizationSettingsMenu.tsx+++ b/studio/components/layouts/SettingsLayout/OrganizationSettingsMenu.tsx@@ -1,9 +1,11 @@import { useRouter } from 'next/router'+import { Accordion_Shadcn_, Button } from 'ui'import { useProjectsQuery } from 'data/projects/projects-query'import { useSelectedOrganization } from 'hooks'import OrganizationSettingsMenuItem from './OrganizationSettingsMenuItem'import ProjectSettingsMenuItem from './ProjectSettingsMenuItem'+import Link from 'next/link'const OrganizationSettingsMenu = () => {const router = useRouter()@@ -25,7 +27,7 @@ const OrganizationSettingsMenu = () => {return (<div className="space-y-10"><div className="space-y-2">- <p className="text-sm">Organization</p>+ <p className="text-sm font-medium">Organization</p>{organizationSettings.map((link) => (<OrganizationSettingsMenuItemkey={link.label}@@ -35,11 +37,24 @@ const OrganizationSettingsMenu = () => {/>))}</div>++ {/* [Joshen] We'll implement this in the second iteration, just to keep things small */}<div className="space-y-2">- <p className="text-sm">Projects</p>- {projects?.map((project) => (- <ProjectSettingsMenuItem key={project.ref} project={project} />- ))}+ <p className="text-sm font-medium">Projects</p>+ <Accordion_Shadcn_ type="single" collapsible className="w-full">+ {projects?.map((project) => (+ <ProjectSettingsMenuItem key={project.ref} project={project} />+ ))}+ </Accordion_Shadcn_>+ </div>+ <div>+ <Link href={`/new/${organization?.slug}`}>+ <a>+ <Button type="default" size="small">+ Create new project+ </Button>+ </a>+ </Link></div></div>)diff --git a/studio/components/layouts/SettingsLayout/ProjectSettingsMenuItem.tsx b/studio/components/layouts/SettingsLayout/ProjectSettingsMenuItem.tsxindex ce956a96365..0a40d1eaba1 100644--- a/studio/components/layouts/SettingsLayout/ProjectSettingsMenuItem.tsx+++ b/studio/components/layouts/SettingsLayout/ProjectSettingsMenuItem.tsx@@ -1,5 +1,13 @@import clsx from 'clsx'import Link from 'next/link'+import {+ AccordionContent_Shadcn_,+ AccordionItem_Shadcn_,+ AccordionTrigger_Shadcn_,+ IconChevronRight,+} from 'ui'++import { useSelectedOrganization } from 'hooks'import { Project } from 'types'interface ProjectSettingsMenuItemProps {@@ -7,19 +15,58 @@ interface ProjectSettingsMenuItemProps {}const ProjectSettingsMenuItem = ({ project }: ProjectSettingsMenuItemProps) => {+ const organization = useSelectedOrganization()+ const isOrgBilling = !!organization?.subscription_id++ // [Joshen] Links need to be updated once we start implementing these+ const projectSettings = isOrgBilling+ ? [+ { label: 'General', pathname: `/org/[slug]/settings` },+ { label: 'Infrastructure', pathname: `/org/[slug]/settings` },+ { label: 'Add Ons', pathname: `/org/[slug]/settings` },+ ]+ : [+ { label: 'General', pathname: `/org/[slug]/settings` },+ { label: 'Subscription', pathname: `/org/[slug]/settings` },+ { label: 'Usage', pathname: `/org/[slug]/settings` },+ { label: 'Invoices', pathname: `/org/[slug]/settings` },+ ]+return (- <div>- <Link href={'/'}>- <a- className={clsx(- 'text-sm',- false ? 'text-scale-1200' : 'text-scale-1100 hover:text-scale-1200 transition'- )}- >- {project.name}- </a>- </Link>- </div>+ <AccordionItem_Shadcn_ value={project.ref} className="!border-none">+ <AccordionTrigger_Shadcn_+ hideIcon+ className="py-1.5 hover:!no-underline [&[data-state=open]>div>svg]:!rotate-90 [&[data-state=open]>div>p]:text-scale-1200"+ >+ <div className="flex items-center space-x-2">+ <IconChevronRight+ className="h-4 w-4 transition-transform duration-200"+ strokeWidth={1.5}+ />+ <p className="text-scale-1100 text-sm font-normal transition duration-200">+ {project.name}+ </p>+ </div>+ </AccordionTrigger_Shadcn_>+ <AccordionContent_Shadcn_>+ <div className="space-y-2 pl-6 mt-1">+ {projectSettings.map((link) => (+ <div key={link.label}>+ <Link href={link.pathname.replace('[slug]', '')}>+ <a+ className={clsx(+ 'text-sm',+ false ? 'text-scale-1200' : 'text-scale-1100 hover:text-scale-1200 transition'+ )}+ >+ {link.label}+ </a>+ </Link>+ </div>+ ))}+ </div>+ </AccordionContent_Shadcn_>+ </AccordionItem_Shadcn_>)}