Skip to content

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

feat: Refactor logs section sidebar navigation

TzeYiingaec9b00205e7
diff --git a/studio/components/interfaces/Settings/Logs/LogsNavigation.tsx b/studio/components/interfaces/Settings/Logs/LogsNavigation.tsx
deleted file mode 100644
index 8662d71e792..00000000000
--- a/studio/components/interfaces/Settings/Logs/LogsNavigation.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Tabs } from 'ui'
-import { useFlag } from 'hooks'
-import { useRouter } from 'next/router'
-
-interface TabItem {
- label: string
- id: string
-}
-const LogsNavigation = () => {
- const router = useRouter()
- const activeRoute = router.pathname.split('/')[5]
- const { ref } = router.query
-
- const indexRoute = 'query'
-
- const tabs = [
- { id: 'query', label: 'Query' },
- { id: 'saved', label: 'Saved' },
- { id: 'recent', label: 'Recent' },
- { id: 'templates', label: 'Templates' },
- ].filter(Boolean) as TabItem[]
-
- return (
- <Tabs
- defaultActiveId="1"
- type="underlined"
- size="medium"
- activeId={!activeRoute ? indexRoute : activeRoute}
- onClick={(e: string) => {
- router.push(`/project/${ref}/logs/explorer/${e === indexRoute ? '' : e}`)
- }}
- >
- {tabs.map((item) => (
- <Tabs.Panel key={item.id} id={item.id} label={item.label} />
- ))}
- </Tabs>
- )
-}
-
-export default LogsNavigation
diff --git a/studio/components/layouts/LogsLayout/LogsLayout.tsx b/studio/components/layouts/LogsLayout/LogsLayout.tsx
index 737d69dba6e..2416aff75e7 100644
--- a/studio/components/layouts/LogsLayout/LogsLayout.tsx
+++ b/studio/components/layouts/LogsLayout/LogsLayout.tsx
@@ -15,7 +15,9 @@ interface LogsLayoutProps {
const LogsLayout = ({ title, children }: PropsWithChildren<LogsLayoutProps>) => {
const { ui } = useStore()
const router = useRouter()
- const page = router.pathname.split('/')[4]
+ const pathArr = router.pathname.split('/')
+ const page = pathArr[pathArr.length - 1]
+ console.log(page)
const project = ui.selectedProject
diff --git a/studio/components/layouts/LogsLayout/LogsMenu.utils.ts b/studio/components/layouts/LogsLayout/LogsMenu.utils.ts
index 4726868a8a1..cb1b4d1d7bc 100644
--- a/studio/components/layouts/LogsLayout/LogsMenu.utils.ts
+++ b/studio/components/layouts/LogsLayout/LogsMenu.utils.ts
@@ -12,14 +12,22 @@ export const generateLogsMenu = (project?: Project): ProductMenuGroup[] => {
return [
...(IS_PLATFORM
? [
+ {
+ title: 'Logs Explorer',
+ items: [
+ { key: 'explorer', name: 'Query', root: true },
+ { key: 'saved', name: 'Saved Queries' },
+ { key: 'recent', name: 'Recent Queries' },
+ { key: 'templates', name: 'Templates' },
+ ].map(({ key, name, root }) => ({
+ name,
+ key,
+ url: `/project/${ref}/logs/explorer${root ? '' : '/' + key}`,
+ items: [],
+ })),
+ },
{
items: [
- {
- name: 'Logs Explorer',
- key: 'explorer',
- url: `/project/${ref}/logs/explorer`,
- items: [],
- },
{
name: 'API Edge Network',
key: 'edge-logs',
diff --git a/studio/components/ui/Logs/LogsExplorerHeader.tsx b/studio/components/ui/Logs/LogsExplorerHeader.tsx
index 552bbf81763..450ffa6a7a1 100644
--- a/studio/components/ui/Logs/LogsExplorerHeader.tsx
+++ b/studio/components/ui/Logs/LogsExplorerHeader.tsx
@@ -1,23 +1,23 @@
-import LogsNavigation from 'components/interfaces/Settings/Logs/LogsNavigation'
import { IconList } from 'ui'
-const LogsExplorerHeader = () => {
- return (
- <div className={['flex flex-col gap-4 transition-all'].join(' ')}>
- <div className="flex items-center gap-3">
- <div
- className="flex h-6 w-6 items-center justify-center rounded border
+interface Props {
+ subtitle?: string
+}
+
+const LogsExplorerHeader: React.FC<Props> = ({ subtitle }) => (
+ <div className={['flex flex-col gap-8 transition-all pb-6'].join(' ')}>
+ <div className="flex items-center gap-3">
+ <div
+ className="flex h-6 w-6 items-center justify-center rounded border
border-brand-600 bg-brand-300 text-brand-900
"
- >
- <IconList size={14} strokeWidth={3} />
- </div>
- <h1 className="text-2xl text-scale-1200">Logs Explorer</h1>
- {/* {subtitle && <Badge color="scale">{subtitle}</Badge>} */}
+ >
+ <IconList size={14} strokeWidth={3} />
</div>
- <LogsNavigation />
- </div>
- )
-}
+ <h1 className="text-2xl text-scale-1200">Logs Explorer</h1>
+ {subtitle && <span className="text-2xl text-scale-1100">{subtitle}</span>}
+ </div>
+ </div>
+)
export default LogsExplorerHeader
diff --git a/studio/pages/project/[ref]/logs/explorer/recent.tsx b/studio/pages/project/[ref]/logs/explorer/recent.tsx
index 9427606916c..0f8bbbe5089 100644
--- a/studio/pages/project/[ref]/logs/explorer/recent.tsx
+++ b/studio/pages/project/[ref]/logs/explorer/recent.tsx
@@ -5,7 +5,6 @@ import { Button, IconClock } from 'ui'
import { useStore } from 'hooks'
import RecentQueriesItem from 'components/interfaces/Settings/Logs/RecentQueriesItem'
import LogsLayout from 'components/layouts/LogsLayout/LogsLayout'
-
import Table from 'components/to-be-cleaned/Table'
import { useRouter } from 'next/router'
import { LogSqlSnippets, NextPageWithLayout } from 'types'
@@ -23,7 +22,7 @@ export const LogsSavedPage: NextPageWithLayout = () => {
return (
<div className="mx-auto w-full px-5 py-6 h-full">
- <LogsExplorerHeader />
+ <LogsExplorerHeader subtitle="Recent Queries" />
{recent.length > 0 && (
<Table
head={
diff --git a/studio/pages/project/[ref]/logs/explorer/saved.tsx b/studio/pages/project/[ref]/logs/explorer/saved.tsx
index 3d9ea64aec5..3d49b345d0c 100644
--- a/studio/pages/project/[ref]/logs/explorer/saved.tsx
+++ b/studio/pages/project/[ref]/logs/explorer/saved.tsx
@@ -26,7 +26,7 @@ export const LogsSavedPage: NextPageWithLayout = () => {
const saved = content.savedLogSqlSnippets()
return (
<div className="mx-auto w-full px-5 py-6 h-full">
- <LogsExplorerHeader />
+ <LogsExplorerHeader subtitle="Saved Queries" />
<div className="flex flex-col gap-3 py-6">
{saved.length > 0 && (
<Table
diff --git a/studio/pages/project/[ref]/logs/explorer/templates.tsx b/studio/pages/project/[ref]/logs/explorer/templates.tsx
index 603a58dc8fe..5879f1d5437 100644
--- a/studio/pages/project/[ref]/logs/explorer/templates.tsx
+++ b/studio/pages/project/[ref]/logs/explorer/templates.tsx
@@ -1,7 +1,7 @@
import React, { useState } from 'react'
import { useRouter } from 'next/router'
-import { observer, useStaticRendering } from 'mobx-react-lite'
-import { IconCode, Badge, Collapsible, Button, Popover } from 'ui'
+import { observer } from 'mobx-react-lite'
+import { IconCode, Button, Popover } from 'ui'
import { TEMPLATES } from 'components/interfaces/Settings/Logs'
import LogsLayout from 'components/layouts/LogsLayout/LogsLayout'
import CardButton from 'components/ui/CardButton'
@@ -14,7 +14,7 @@ export const LogsTemplatesPage: NextPageWithLayout = () => {
return (
<div className="mx-auto h-full w-full px-5 py-6">
- <LogsExplorerHeader />
+ <LogsExplorerHeader subtitle="Templates" />
<div className="grid grid-cols-3 gap-6 mt-4">
{TEMPLATES.sort((a, b) => a.label!.localeCompare(b.label!))
.filter((template) => template.mode === 'custom')