Skip to content

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

Feat/collapsible nav bar (#21550)

Jonathan Summers-Muireb5039c5e63d
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
index cfe9255be01..fdfc6f1d65a 100644
--- a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.tsx
@@ -1,10 +1,12 @@
-import * as Tooltip from '@radix-ui/react-tooltip'
import { useParams } from 'common'
+import { useFlag, useIsFeatureEnabled } from 'hooks'
+import { Home, User } from 'icons'
import { isUndefined } from 'lodash'
-import { FlaskConical } from 'lucide-react'
+import { Command, FileText, FlaskConical, Search, Settings } from 'lucide-react'
import { useTheme } from 'next-themes'
import Link from 'next/link'
import { useRouter } from 'next/router'
+import { useState } from 'react'
import {
Button,
DropdownMenu,
@@ -15,31 +17,29 @@ import {
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuSeparator,
+ DropdownMenuSub,
DropdownMenuTrigger,
- IconCommand,
- IconFileText,
- IconHome,
- IconSearch,
- IconSettings,
- IconUser,
+ Separator,
Theme,
+ cn,
themes,
useCommandMenu,
} from 'ui'
import { useIsAPIDocsSidePanelEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
-import { useFlag, useIsFeatureEnabled } from 'hooks'
import { IS_PLATFORM } from 'lib/constants'
import { detectOS } from 'lib/helpers'
+import { useProfile } from 'lib/profile'
import { useAppStateSnapshot } from 'state/app-state'
import { useProjectContext } from '../ProjectContext'
import {
generateOtherRoutes,
generateProductRoutes,
+ generateSettingsRoutes,
generateToolRoutes,
} from './NavigationBar.utils'
-import NavigationIconButton from './NavigationIconButton'
-import { Home } from 'icons'
+import { NavigationIconButton } from './NavigationIconButton'
+import NavigationIconLink from './NavigationIconLink'
export const ICON_SIZE = 20
export const ICON_STROKE_WIDTH = 1.5
@@ -47,14 +47,16 @@ export const ICON_STROKE_WIDTH = 1.5
const NavigationBar = () => {
const os = detectOS()
const router = useRouter()
- const snap = useAppStateSnapshot()
+ const { profile } = useProfile()
+ const { project } = useProjectContext()
const { theme, setTheme } = useTheme()
const { ref: projectRef } = useParams()
const { setIsOpen } = useCommandMenu()
+ const snap = useAppStateSnapshot()
- const { project } = useProjectContext()
const navLayoutV2 = useFlag('navigationLayoutV2')
const isNewAPIDocsEnabled = useIsAPIDocsSidePanelEnabled()
+ const [userDropdownOpen, setUserDropdownOpenState] = useState(false)
const {
projectAuthAll: authEnabled,
@@ -76,147 +78,187 @@ const NavigationBar = () => {
storage: storageEnabled,
realtime: realtimeEnabled,
})
+
const otherRoutes = generateOtherRoutes(projectRef, project)
+ const settingsRoutes = generateSettingsRoutes(projectRef, project)
return (
- <div
- className={[
- 'hide-scrollbar flex w-14 flex-col justify-between p-2 overflow-y-auto',
- 'border-r bg-studio border-default',
- ].join(' ')}
- >
- <ul className="flex flex-col space-y-2">
- {(!navLayoutV2 || !IS_PLATFORM) && (
- <Link href={IS_PLATFORM ? '/projects' : `/project/${projectRef}`} className="block">
- <img
- src={`${router.basePath}/img/supabase-logo.svg`}
- alt="Supabase"
- className="mx-auto h-[40px] w-6 cursor-pointer rounded"
- />
- </Link>
+ <div className="w-14 h-full flex flex-col">
+ <nav
+ data-state={snap.navigationPanelOpen ? 'expanded' : 'collapsed'}
+ className={cn(
+ 'group py-2 z-10 h-full w-14 data-[state=expanded]:w-[13rem]',
+ 'border-r bg-studio border-default data-[state=expanded]:shadow-xl',
+ 'transition-width duration-200',
+ 'hide-scrollbar flex flex-col justify-between overflow-y-auto'
)}
- <NavigationIconButton
- isActive={isUndefined(activeRoute) && !isUndefined(router.query.ref)}
- route={{
- key: 'HOME',
- label: 'Home',
- icon: <Home size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
- link: `/project/${projectRef}`,
- }}
- />
- <div className="bg-border h-px w-full" />
- {toolRoutes.map((route) => (
- <NavigationIconButton
- key={route.key}
- route={route}
- isActive={activeRoute === route.key}
+ onMouseEnter={() => snap.setNavigationPanelOpen(true)}
+ onMouseLeave={() => {
+ if (!userDropdownOpen) snap.setNavigationPanelOpen(false)
+ }}
+ >
+ <ul className="flex flex-col gap-0 justify-start px-2">
+ {(!navLayoutV2 || !IS_PLATFORM) && (
+ <Link
+ href={IS_PLATFORM ? '/projects' : `/project/${projectRef}`}
+ className="mx-2 flex items-center h-[40px]"
+ >
+ <img
+ alt="Supabase"
+ src={`${router.basePath}/img/supabase-logo.svg`}
+ className="absolute h-[40px] w-6 cursor-pointer rounded"
+ />
+ </Link>
+ )}
+ <NavigationIconLink
+ isActive={isUndefined(activeRoute) && !isUndefined(router.query.ref)}
+ route={{
+ key: 'HOME',
+ label: 'Home',
+ icon: <Home size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
+ link: `/project/${projectRef}`,
+ }}
/>
- ))}
- <div className="bg-border h-px w-full"></div>
+ <Separator className="my-1 bg-border-muted" />
+ {toolRoutes.map((route) => (
+ <NavigationIconLink
+ key={route.key}
+ route={route}
+ isActive={activeRoute === route.key}
+ />
+ ))}
+ <Separator className="my-1 bg-border-muted" />
+ {productRoutes.map((route) => (
+ <NavigationIconLink
+ key={route.key}
+ route={route}
+ isActive={activeRoute === route.key}
+ />
+ ))}
+ <Separator className="my-1 bg-border-muted" />
+ {otherRoutes.map((route) => {
+ if (route.key === 'api' && isNewAPIDocsEnabled) {
+ return (
+ <NavigationIconButton
+ key={route.key}
+ onClick={() => snap.setShowProjectApiDocs(true)}
+ icon={<FileText size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />}
+ >
+ Project API
+ </NavigationIconButton>
+ )
+ } else {
+ return (
+ <NavigationIconLink
+ key={route.key}
+ route={route}
+ isActive={activeRoute === route.key}
+ />
+ )
+ }
+ })}
+ </ul>
+
+ <ul className="flex flex-col px-2">
+ {settingsRoutes.map((route) => (
+ <NavigationIconLink
+ key={route.key}
+ route={route}
+ isActive={activeRoute === route.key}
+ />
+ ))}
- {productRoutes.map((route) => (
- <NavigationIconButton
- key={route.key}
- route={route}
- isActive={activeRoute === route.key}
- />
- ))}
- <div className="h-px w-full bg-border"></div>
- {otherRoutes.map((route) => {
- if (route.key === 'api' && isNewAPIDocsEnabled) {
- return (
- <Tooltip.Root delayDuration={0} key={route.key}>
- <Tooltip.Trigger asChild>
- <Button
- type="text"
- size="tiny"
- onClick={() => snap.setShowProjectApiDocs(true)}
- className="border-none group"
- >
- <div className="py-[7px]">
- <IconFileText
- size={18}
- strokeWidth={2}
- className="transition text-foreground-lighter group-hover:text-foreground"
- />
- </div>
- </Button>
- </Tooltip.Trigger>
- <Tooltip.Portal>
- <Tooltip.Content side="right">
- <Tooltip.Arrow className="radix-tooltip-arrow" />
- <div
- className={[
- 'bg-alternative shadow-lg shadow-background-surface-100 py-1.5 px-3 rounded leading-none', // background
- 'border border-default', //border
- ].join(' ')}
- >
- <span className="text-foreground text-xs">Project API Docs</span>
- </div>
- </Tooltip.Content>
- </Tooltip.Portal>
- </Tooltip.Root>
- )
- } else {
- return (
- <NavigationIconButton
- key={route.key}
- route={route}
- isActive={activeRoute === route.key}
- />
- )
- }
- })}
- </ul>
- {!navLayoutV2 && (
- <ul className="flex flex-col space-y-4 items-center">
{IS_PLATFORM && (
- <Tooltip.Root delayDuration={0}>
- <Tooltip.Trigger asChild>
- <Button
- type="text"
- size="tiny"
- onClick={() => setIsOpen(true)}
- className="border-none"
+ <NavigationIconButton
+ size="tiny"
+ onClick={() => setIsOpen(true)}
+ type="text"
+ icon={<Search size={ICON_SIZE} strokeWidth={2} />}
+ rightText={
+ <div
+ className={cn(
+ 'flex items-center gap-1',
+ 'h-6',
+ 'py-1.5 px-2',
+ 'bg-surface-100',
+ 'text-foreground-lighter',
+ 'border border-default rounded-md',
+ 'shadow-xs shadow-background-surface-100',
+ 'leading-none'
+ )}
>
- <div className="py-1">
- <IconSearch size={18} strokeWidth={2} className="text-foreground-lighter" />
- </div>
- </Button>
- </Tooltip.Trigger>
- <Tooltip.Portal>
- <Tooltip.Content side="right" sideOffset={5}>
- <Tooltip.Arrow className="radix-tooltip-arrow" />
- <div
- className={[
- 'bg-alternative shadow-lg shadow-background-surface-100 py-1.5 px-3 rounded leading-none', // background
- 'border border-default', // border
- 'flex items-center gap-1', // layout
- ].join(' ')}
- >
- {os === 'macos' ? (
- <IconCommand size={11.5} strokeWidth={1.5} className="text-foreground" />
- ) : (
- <p className="text-xs">CTRL</p>
- )}
- <p className="text-xs">K</p>
- </div>
- </Tooltip.Content>
- </Tooltip.Portal>
- </Tooltip.Root>
+ {os === 'macos' || true ? ( // todo: issue with `os` and hydration fail
+ <Command size={11.5} strokeWidth={1.5} />
+ ) : (
+ <p className="text-xs">CTRL</p>
+ )}
+ <p className="text-xs">K</p>
+ </div>
+ }
+ >
+ Search
+ </NavigationIconButton>
)}
- <DropdownMenu>
+
+ <DropdownMenu
+ open={userDropdownOpen}
+ onOpenChange={(open: boolean) => {
+ console.log('open', open)
+ setUserDropdownOpenState(open)
+ if (open === false) {
+ snap.setNavigationPanelOpen(false)
+ }
+ }}
+ >
<DropdownMenuTrigger asChild>
- <Button type="text" size="tiny" className="py-1 h-10 border-none">
- <IconUser size={18} strokeWidth={2} className="text-foreground-lighter" />
+ <Button
+ type="text"
+ size="tiny"
+ className={cn(
+ 'mt-3',
+ 'h-10 [&>span]:relative [&>span]:flex [&>span]:w-full [&>span]:h-full p-0'
+ )}
+ block
+ >
+ <div className="relative w-full h-full flex items-center justify-center">
+ <figure className="absolute left-1.5 min-h-6 min-w-6 bg-foreground rounded-full flex items-center justify-center">
+ <User
+ size={ICON_SIZE - 2}
+ strokeWidth={ICON_STROKE_WIDTH}
+ className="text-background"
+ />
+ </figure>
+ <span
+ className={cn(
+ 'w-[8rem] flex flex-col items-start text-sm truncate',
+ 'absolute left-7 group-data-[state=expanded]:left-10',
+ 'group-data-[state=collapsed]:opacity-0 group-data-[state=expanded]:opacity-100',
+ 'transition-all'
+ )}
+ >
+ <span
+ title={profile?.username}
+ className="w-full text-left text-foreground truncate"
+ >
+ {profile?.username}
+ </span>
+ <span
+ title={profile?.primary_email}
+ className="w-full text-left text-foreground-light text-xs truncate"
+ >
+ {profile?.primary_email}
+ </span>
+ </span>
+ </div>
</Button>
</DropdownMenuTrigger>
- <DropdownMenuContent side="right" align="start">
+ <DropdownMenuContent side="top" align="start">
{IS_PLATFORM && (
<>
+ <DropdownMenuSub>{}</DropdownMenuSub>
<DropdownMenuItem key="header" className="space-x-2" asChild>
<Link href="/account/me">
- <IconSettings size={14} strokeWidth={1.5} />
+ <Settings size={14} strokeWidth={1.5} />
<p>Account preferences</p>
</Link>
</DropdownMenuItem>
@@ -254,7 +296,7 @@ const NavigationBar = () => {
</DropdownMenuContent>
</DropdownMenu>
</ul>
- )}
+ </nav>
</div>
)
}
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
index 79d0bf961ae..f584fcd1a00 100644
--- a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
@@ -7,13 +7,12 @@ import {
EdgeFunctions,
Realtime,
Reports,
- Settings,
SqlEditor,
Storage,
TableEditor,
} from 'icons'
import { ICON_SIZE, ICON_STROKE_WIDTH } from './NavigationBar'
-import { FileText, List } from 'lucide-react'
+import { Settings, FileText, List } from 'lucide-react'
export const generateToolRoutes = (ref?: string, project?: Project): Route[] => {
const isProjectBuilding = project?.status === PROJECT_STATUS.COMING_UP
@@ -126,6 +125,11 @@ export const generateOtherRoutes = (ref?: string, project?: Project): Route[] =>
icon: <FileText size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,
link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/api`),
},
+ ]
+}
+
+export const generateSettingsRoutes = (ref?: string, project?: Project): Route[] => {
+ return [
...(IS_PLATFORM
? [
{
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconButton.tsx b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconButton.tsx
index d9d466bb5cc..f859cb33735 100644
--- a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconButton.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconButton.tsx
@@ -1,50 +1,52 @@
-import * as Tooltip from '@radix-ui/react-tooltip'
-import Link from 'next/link'
+import { Button, cn } from 'ui'
+import { ComponentProps, ReactNode, forwardRef } from 'react'
-import ConditionalWrap from 'components/ui/ConditionalWrap'
-import { Route } from 'components/ui/ui.types'
-
-interface NavigationIconButtonProps {
- route: Route
- isActive?: boolean
-}
-
-const NavigationIconButton = ({ route, isActive = false }: NavigationIconButtonProps) => {
+export const NavigationIconButton = forwardRef<
+ HTMLButtonElement,
+ Omit<
+ ComponentProps<typeof Button>,
+ // omit other icon props to avoid confusion
+ // using `icon` instead as there is only 1 use case for this component
+ 'iconRight' | 'iconLeft'
+ > & {
+ rightText?: ReactNode
+ }
+>(({ icon, rightText, ...props }, ref) => {
return (
- <Tooltip.Root delayDuration={0}>
- <Tooltip.Trigger>
- <ConditionalWrap
- condition={route.link !== undefined}
- wrap={(children) => <Link href={route.link!}>{children}</Link>}
+ <Button
+ ref={ref}
+ type="text"
+ size="tiny"
+ {...props}
+ className={cn(
+ 'h-10 [&>span]:relative [&>span]:items-center [&>span]:gap-3 [&>span]:flex [&>span]:w-full [&>span]:h-full p-0',
+ props.className
+ )}
+ >
+ <div className="absolute left-2 text-foreground-lighter">{icon}</div>
+ <span
+ className={cn(
+ 'absolute left-7 group-data-[state=expanded]:left-10',
+ 'opacity-0 group-data-[state=expanded]:opacity-100',
+ 'w-[10rem] text-sm flex flex-col items-center',
+ 'transition-all'
+ )}
+ >
+ <span className="w-full text-left text-foreground-light truncate">{props.children}</span>
+ </span>
+ {rightText && (
+ <div
+ className={cn(
+ 'absolute right-2 flex items-center',
+ 'opacity-0 transition-all',
+ 'group-data-[state=expanded]:opacity-100 '
+ )}
>
- <span
- className={[
- 'transition-colors duration-200',
- 'flex items-center justify-center h-10 w-10 rounded', // Layout
- 'text-foreground-lighter hover:text-foreground ', // Dark mode
- 'bg-studio hover:bg-surface-200', // Light mode
- `${isActive ? '!bg-surface-300 !text-foreground shadow-sm' : ''}`,
- ].join(' ')}
- >
- {route.icon}
- </span>
- </ConditionalWrap>
- </Tooltip.Trigger>
- <Tooltip.Portal>
- <Tooltip.Content side="right" sideOffset={5}>
- <Tooltip.Arrow className="radix-tooltip-arrow" />
- <div
- className={[
- 'bg-alternative shadow-lg shadow-background-surface-100 py-1.5 px-3 rounded leading-none', // background
- 'border border-default', //border
- ].join(' ')}
- >
- <span className="text-foreground text-xs">{route.label}</span>
- </div>
- </Tooltip.Content>
- </Tooltip.Portal>
- </Tooltip.Root>
+ {rightText}
+ </div>
+ )}
+ </Button>
)
-}
+})
-export default NavigationIconButton
+NavigationIconButton.displayName = 'NavigationIconButton'
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconLink.tsx b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconLink.tsx
new file mode 100644
index 00000000000..d57e16056f3
--- /dev/null
+++ b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconLink.tsx
@@ -0,0 +1,67 @@
+import Link from 'next/link'
+import { AnchorHTMLAttributes, forwardRef } from 'react'
+import { cn } from 'ui'
+
+import { Route } from 'components/ui/ui.types'
+import { useAppStateSnapshot } from 'state/app-state'
+
+interface NavigationIconButtonProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
+ route: Route
+ isActive?: boolean
+}
+
+const NavigationIconLink = forwardRef<HTMLAnchorElement, NavigationIconButtonProps>(
+ ({ route, isActive = false, ...props }, ref) => {
+ const snap = useAppStateSnapshot()
+
+ const iconClasses = [
+ 'absolute left-0 top-0 flex rounded items-center h-10 w-10 items-center justify-center', // Layout
+ ]
+
+ const classes = [
+ 'relative',
+ 'h-10 w-10 group-data-[state=expanded]:h-10 group-data-[state=expanded]:w-full',
+ 'transition-all duration-200',
+ 'flex items-center rounded',
+ 'group-data-[state=collapsed]:justify-center',
+ 'group-data-[state=expanded]:-space-x-2',
+ 'text-foreground-lighter hover:text-foreground ',
+ 'hover:bg-surface-200',
+ `${isActive ? '!bg-selection !text-foreground shadow-sm' : ''}`,
+ 'group/item',
+ ]
+
+ return route.link !== undefined ? (
+ <Link
+ role="button"
+ aria-current={isActive}
+ ref={ref}
+ href={route.link!}
+ {...props}
+ className={cn(classes, props.className)}
+ >
+ <span className={cn(...iconClasses)} {...props}>
+ {route.icon}
+ </span>
+ <span
+ aria-hidden={snap.navigationPanelOpen || undefined}
+ className={cn(
+ 'min-w-[128px] text-sm text-foreground-light',
+ 'group-hover/item:text-foreground',
+ 'group-aria-current/item:text-foreground',
+ 'absolute left-7 group-data-[state=expanded]:left-12',
+ 'opacity-0 group-data-[state=expanded]:opacity-100',
+ 'transition-all'
+ )}
+ >
+ {route.label}
+ </span>
+ </Link>
+ ) : (
+ <span ref={ref} {...props}></span>
+ )
+ }
+)
+
+NavigationIconLink.displayName = 'NavigationIconLink'
+export default NavigationIconLink
diff --git a/apps/studio/data/auth/auth-config-query.ts b/apps/studio/data/auth/auth-config-query.ts
index 1454802abcb..293b47b039a 100644
--- a/apps/studio/data/auth/auth-config-query.ts
+++ b/apps/studio/data/auth/auth-config-query.ts
@@ -1,6 +1,6 @@
import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'
import { components } from 'data/api'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import { useCallback } from 'react'
import { ResponseError } from 'types'
import { authKeys } from './keys'
@@ -15,19 +15,14 @@ export async function getProjectAuthConfig(
{ projectRef }: AuthConfigVariables,
signal?: AbortSignal
) {
- if (!projectRef) {
- throw new Error('projectRef is required')
- }
+ if (!projectRef) throw new Error('projectRef is required')
const { data, error } = await get('/platform/auth/{ref}/config', {
- params: {
- path: { ref: projectRef },
- },
+ params: { path: { ref: projectRef } },
signal,
})
- if (error) throw error
-
+ if (error) throw handleError(error)
return data
}
diff --git a/apps/studio/data/auth/users-query.ts b/apps/studio/data/auth/users-query.ts
index 3ec8923de2a..a4fcc4123c4 100644
--- a/apps/studio/data/auth/users-query.ts
+++ b/apps/studio/data/auth/users-query.ts
@@ -1,5 +1,5 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import { ResponseError } from 'types'
import { authKeys } from './keys'
import { components } from 'data/api'
@@ -37,7 +37,7 @@ export async function getUsers(
signal,
})
- if (error) throw error
+ if (error) throw handleError(error)
return data
}
diff --git a/apps/studio/data/banned-ips/banned-ips-query.ts b/apps/studio/data/banned-ips/banned-ips-query.ts
index 5dd4b7c6f88..66e914ee14c 100644
--- a/apps/studio/data/banned-ips/banned-ips-query.ts
+++ b/apps/studio/data/banned-ips/banned-ips-query.ts
@@ -1,5 +1,5 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import { ResponseError } from 'types'
import { BannedIPKeys } from './keys'
@@ -14,16 +14,11 @@ export async function getBannedIPs({ projectRef }: BannedIPVariables, signal?: A
if (!projectRef) throw new Error('projectRef is required')
const { data, error } = await post(`/v1/projects/{ref}/network-bans/retrieve`, {
- params: {
- path: { ref: projectRef },
- },
+ params: { path: { ref: projectRef } },
signal,
})
- if (error) {
- throw error
- }
-
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/branches/branches-query.ts b/apps/studio/data/branches/branches-query.ts
index 77940400bfb..91a95c3d753 100644
--- a/apps/studio/data/branches/branches-query.ts
+++ b/apps/studio/data/branches/branches-query.ts
@@ -1,6 +1,6 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
import { components } from 'data/api'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import { ResponseError } from 'types'
import { branchKeys } from './keys'
@@ -22,7 +22,7 @@ export async function getBranches({ projectRef }: BranchesVariables, signal?: Ab
if ((error as ResponseError).message === 'Preview branching is not enabled for this project.') {
return []
} else {
- throw error
+ throw handleError(error)
}
}
return data
diff --git a/apps/studio/data/custom-domains/custom-domains-query.ts b/apps/studio/data/custom-domains/custom-domains-query.ts
index e9e8df0f208..4a4ea190cbc 100644
--- a/apps/studio/data/custom-domains/custom-domains-query.ts
+++ b/apps/studio/data/custom-domains/custom-domains-query.ts
@@ -1,6 +1,6 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import { IS_PLATFORM } from 'lib/constants'
import { ResponseError } from 'types'
import { customDomainKeys } from './keys'
@@ -64,16 +64,10 @@ export async function getCustomDomains(
{ projectRef }: CustomDomainsVariables,
signal?: AbortSignal
) {
- if (!projectRef) {
- throw new Error('projectRef is required')
- }
+ if (!projectRef) throw new Error('projectRef is required')
const { data, error: _error } = await get('/v1/projects/{ref}/custom-hostname', {
- params: {
- path: {
- ref: projectRef,
- },
- },
+ params: { path: { ref: projectRef } },
signal,
})
@@ -99,7 +93,7 @@ export async function getCustomDomains(
} as const
}
- throw error
+ handleError(error)
}
return { customDomain: data.data.result as CustomDomainResponse, status: data.status }
diff --git a/apps/studio/data/organizations/organization-by-fly-organization-id-mutation.ts b/apps/studio/data/organizations/organization-by-fly-organization-id-mutation.ts
index 1d4e29069fc..e8525103870 100644
--- a/apps/studio/data/organizations/organization-by-fly-organization-id-mutation.ts
+++ b/apps/studio/data/organizations/organization-by-fly-organization-id-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import toast from 'react-hot-toast'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import { ResponseError } from 'types'
export type OrganizationByFlyOrgIdVariables = {
@@ -17,7 +17,7 @@ export async function getOrganizationByFlyOrgId({
const { data, error } = await get('/platform/organizations/fly/{fly_organization_id}', {
params: { path: { fly_organization_id: flyOrganizationId } },
})
- if (error) throw error
+ if (error) throw handleError(error)
return data as { slug: string }
}
diff --git a/apps/studio/data/projects/project-by-fly-extension-id-mutation.ts b/apps/studio/data/projects/project-by-fly-extension-id-mutation.ts
index b12f557aa1d..fc6b3e32740 100644
--- a/apps/studio/data/projects/project-by-fly-extension-id-mutation.ts
+++ b/apps/studio/data/projects/project-by-fly-extension-id-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
-
-import { get } from 'data/fetchers'
import toast from 'react-hot-toast'
+
+import { get, handleError } from 'data/fetchers'
import { ResponseError } from 'types'
export type ProjectByFlyExtensionIdVariables = {
@@ -17,7 +17,7 @@ export async function getProjectByFlyExtensionId({
const { data, error } = await get('/platform/projects/fly/{fly_extension_id}', {
params: { path: { fly_extension_id: flyExtensionId } },
})
- if (error) throw error
+ if (error) throw handleError(error)
return data as { ref: string }
}
diff --git a/apps/studio/state/app-state.ts b/apps/studio/state/app-state.ts
index e06e54f0e4d..cd501a8cdd0 100644
--- a/apps/studio/state/app-state.ts
+++ b/apps/studio/state/app-state.ts
@@ -58,6 +58,11 @@ export const appState = proxy({
setShowAiSettingsModal: (value: boolean) => {
appState.showAiSettingsModal = value
},
+
+ navigationPanelOpen: false,
+ setNavigationPanelOpen: (value: boolean) => {
+ appState.navigationPanelOpen = value
+ },
})
export const getAppStateSnapshot = () => snapshot(appState)