The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(studio): account area ui updates (#38006)
kemal.earth0fadb115607d
diff --git a/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx b/apps/studio/components/layouts/AccountLayout/AccountLayout.tsxindex cc610501128..cf709526141 100644--- a/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx+++ b/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx@@ -1,6 +1,4 @@-import { ArrowLeft } from 'lucide-react'import Head from 'next/head'-import Link from 'next/link'import { useRouter } from 'next/router'import { PropsWithChildren, useEffect } from 'react'@@ -9,13 +7,8 @@ import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'import { withAuth } from 'hooks/misc/withAuth'import { IS_PLATFORM } from 'lib/constants'import { useAppStateSnapshot } from 'state/app-state'-import { cn, NavMenu, NavMenuItem } from 'ui'-import {- MAX_WIDTH_CLASSES,- PADDING_CLASSES,- ScaffoldContainerLegacy,- ScaffoldTitle,-} from '../Scaffold'+import { cn } from 'ui'+import { WithSidebar } from './WithSidebar'export interface AccountLayoutProps {title: string@@ -37,19 +30,6 @@ const AccountLayout = ({ children, title }: PropsWithChildren<AccountLayoutProps? `/org/${lastVisitedOrganization}`: '/organizations'- const accountLinks = [- {- label: 'Account Settings',- href: `/account/me`,- keys: [`/account/me`, `/account/tokens`, `/account/security`],- },- {- label: 'Audit Logs',- href: `/account/audit`,- key: `/account/audit`,- },- ]-const currentPath = router.pathnameuseEffect(() => {@@ -64,33 +44,52 @@ const AccountLayout = ({ children, title }: PropsWithChildren<AccountLayoutProps<title>{title ? `${title} | Supabase` : 'Supabase'}</title><meta name="description" content="Supabase Studio" /></Head>- <div className={cn('flex flex-col h-screen w-screen')}>- <ScaffoldContainerLegacy>- <Link- href={backToDashboardURL}- className="flex text-xs flex-row gap-2 items-center text-foreground-lighter focus-visible:text-foreground hover:text-foreground"- >- <ArrowLeft strokeWidth={1.5} size={14} />- Back to dashboard- </Link>- <ScaffoldTitle>Account settings</ScaffoldTitle>- </ScaffoldContainerLegacy>- <div className="border-b">- <NavMenu- className={cn(PADDING_CLASSES, MAX_WIDTH_CLASSES, 'border-none')}- aria-label="Organization menu navigation"- >- {accountLinks.map((item, i) => (- <NavMenuItem- key={`${item.key}-${i}`}- active={(item.key === currentPath || item.keys?.includes(currentPath)) ?? false}- >- <Link href={item.href}>{item.label}</Link>- </NavMenuItem>- ))}- </NavMenu>- </div>- {children}+ <div className={cn('flex flex-col w-screen h-[calc(100vh-48px)]')}>+ <WithSidebar+ title=""+ breadcrumbs={[]}+ backToDashboardURL={backToDashboardURL}+ sections={[+ {+ key: 'account-settings',+ heading: 'Account Settings',+ links: [+ {+ key: 'preferences',+ label: 'Preferences',+ href: '/account/me',+ isActive: currentPath === '/account/me',+ },+ {+ key: 'access-tokens',+ label: 'Access Tokens',+ href: '/account/tokens',+ isActive: currentPath === '/account/tokens',+ },+ {+ key: 'security',+ label: 'Security',+ href: '/account/security',+ isActive: currentPath === '/account/security',+ },+ ],+ },+ {+ key: 'logs',+ heading: 'Logs',+ links: [+ {+ key: 'audit-logs',+ label: 'Audit Logs',+ href: '/account/audit',+ isActive: currentPath === '/account/audit',+ },+ ],+ },+ ]}+ >+ {children}+ </WithSidebar></div></>)diff --git a/apps/studio/components/layouts/AccountLayout/WithSidebar.tsx b/apps/studio/components/layouts/AccountLayout/WithSidebar.tsxindex 2ea219a9d50..b70d439f9f5 100644--- a/apps/studio/components/layouts/AccountLayout/WithSidebar.tsx+++ b/apps/studio/components/layouts/AccountLayout/WithSidebar.tsx@@ -1,11 +1,9 @@-import { isUndefined } from 'lodash'-import { ArrowUpRight, LogOut } from 'lucide-react'+import { ArrowLeft } from 'lucide-react'import Link from 'next/link'-import { PropsWithChildren, ReactNode, useState } from 'react'-import { Badge, cn, Menu } from 'ui'+import { PropsWithChildren, ReactNode } from 'react'+import { cn, Menu } from 'ui'import MobileSheetNav from 'ui-patterns/MobileSheetNav/MobileSheetNav'-import { LayoutHeader } from '../ProjectLayout/LayoutHeader'-import type { SidebarLink, SidebarSection } from './AccountLayout.types'+import type { SidebarSection } from './AccountLayout.types'import { useAppStateSnapshot } from 'state/app-state'interface WithSidebarProps {@@ -17,9 +15,10 @@ interface WithSidebarProps {subitemsParentKey?: numberhideSidebar?: booleancustomSidebarContent?: ReactNode+ backToDashboardURL?: string}-const WithSidebar = ({+export const WithSidebar = ({title,header,breadcrumbs = [],@@ -29,6 +28,7 @@ const WithSidebar = ({subitemsParentKey,hideSidebar = false,customSidebarContent,+ backToDashboardURL,}: PropsWithChildren<WithSidebarProps>) => {const noContent = !sections && !customSidebarContentconst { mobileMenuOpen, setMobileMenuOpen } = useAppStateSnapshot()@@ -43,11 +43,16 @@ const WithSidebar = ({subitems={subitems}subitemsParentKey={subitemsParentKey}customSidebarContent={customSidebarContent}- className="hidden md:block"+ backToDashboardURL={backToDashboardURL}+ className="hidden md:flex"/>)}<div className="flex flex-1 flex-col">- <div className="flex-1 flex-grow overflow-y-auto">{children}</div>+ <div className="flex-1 flex-grow overflow-y-auto">+ <div className="mx-auto max-w-7xl w-full px-6 lg:px-14 xl:px-28 2xl:px-32 py-16">+ {children}+ </div>+ </div></div><MobileSheetNav open={mobileMenuOpen} onOpenChange={setMobileMenuOpen}><SidebarContent@@ -57,12 +62,12 @@ const WithSidebar = ({subitems={subitems}subitemsParentKey={subitemsParentKey}customSidebarContent={customSidebarContent}+ backToDashboardURL={backToDashboardURL}/></MobileSheetNav></div>)}-export default WithSidebarexport const SidebarContent = ({title,@@ -71,6 +76,7 @@ export const SidebarContent = ({subitems,subitemsParentKey,customSidebarContent,+ backToDashboardURL,className,}: PropsWithChildren<Omit<WithSidebarProps, 'breadcrumbs'>> & { className?: string }) => {return (@@ -78,43 +84,72 @@ export const SidebarContent = ({<divid="with-sidebar"className={cn(- 'h-full bg-dash-sidebar',- 'hide-scrollbar w-full md:w-64 overflow-auto md:border-r border-default',+ 'h-full bg-dash-sidebar flex flex-col justify-between',+ 'hide-scrollbar w-full md:w-64 md:border-r border-default',className)}>- {title && (- <div className="block mb-2">- <div className="flex h-12 max-h-12 items-center border-b px-6 border-default">- <h4 className="mb-0 text-lg truncate" title={title}>- {title}- </h4>+ <div className="flex-1 flex flex-col">+ {backToDashboardURL && (+ <div className="flex-shrink-0 hidden md:block">+ <div className="flex h-12 max-h-12 items-center border-b px-6 border-default">+ <Link+ href={backToDashboardURL}+ className="flex text-sm flex-row gap-2 items-center text-foreground-lighter focus-visible:text-foreground hover:text-foreground"+ >+ <ArrowLeft strokeWidth={1.5} size={16} />+ Back to dashboard+ </Link>+ </div>+ </div>+ )}+ {header && header}+ <div className="flex-1 overflow-auto">+ <div className="flex flex-col space-y-8">+ <Menu type="pills">+ {customSidebarContent}+ {sections.map((section, idx) => (+ <div key={section.key || section.heading}>+ {Boolean(section.heading) ? (+ <SectionWithHeaders+ key={section.key}+ section={section}+ subitems={subitems}+ subitemsParentKey={subitemsParentKey}+ />+ ) : (+ <div className="my-6 space-y-8">+ <div className="mx-3">+ {section.links.map((link, i: number) => {+ const isActive = link.isActive && !subitems+ return (+ <Menu.Item+ key={`${link.key}-${i}`}+ rounded+ active={isActive}+ icon={link.icon}+ >+ <Link href={link.href || ''} className="block">+ <div className="flex w-full items-center justify-between gap-1">+ <div className="flex items-center gap-2 truncate w-full">+ <span className="truncate">{link.label}</span>+ </div>+ </div>+ </Link>+ </Menu.Item>+ )+ })}+ </div>+ </div>+ )}+ {idx !== sections.length - 1 && (+ <div className="h-px w-full bg-border-overlay" />+ )}+ </div>+ ))}+ </Menu></div></div>- )}- {header && header}- <div className="-mt-1">- <Menu>- {customSidebarContent}- {sections.map((section) => {- return Boolean(section.heading) ? (- <SectionWithHeaders- key={section.key}- section={section}- subitems={subitems}- subitemsParentKey={subitemsParentKey}- />- ) : (- <div className="border-b py-5 px-6 border-default" key={section.key}>- <SidebarItem- links={section.links}- subitems={subitems}- subitemsParentKey={subitemsParentKey}- />- </div>- )- })}- </Menu></div></div></>@@ -128,131 +163,33 @@ interface SectionWithHeadersProps {}const SectionWithHeaders = ({ section, subitems, subitemsParentKey }: SectionWithHeadersProps) => (- <div key={section.heading} className="border-b py-5 px-6 border-default">- {section.heading && <Menu.Group title={section.heading} />}- {section.versionLabel && (- <div className="mb-1 px-3">- <Badge variant="warning">{section.versionLabel}</Badge>+ <div key={section.heading} className="my-6 space-y-8">+ <div className="mx-3">+ {section.heading && (+ <Menu.Group+ title={+ <div className="flex flex-col space-y-2 uppercase font-mono">+ <span>{section.heading}</span>+ </div>+ }+ />+ )}+ <div>+ {section.links.map((link, i: number) => {+ const isActive = link.isActive && !subitems+ return (+ <Menu.Item key={`${link.key}-${i}`} rounded active={isActive} icon={link.icon}>+ <Link href={link.href || ''} className="block">+ <div className="flex w-full items-center justify-between gap-1">+ <div className="flex items-center gap-2 truncate w-full">+ <span className="truncate">{link.label}</span>+ </div>+ </div>+ </Link>+ </Menu.Item>+ )+ })}</div>- )}- {- <SidebarItem- links={section.links}- subitems={subitems}- subitemsParentKey={subitemsParentKey}- />- }+ </div></div>)-interface SidebarItemProps {- links: SidebarLink[]- subitems?: any[]- subitemsParentKey?: number-}--const SidebarItem = ({ links, subitems, subitemsParentKey }: SidebarItemProps) => {- return (- <ul className="space-y-1">- {links.map((link, i: number) => {- // disable active state for link with subitems- const isActive = link.isActive && !subitems-- let render: any = (- <SidebarLinkItem- key={`${link.key}-${i}-sidebarItem`}- id={`${link.key}-${i}`}- isActive={isActive}- label={link.label}- href={link.href}- onClick={link.onClick}- isExternal={link.isExternal || false}- icon={link.icon}- />- )-- if (subitems && link.subitemsKey === subitemsParentKey) {- const subItemsRender = subitems.map((y: any, i: number) => (- <SidebarLinkItem- key={`${y.key || y.as}-${i}-sidebarItem`}- id={`${y.key || y.as}-${i}`}- isSubitem={true}- label={y.label}- onClick={y.onClick}- isExternal={link.isExternal || false}- icon={link.icon}- />- ))- render = [render, ...subItemsRender]- }-- return render- })}- </ul>- )-}--interface SidebarLinkProps extends SidebarLink {- id: string- isSubitem?: boolean-}--const SidebarLinkItem = ({- id,- label,- href,- isActive,- isSubitem,- isExternal,- onClick,- icon,-}: SidebarLinkProps) => {- if (isUndefined(href)) {- let icon- if (isExternal) {- icon = <ArrowUpRight size={14} />- }-- if (label === 'Log out') {- icon = <LogOut size={14} />- }-- return (- <Menu.Item- rounded- key={id}- style={{- marginLeft: isSubitem ? '.5rem' : '0rem',- }}- active={isActive}- onClick={onClick || (() => {})}- icon={icon}- >- {isSubitem ? <p className="text-sm">{label}</p> : label}- </Menu.Item>- )- }-- return (- <Link href={href || ''} className="block" target={isExternal ? '_blank' : '_self'}>- <span className="group flex max-w-full cursor-pointer items-center space-x-2 border-default py-1 font-normal outline-none ring-foreground focus-visible:z-10 focus-visible:ring-1 group-hover:border-foreground-muted">- {isExternal && (- <span className="truncate text-sm text-foreground-lighter transition group-hover:text-foreground-light">- <ArrowUpRight size={14} />- </span>- )}- <div className="flex items-center gap-1.5 flex-shrink-0">- <span- title={label}- className={cn(- 'w-full truncate text-sm transition',- isActive ? 'text-foreground' : 'text-foreground-light group-hover:text-foreground'- )}- >- {isSubitem ? <p>{label}</p> : label}- </span>- {icon}- </div>- </span>- </Link>- )-}diff --git a/apps/studio/components/layouts/DefaultLayout.tsx b/apps/studio/components/layouts/DefaultLayout.tsxindex c9b8a705428..9361bd4dce9 100644--- a/apps/studio/components/layouts/DefaultLayout.tsx+++ b/apps/studio/components/layouts/DefaultLayout.tsx@@ -1,11 +1,14 @@import { useRouter } from 'next/router'import { PropsWithChildren } from 'react'+import { LOCAL_STORAGE_KEYS } from 'common'import { useParams } from 'common'import { AppBannerWrapper } from 'components/interfaces/App'import { AppBannerContextProvider } from 'components/interfaces/App/AppBannerWrapperContext'import { Sidebar } from 'components/interfaces/Sidebar'import { useCheckLatestDeploy } from 'hooks/use-check-latest-deploy'+import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'+import { useAppStateSnapshot } from 'state/app-state'import { SidebarProvider } from 'ui'import { LayoutHeader } from './ProjectLayout/LayoutHeader'import MobileNavigationBar from './ProjectLayout/NavigationBar/MobileNavigationBar'@@ -28,8 +31,21 @@ export interface DefaultLayoutProps {const DefaultLayout = ({ children, headerTitle }: PropsWithChildren<DefaultLayoutProps>) => {const { ref } = useParams()const router = useRouter()+ const appSnap = useAppStateSnapshot()const showProductMenu = !!ref && router.pathname !== '/project/[ref]'+ const [lastVisitedOrganization] = useLocalStorageQuery(+ LOCAL_STORAGE_KEYS.LAST_VISITED_ORGANIZATION,+ ''+ )++ const backToDashboardURL =+ appSnap.lastRouteBeforeVisitingAccountPage.length > 0+ ? appSnap.lastRouteBeforeVisitingAccountPage+ : !!lastVisitedOrganization+ ? `/org/${lastVisitedOrganization}`+ : '/organizations'+useCheckLatestDeploy()return (@@ -41,12 +57,18 @@ const DefaultLayout = ({ children, headerTitle }: PropsWithChildren<DefaultLayou<AppBannerWrapper /><div className="flex-shrink-0"><MobileNavigationBar />- <LayoutHeader showProductMenu={showProductMenu} headerTitle={headerTitle} />+ <LayoutHeader+ showProductMenu={showProductMenu}+ headerTitle={headerTitle}+ backToDashboardURL={+ router.pathname.startsWith('/account') ? backToDashboardURL : undefined+ }+ /></div>{/* Main Content Area */}<div className="flex flex-1 w-full overflow-y-hidden">- {/* Sidebar */}- <Sidebar />+ {/* Sidebar - Only show for project pages, not account pages */}+ {!router.pathname.startsWith('/account') && <Sidebar />}{/* Main Content */}<div className="flex-grow h-full overflow-y-auto">{children}</div></div>diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsxindex b0d99ecc117..fe558c231fa 100644--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx@@ -1,4 +1,5 @@import { AnimatePresence, motion } from 'framer-motion'+import { ChevronLeft } from 'lucide-react'import Link from 'next/link'import { ReactNode, useMemo, useState } from 'react'@@ -21,6 +22,7 @@ import { useHotKey } from 'hooks/ui/useHotKey'import { IS_PLATFORM } from 'lib/constants'import { useAppStateSnapshot } from 'state/app-state'import { Badge, cn } from 'ui'+import { useRouter } from 'next/router'import { BreadcrumbsView } from './BreadcrumbsView'import { FeedbackDropdown } from './FeedbackDropdown'import { HelpPopover } from './HelpPopover'@@ -52,6 +54,7 @@ interface LayoutHeaderProps {breadcrumbs?: any[]headerTitle?: stringshowProductMenu?: boolean+ backToDashboardURL?: string}const LayoutHeader = ({@@ -59,13 +62,17 @@ const LayoutHeader = ({breadcrumbs = [],headerTitle,showProductMenu,+ backToDashboardURL,}: LayoutHeaderProps) => {const { ref: projectRef, slug } = useParams()+ const router = useRouter()const { data: selectedProject } = useSelectedProjectQuery()const { data: selectedOrganization } = useSelectedOrganizationQuery()const { setMobileMenuOpen } = useAppStateSnapshot()const gitlessBranching = useIsBranching2Enabled()+ const isAccountPage = router.pathname.startsWith('/account')+const [showEditorPanel, setShowEditorPanel] = useState(false)useHotKey(() => {@@ -95,7 +102,17 @@ const LayoutHeader = ({return (<><header className={cn('flex h-12 items-center flex-shrink-0 border-b')}>- {showProductMenu && (+ {backToDashboardURL && isAccountPage && (+ <div className="flex items-center justify-center border-r flex-0 md:hidden h-full aspect-square">+ <Link+ href={backToDashboardURL}+ className="flex items-center justify-center border-none !bg-transparent rounded-md min-w-[30px] w-[30px] h-[30px] text-foreground-lighter hover:text-foreground transition-colors"+ >+ <ChevronLeft strokeWidth={1.5} size={16} />+ </Link>+ </div>+ )}+ {(showProductMenu || isAccountPage) && (<div className="flex items-center justify-center border-r flex-0 md:hidden h-full aspect-square"><buttontitle="Menu dropdown button"diff --git a/apps/studio/pages/account/audit.tsx b/apps/studio/pages/account/audit.tsxindex de0bb32bf3d..3343a22a8af 100644--- a/apps/studio/pages/account/audit.tsx+++ b/apps/studio/pages/account/audit.tsx@@ -4,14 +4,24 @@ import AppLayout from 'components/layouts/AppLayout/AppLayout'import DefaultLayout from 'components/layouts/DefaultLayout'import OrganizationLayout from 'components/layouts/OrganizationLayout'import { ScaffoldContainer } from 'components/layouts/Scaffold'+import { FormHeader } from 'components/ui/Forms/FormHeader'import type { NextPageWithLayout } from 'types'import { cn } from 'ui'const Audit: NextPageWithLayout = () => {return (- <ScaffoldContainer className={cn('[&>div]:mt-8')}>- <AuditLogs />- </ScaffoldContainer>+ <>+ <ScaffoldContainer>+ <FormHeader+ title="Audit Logs"+ description="View a detailed history of account activities and security events."+ />+ </ScaffoldContainer>++ <ScaffoldContainer className={cn('[&>div]:mt-8')} bottomPadding>+ <AuditLogs />+ </ScaffoldContainer>+ </>)}diff --git a/apps/studio/pages/account/me.tsx b/apps/studio/pages/account/me.tsxindex 21c23c2af64..105f1ea0f9c 100644--- a/apps/studio/pages/account/me.tsx+++ b/apps/studio/pages/account/me.tsx@@ -5,7 +5,6 @@ import { AnalyticsSettings } from 'components/interfaces/Account/Preferences/Anaimport { ProfileInformation } from 'components/interfaces/Account/Preferences/ProfileInformation'import { ThemeSettings } from 'components/interfaces/Account/Preferences/ThemeSettings'import AccountLayout from 'components/layouts/AccountLayout/AccountLayout'-import { AccountSettingsLayout } from 'components/layouts/AccountLayout/AccountSettingsLayout'import AppLayout from 'components/layouts/AppLayout/AppLayout'import DefaultLayout from 'components/layouts/DefaultLayout'import OrganizationLayout from 'components/layouts/OrganizationLayout'@@ -29,9 +28,7 @@ User.getLayout = (page) => (<AppLayout><DefaultLayout headerTitle="Account"><OrganizationLayout>- <AccountLayout title="Preferences">- <AccountSettingsLayout>{page}</AccountSettingsLayout>- </AccountLayout>+ <AccountLayout title="Account Settings">{page}</AccountLayout></OrganizationLayout></DefaultLayout></AppLayout>diff --git a/apps/studio/pages/account/security.tsx b/apps/studio/pages/account/security.tsxindex a1ff44e7546..8fe0a22e1de 100644--- a/apps/studio/pages/account/security.tsx+++ b/apps/studio/pages/account/security.tsx@@ -2,7 +2,6 @@ import { Smartphone } from 'lucide-react'import { TOTPFactors } from 'components/interfaces/Account'import AccountLayout from 'components/layouts/AccountLayout/AccountLayout'-import { AccountSettingsLayout } from 'components/layouts/AccountLayout/AccountSettingsLayout'import AppLayout from 'components/layouts/AppLayout/AppLayout'import DefaultLayout from 'components/layouts/DefaultLayout'import OrganizationLayout from 'components/layouts/OrganizationLayout'@@ -76,9 +75,7 @@ Security.getLayout = (page) => (<AppLayout><DefaultLayout headerTitle="Account"><OrganizationLayout>- <AccountLayout title="Security">- <AccountSettingsLayout>{page}</AccountSettingsLayout>- </AccountLayout>+ <AccountLayout title="Security">{page}</AccountLayout></OrganizationLayout></DefaultLayout></AppLayout>diff --git a/apps/studio/pages/account/tokens.tsx b/apps/studio/pages/account/tokens.tsxindex 953e898ab9e..cae0704f8f8 100644--- a/apps/studio/pages/account/tokens.tsx+++ b/apps/studio/pages/account/tokens.tsx@@ -5,7 +5,6 @@ import { AccessTokenList } from 'components/interfaces/Account/AccessTokens/Acceimport { NewAccessTokenButton } from 'components/interfaces/Account/AccessTokens/NewAccessTokenButton'import { NewTokenBanner } from 'components/interfaces/Account/AccessTokens/NewTokenBanner'import AccountLayout from 'components/layouts/AccountLayout/AccountLayout'-import { AccountSettingsLayout } from 'components/layouts/AccountLayout/AccountSettingsLayout'import AppLayout from 'components/layouts/AppLayout/AppLayout'import DefaultLayout from 'components/layouts/DefaultLayout'import OrganizationLayout from 'components/layouts/OrganizationLayout'@@ -82,9 +81,7 @@ UserAccessTokens.getLayout = (page) => (<AppLayout><DefaultLayout headerTitle="Account"><OrganizationLayout>- <AccountLayout title="Access Tokens">- <AccountSettingsLayout>{page}</AccountSettingsLayout>- </AccountLayout>+ <AccountLayout title="Access Tokens">{page}</AccountLayout></OrganizationLayout></DefaultLayout></AppLayout>