The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Feat: remember last visited route in logs FE-1418 (#33486)
Jordi Enricb6e126c3311d
diff --git a/.github/workflows/studio-e2e-tests.yml b/.github/workflows/studio-e2e-tests.ymlindex ec79edae963..163c42dbe01 100644--- a/.github/workflows/studio-e2e-tests.yml+++ b/.github/workflows/studio-e2e-tests.yml@@ -35,6 +35,8 @@ jobs:node-version-file: '.nvmrc'cache: 'pnpm'- uses: supabase/setup-cli@v1+ with:+ version: latest- name: Install dependenciesrun: pnpm i- name: Install Playwright Browsersdiff --git a/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx b/apps/studio/components/layouts/LogsLayout/LogsLayout.tsxindex ad231063ca4..fe549556727 100644--- a/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx+++ b/apps/studio/components/layouts/LogsLayout/LogsLayout.tsx@@ -1,9 +1,12 @@import { PermissionAction } from '@supabase/shared-types/out/constants'-import { PropsWithChildren } from 'react'+import { useRouter } from 'next/router'+import { PropsWithChildren, useEffect } from 'react'import NoPermission from 'components/ui/NoPermission'import { useAsyncCheckProjectPermissions } from 'hooks/misc/useCheckPermissions'+import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'import { withAuth } from 'hooks/misc/withAuth'+import { LOCAL_STORAGE_KEYS } from 'lib/constants'import ProjectLayout from '../ProjectLayout/ProjectLayout'import { LogsSidebarMenuV2 } from './LogsSidebarMenuV2'@@ -17,16 +20,31 @@ const LogsLayout = ({ title, children }: PropsWithChildren<LogsLayoutProps>) =>'logflare')- if (isLoading) {- return <ProjectLayout isLoading></ProjectLayout>- }+ const router = useRouter()+ const [_, setLastLogsPage] = useLocalStorageQuery(+ LOCAL_STORAGE_KEYS.LAST_VISITED_LOGS_PAGE,+ router.pathname.split('/').pop()+ )++ useEffect(() => {+ if (router.pathname.includes('/logs/')) {+ const path = router.pathname.split('/').pop()+ setLastLogsPage(path)+ }+ }, [router, setLastLogsPage])++ if (!canUseLogsExplorer) {+ if (isLoading) {+ return <ProjectLayout isLoading></ProjectLayout>+ }- if (!isLoading && !canUseLogsExplorer) {- return (- <ProjectLayout>- <NoPermission isFullPage resourceText="access your project's logs" />- </ProjectLayout>- )+ if (!isLoading && !canUseLogsExplorer) {+ return (+ <ProjectLayout>+ <NoPermission isFullPage resourceText="access your project's logs" />+ </ProjectLayout>+ )+ }}return (diff --git a/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsx b/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsxindex 7bc1a15dc3d..161ddb886a8 100644--- a/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsx+++ b/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsx@@ -1,4 +1,9 @@import { PermissionAction } from '@supabase/shared-types/out/constants'+import { ChevronRight, FilePlus, Plus } from 'lucide-react'+import Link from 'next/link'+import { useRouter } from 'next/router'+import { useState } from 'react'+import { IS_PLATFORM, useParams } from 'common'import { CreateWarehouseCollectionModal } from 'components/interfaces/DataWarehouse/CreateWarehouseCollection'import { WarehouseMenuItem } from 'components/interfaces/DataWarehouse/WarehouseMenuItem'@@ -10,10 +15,6 @@ import { useContentQuery } from 'data/content/content-query'import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'import { useFlag } from 'hooks/ui/useFlag'-import { ChevronRight, FilePlus, Plus } from 'lucide-react'-import Link from 'next/link'-import { useRouter } from 'next/router'-import { useState } from 'react'import {Button,Collapsible_Shadcn_,diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsxindex d55afbd075c..16eedb4530e 100644--- a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx+++ b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx@@ -133,7 +133,7 @@ export const generateOtherRoutes = (ref?: string, project?: Project): Route[] =>key: 'logs',label: 'Logs',icon: <List size={ICON_SIZE} strokeWidth={ICON_STROKE_WIDTH} />,- link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/logs/explorer`),+ link: ref && (isProjectBuilding ? buildingUrl : `/project/${ref}/logs`),},{key: 'api',diff --git a/apps/studio/lib/constants/index.ts b/apps/studio/lib/constants/index.tsindex de927eebe22..022ca4c31fb 100644--- a/apps/studio/lib/constants/index.ts+++ b/apps/studio/lib/constants/index.ts@@ -93,6 +93,9 @@ export const LOCAL_STORAGE_KEYS = {// api keys view switcher for new and legacy api keysAPI_KEYS_VIEW: (ref: string) => `supabase-api-keys-view-${ref}`,++ // last visited logs page+ LAST_VISITED_LOGS_PAGE: 'supabase-last-visited-logs-page',}export const OPT_IN_TAGS = {diff --git a/apps/studio/pages/project/[ref]/logs/index.tsx b/apps/studio/pages/project/[ref]/logs/index.tsxnew file mode 100644index 00000000000..cfb40aea392--- /dev/null+++ b/apps/studio/pages/project/[ref]/logs/index.tsx@@ -0,0 +1,33 @@+import { useRouter } from 'next/router'+import { useEffect } from 'react'++import { useParams } from 'common'+import DefaultLayout from 'components/layouts/DefaultLayout'+import LogsLayout from 'components/layouts/LogsLayout/LogsLayout'+import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'+import { LOCAL_STORAGE_KEYS } from 'lib/constants'+import type { NextPageWithLayout } from 'types'++export const LogPage: NextPageWithLayout = () => {+ const router = useRouter()+ const { ref } = useParams()++ const [lastVisitedLogsPage] = useLocalStorageQuery(+ LOCAL_STORAGE_KEYS.LAST_VISITED_LOGS_PAGE,+ 'explorer'+ )++ useEffect(() => {+ router.replace(`/project/${ref}/logs/${lastVisitedLogsPage}`)+ }, [router, lastVisitedLogsPage, ref])++ return null+}++LogPage.getLayout = (page) => (+ <DefaultLayout>+ <LogsLayout>{page}</LogsLayout>+ </DefaultLayout>+)++export default LogPagediff --git a/package.json b/package.jsonindex 483cc362ea7..7b1d9ff7a85 100644--- a/package.json+++ b/package.json@@ -15,7 +15,7 @@"dev": "turbo run dev --parallel","dev:reference": "turbo run dev --filter=reference --parallel","dev:studio": "turbo run dev --filter=studio --parallel",- "dev:studio-local": "pnpm run --dir tests/local-studio-tests codegen:setup",+ "dev:studio-local": "pnpm run --dir tests/studio-tests codegen:setup","dev:docs": "turbo run dev --filter=docs --parallel","dev:www": "turbo run dev --filter=www --parallel","dev:design-system": "turbo run dev --filter=design-system --parallel",diff --git a/tests/studio-tests/package.json b/tests/studio-tests/package.jsonindex e15ee220a07..b96c92fd6aa 100644--- a/tests/studio-tests/package.json+++ b/tests/studio-tests/package.json@@ -10,6 +10,8 @@"test:local": "pnpm env:setup && export ENV=local && export PROJECT_REF=default && playwright test","posttest:local": "supabase stop --no-backup","test:staging": "export ENV=staging && playwright test",+ "codegen:setup": "pnpm env:setup && NODE_ENV=test pnpm --prefix ../../apps/studio dev",+ "codegen": "playwright codegen http://localhost:8082/project/default","clean": "rimraf node_modules"},"keywords": [],