Skip to content

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

Set last visited page when going to preferences from explorer (#50691)

Joshen Lim47592ace0f3b
diff --git a/apps/studio/components/layouts/ExplorerLayout/ExplorerNavHome.tsx b/apps/studio/components/layouts/ExplorerLayout/ExplorerNavHome.tsx
index d0a66e47622..c5c44e7cdb0 100644
--- a/apps/studio/components/layouts/ExplorerLayout/ExplorerNavHome.tsx
+++ b/apps/studio/components/layouts/ExplorerLayout/ExplorerNavHome.tsx
@@ -2,6 +2,7 @@ import { useParams } from 'common'
import { motion } from 'framer-motion'
import { ChevronRight, Plus, Settings, SquareCode } from 'lucide-react'
import Link from 'next/link'
+import { useRouter } from 'next/router'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
import {
@@ -16,6 +17,7 @@ import { useCreateChat, useCreateQuery } from '@/components/interfaces/Explorer/
import { useContentCountQuery } from '@/data/content/content-count-query'
import { useNotebooksInfiniteQuery } from '@/data/content/notebooks/notebooks-infinite-query'
import { useAiAssistantChatList } from '@/state/ai-assistant-state'
+import { useAppStateSnapshot } from '@/state/app-state'
import { createTabId, useTabsStateSnapshot } from '@/state/tabs'
export const ExplorerNavHome = ({
@@ -23,9 +25,12 @@ export const ExplorerNavHome = ({
}: {
onSelectSection: (section: ExplorerResourceType) => void
}) => {
+ const router = useRouter()
const { ref } = useParams()
- const { openChat } = useCreateChat()
const tabs = useTabsStateSnapshot()
+ const appStateSnapshot = useAppStateSnapshot()
+
+ const { openChat } = useCreateChat()
const { createQuery } = useCreateQuery()
const { data: notebooksData } = useNotebooksInfiniteQuery({ projectRef: ref, limit: 100 })
@@ -138,7 +143,11 @@ export const ExplorerNavHome = ({
</div>
<div className="shrink-0 border-t border-default p-3">
- <Link href="/account/me#dashboard" className={rowClassName(false)}>
+ <Link
+ href="/account/me#dashboard"
+ className={rowClassName(false)}
+ onClick={() => appStateSnapshot.setLastRouteBeforeVisitingAccountPage(router.asPath)}
+ >
<Settings size={14} className="shrink-0" />
<span className="flex-1 text-left">Preferences</span>
</Link>
diff --git a/apps/studio/pages/account/me.tsx b/apps/studio/pages/account/me.tsx
index 0e24daaa36f..237292fb988 100644
--- a/apps/studio/pages/account/me.tsx
+++ b/apps/studio/pages/account/me.tsx
@@ -1,3 +1,5 @@
+import { useRouter } from 'next/router'
+import { useEffect } from 'react'
import { Card, CardContent, CardFooter } from 'ui'
import { PageContainer } from 'ui-patterns/PageContainer'
import {
@@ -61,6 +63,8 @@ const PreferencesPageHeader = ({ description }: { description: string }) => (
)
const PlatformPreferences = () => {
+ const router = useRouter()
+
const { profileShowInformation, profileShowAnalyticsAndMarketing, profileShowAccountDeletion } =
useIsFeatureEnabled([
'profile:show_information',
@@ -69,6 +73,13 @@ const PlatformPreferences = () => {
])
const { error, isLoading, isError } = useProfile()
+ useEffect(() => {
+ const hash = router.asPath.split('#')[1]
+ if (isLoading || !hash) return
+
+ document.getElementById(hash)?.scrollIntoView({ block: 'start' })
+ }, [isLoading, router.asPath])
+
return (
<>
<PreferencesPageHeader description="Manage your account profile, connections, and dashboard experience." />