mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Context This is largely just a mechanical change here: Opting to use lucide icons with the `Icon` suffix across all icon imports within `studio` - so that it’s clearer which components are icons + reduces the possibility of name collision with our own components - e.g <User /> vs <UserIcon /> Also added a eslint rule for this: <img width="1069" height="167" alt="image" src="https://github.com/user-attachments/assets/7f36f443-5ca2-4bf6-8d22-86e774513bfc" /> And updated `AGENTS.md` as such: ``` Icons come from `lucide-react`, always imported with the `Icon` suffix (`import { CheckIcon, Trash2Icon } from 'lucide-react'`) — never the bare names (`Check`) or `Check as CheckIcon` aliases (lint-enforced). ```
94 lines
2.4 KiB
TypeScript
94 lines
2.4 KiB
TypeScript
import { useFlag, useParams } from 'common'
|
|
import { ArrowUpRightIcon } from 'lucide-react'
|
|
|
|
import { useIsAdvisorRulesEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
|
|
import type {
|
|
ProductMenuGroup,
|
|
ProductMenuGroupItem,
|
|
} from '@/components/ui/ProductMenu/ProductMenu.types'
|
|
import { IS_PLATFORM } from '@/lib/constants'
|
|
import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
|
|
|
|
export const generateAdvisorsMenu = ({
|
|
ref,
|
|
isAdvisorRulesEnabled,
|
|
isHealthAdvisorEnabled,
|
|
isPlatform,
|
|
}: {
|
|
ref: string | undefined
|
|
isAdvisorRulesEnabled: boolean
|
|
isHealthAdvisorEnabled: boolean
|
|
isPlatform: boolean
|
|
}): ProductMenuGroup[] => {
|
|
const advisorItems: ProductMenuGroupItem[] = [
|
|
...(isHealthAdvisorEnabled
|
|
? [
|
|
{
|
|
name: 'Health Advisor',
|
|
key: 'health',
|
|
url: `/project/${ref}/advisors/health`,
|
|
items: [],
|
|
shortcutId: SHORTCUT_IDS.NAV_ADVISORS_HEALTH,
|
|
},
|
|
]
|
|
: []),
|
|
{
|
|
name: 'Security Advisor',
|
|
key: 'security',
|
|
url: `/project/${ref}/advisors/security`,
|
|
items: [],
|
|
shortcutId: SHORTCUT_IDS.NAV_ADVISORS_SECURITY,
|
|
},
|
|
{
|
|
name: 'Performance Advisor',
|
|
key: 'performance',
|
|
url: `/project/${ref}/advisors/performance`,
|
|
items: [],
|
|
shortcutId: SHORTCUT_IDS.NAV_ADVISORS_PERFORMANCE,
|
|
},
|
|
{
|
|
name: 'Query Performance',
|
|
key: 'query-performance',
|
|
url: `/project/${ref}/observability/query-performance`,
|
|
items: [],
|
|
rightIcon: <ArrowUpRightIcon size={14} strokeWidth={1.5} className="h-4 w-4" />,
|
|
},
|
|
]
|
|
|
|
return [
|
|
{
|
|
title: 'Advisors',
|
|
items: advisorItems,
|
|
},
|
|
...(isPlatform && isAdvisorRulesEnabled
|
|
? [
|
|
{
|
|
title: 'Configuration',
|
|
items: [
|
|
{
|
|
name: 'Settings',
|
|
key: 'rules',
|
|
url: `/project/${ref}/advisors/rules/security`,
|
|
items: [],
|
|
shortcutId: SHORTCUT_IDS.NAV_ADVISORS_RULES,
|
|
},
|
|
],
|
|
},
|
|
]
|
|
: []),
|
|
]
|
|
}
|
|
|
|
export const useGenerateAdvisorsMenu = (): ProductMenuGroup[] => {
|
|
const { ref } = useParams()
|
|
const isAdvisorRulesEnabled = useIsAdvisorRulesEnabled()
|
|
const isHealthAdvisorEnabled = useFlag('healthAdvisor')
|
|
|
|
return generateAdvisorsMenu({
|
|
ref,
|
|
isAdvisorRulesEnabled,
|
|
isHealthAdvisorEnabled,
|
|
isPlatform: IS_PLATFORM,
|
|
})
|
|
}
|