Skip to content

Commit

Permalink
feat: add query-performance link in advisor
Browse files Browse the repository at this point in the history
  • Loading branch information
jingsam committed Aug 3, 2024
1 parent 62b143f commit 1715230
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ limit 12
},
},
[Presets.QUERY_PERFORMANCE]: {
title: '查询性能',
title: '查询优化',
queries: {
mostFrequentlyInvoked: {
queryType: 'db',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@ const LogsQueryPanel = ({
<Table
head={[
<Table.th className="text-xs !p-2" key="path">
Path
路径
</Table.th>,
<Table.th key="type" className="text-xs !p-2">
Type
类型
</Table.th>,
]}
body={schema.fields
Expand Down Expand Up @@ -374,7 +374,7 @@ const Field = ({
'border border-background',
].join(' ')}
>
<span className="text-xs text-foreground">Copied</span>
<span className="text-xs text-foreground">已复制</span>
</div>
</Tooltip.Content>
</Tooltip.Portal>
Expand All @@ -393,7 +393,7 @@ const Field = ({
'border border-background',
].join(' ')}
>
<span className="text-xs text-foreground">Copy value</span>
<span className="text-xs text-foreground">复制</span>
</div>
</Tooltip.Content>
</Tooltip.Portal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ export interface AdvisorsLayoutProps {
title?: string
}

const AdvisorsLayout = ({ children }: PropsWithChildren<AdvisorsLayoutProps>) => {
const AdvisorsLayout = ({ children, title }: PropsWithChildren<AdvisorsLayoutProps>) => {
const project = useSelectedProject()

const router = useRouter()
const page = router.pathname.split('/')[4]

return (
<ProjectLayout
title={title}
isLoading={false}
product="优化助手"
productMenu={<ProductMenu page={page} menu={generateAdvisorsMenu(project)} />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ProductMenuGroup } from 'components/ui/ProductMenu/ProductMenu.types'
import type { Project } from 'data/projects/project-detail-query'
import { ArrowUpRight } from 'lucide-react'

export const generateAdvisorsMenu = (project?: Project): ProductMenuGroup[] => {
const ref = project?.ref ?? 'default'
Expand All @@ -9,17 +10,24 @@ export const generateAdvisorsMenu = (project?: Project): ProductMenuGroup[] => {
title: '优化助手',
items: [
{
name: '安全',
name: '安全助手',
key: 'security',
url: `/project/${ref}/advisors/security`,
items: [],
},
{
name: '性能',
name: '性能助手',
key: 'performance',
url: `/project/${ref}/advisors/performance`,
items: [],
},
{
name: '查询优化',
key: 'query-performance',
url: `/project/${ref}/database/query-performance`,
rightIcon: <ArrowUpRight strokeWidth={1} className="h-4 w-4" />,
items: [],
},
],
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const generateDatabaseMenu = (
items: [],
},
{
name: '查询性能',
name: '查询优化',
key: 'query-performance',
url: `/project/${ref}/database/query-performance`,
items: [],
Expand Down
4 changes: 2 additions & 2 deletions apps/studio/components/layouts/LogsLayout/LogsMenu.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export const generateLogsMenu = (
items: [],
},
{
name: 'Postgres',
name: '数据库',
key: 'postgres-logs',
url: `/project/${ref}/logs/postgres-logs`,
items: [],
},
{
name: 'PostgREST',
name: '接口生成器',
key: 'postgrest-logs',
url: `/project/${ref}/logs/postgrest-logs`,
items: [],
Expand Down
2 changes: 1 addition & 1 deletion apps/studio/pages/project/[ref]/advisors/performance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ const ProjectLints: NextPageWithLayout = () => {
)
}

ProjectLints.getLayout = (page) => <AdvisorsLayout title="Linter">{page}</AdvisorsLayout>
ProjectLints.getLayout = (page) => <AdvisorsLayout title="性能助手">{page}</AdvisorsLayout>

export default ProjectLints
2 changes: 1 addition & 1 deletion apps/studio/pages/project/[ref]/advisors/security.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@ const ProjectLints: NextPageWithLayout = () => {
)
}

ProjectLints.getLayout = (page) => <AdvisorsLayout title="Linter">{page}</AdvisorsLayout>
ProjectLints.getLayout = (page) => <AdvisorsLayout title="安全助手">{page}</AdvisorsLayout>

export default ProjectLints
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const QueryPerformanceReport: NextPageWithLayout = () => {
<div className="h-full flex flex-col">
<FormHeader
className="py-4 px-6 !mb-0"
title="查询性能"
title="查询优化"
docsUrl="https://supabase.com/docs/guides/platform/performance#examining-query-performance"
// actions={<DatabaseSelector />}
/>
Expand All @@ -58,7 +58,7 @@ const QueryPerformanceReport: NextPageWithLayout = () => {
}

QueryPerformanceReport.getLayout = (page) => (
<DatabaseLayout title="查询性能">{page}</DatabaseLayout>
<DatabaseLayout title="查询优化">{page}</DatabaseLayout>
)

export default QueryPerformanceReport
2 changes: 1 addition & 1 deletion apps/studio/pages/project/[ref]/logs/edge-logs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export const LogPage: NextPageWithLayout = () => {
)
}

LogPage.getLayout = (page) => <LogsLayout title="云函数日志">{page}</LogsLayout>
LogPage.getLayout = (page) => <LogsLayout title="API 网关日志">{page}</LogsLayout>

export default LogPage
12 changes: 6 additions & 6 deletions packages/shared-data/logConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const schemas = [
],
},
{
name: '认证',
name: '认证授权',
reference: 'auth_logs',
fields: [
{ path: 'event_message', type: 'string' },
Expand Down Expand Up @@ -130,7 +130,7 @@ const schemas = [
],
},
{
name: '边缘函数',
name: '云函数',
reference: 'function_edge_logs',
fields: [
{ path: 'event_message', type: 'string' },
Expand Down Expand Up @@ -159,7 +159,7 @@ const schemas = [
],
},
{
name: '边缘函数运行时',
name: '云函数运行时',
reference: 'function_logs',
fields: [
{ path: 'event_message', type: 'string' },
Expand All @@ -177,7 +177,7 @@ const schemas = [
],
},
{
name: 'Postgres',
name: '数据库',
reference: 'postgres_logs',
fields: [
{ path: 'event_message', type: 'string' },
Expand Down Expand Up @@ -218,7 +218,7 @@ const schemas = [
],
},
{
name: 'PostgREST',
name: '接口生成器',
reference: 'postgrest_logs',
fields: [
{ path: 'event_message', type: 'string' },
Expand All @@ -229,7 +229,7 @@ const schemas = [
],
},
{
name: 'Supavisor',
name: '连接池',
reference: 'supavisor_logs',
fields: [
{ path: 'event_message', type: 'string' },
Expand Down

0 comments on commit 1715230

Please sign in to comment.