mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
Moves the `/settings/*`, `/advisors/*` and `/issues/*` page bodies into their route files and deletes the pages (FE-3106). Part 10 of the stack. **Depends on:** #53218 **Changed:** - `routes/project/$ref/settings/**` – 16 page bodies inlined. `settings/api` redirects with `<Navigate>`; billing usage, dashboard and replica pages use typed `navigate`/`Link` - `routes/project/$ref/{advisors,issues}/**` – 7 page bodies inlined - Settings tests moved from `tests/pages/**` to `tests/routes/**` and rendered with `renderRoute` - `routes/project/$ref/advisors{.tsx,/rules.tsx,/security.tsx,/performance.tsx,/health.tsx}` – carry master's #52993 (Advisors → Issues behind `issuesInbox`: `IssuesCategoryRedirect`, `LegacyAdvisorsLayout`, `parseLinterLevel`, named `LinterFilters`/`LintPageTabs`), ported from the deleted pages and checked against master's pages + route adapters; `LegacyAdvisorsPages.platform.test.tsx` now renders the routes (`tests/routes/project/$ref/advisors/legacy-advisors.platform.test.tsx`) **Removed:** - 23 page files, and `AdvisorRulesLayout` (only the deleted rules pages used it; `routes/project/$ref/advisors/rules.tsx` already inlines it) Addresses [FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages). ## To test - Project Settings (General, Compute, Infrastructure, Add-ons, API keys, JWT, Log drains, Webhooks, Integrations) – same layout and sidebar - `/project/<ref>/settings/api` – redirects as before - Advisors (Security, Performance, Rules) and Issues – same layout --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
128 lines
4.3 KiB
TypeScript
128 lines
4.3 KiB
TypeScript
import { createFileRoute } from '@tanstack/react-router'
|
|
import { useFlag, useParams } from 'common'
|
|
import { useMemo, useState } from 'react'
|
|
import { LoadingLine } from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
|
|
import { IssuesCategoryRedirect } from '@/components/interfaces/Issues/IssuesCategoryRedirect'
|
|
import { LINTER_LEVELS } from '@/components/interfaces/Linter/Linter.constants'
|
|
import { lintInfoMap, parseLinterLevel } from '@/components/interfaces/Linter/Linter.utils'
|
|
import { LinterDataGrid } from '@/components/interfaces/Linter/LinterDataGrid'
|
|
import { LinterFilters } from '@/components/interfaces/Linter/LinterFilters'
|
|
import { LintPageTabs } from '@/components/interfaces/Linter/LintPageTabs'
|
|
import { useAdvisorPageShortcuts } from '@/components/interfaces/Linter/useAdvisorPageShortcuts'
|
|
import { LegacyAdvisorsLayout } from '@/components/layouts/AdvisorsLayout/LegacyAdvisorsLayout'
|
|
import { FormHeader } from '@/components/ui/Forms/FormHeader'
|
|
import { useProjectHealthLintsQuery } from '@/data/lint/health-lints-query'
|
|
import { Lint } from '@/data/lint/lint-query'
|
|
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
|
|
|
export const Route = createFileRoute('/project/$ref/advisors/health')({
|
|
component: AdvisorsHealthRoute,
|
|
staticData: { skipAdvisorsLayout: true },
|
|
})
|
|
|
|
function AdvisorsHealthRoute() {
|
|
return (
|
|
<LegacyAdvisorsLayout>
|
|
<AdvisorsHealthPage />
|
|
</LegacyAdvisorsLayout>
|
|
)
|
|
}
|
|
|
|
const ProjectHealthLints = () => {
|
|
const isHealthAdvisorEnabled = useFlag('healthAdvisor')
|
|
|
|
if (!isHealthAdvisorEnabled) {
|
|
return (
|
|
<div className="flex items-center justify-center w-full h-full">
|
|
<Admonition type="default" title="Health Advisor is not available for this project" />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return <ProjectHealthLintsContent />
|
|
}
|
|
|
|
const ProjectHealthLintsContent = () => {
|
|
const { preset, id } = useParams()
|
|
const { data: project } = useSelectedProjectQuery()
|
|
|
|
const [filters, setFilters] = useState<{ level: LINTER_LEVELS; filters: string[] }[]>([
|
|
{ level: LINTER_LEVELS.ERROR, filters: [] },
|
|
{ level: LINTER_LEVELS.WARN, filters: [] },
|
|
{ level: LINTER_LEVELS.INFO, filters: [] },
|
|
])
|
|
const [currentTab, setCurrentTab] = useState<LINTER_LEVELS>(
|
|
parseLinterLevel(preset) ?? LINTER_LEVELS.ERROR
|
|
)
|
|
const { data, isPending, isRefetching, refetch } = useProjectHealthLintsQuery({
|
|
projectRef: project?.ref,
|
|
})
|
|
|
|
const isLoading = isPending
|
|
|
|
const activeLints = (data ?? []).filter((lint) => lint.categories.includes('HEALTH'))
|
|
const currentTabFilters = filters.find((filter) => filter.level === currentTab)?.filters ?? []
|
|
const filteredLints = activeLints
|
|
.filter((x) => x.level === currentTab)
|
|
.filter((x) => (currentTabFilters.length > 0 ? currentTabFilters.includes(x.name) : x))
|
|
const filterOptions = lintInfoMap
|
|
.filter((item) =>
|
|
activeLints.some((lint) => lint.name === item.name && lint.level === currentTab)
|
|
)
|
|
.map((type) => ({
|
|
name: type.title,
|
|
value: type.name,
|
|
}))
|
|
|
|
const selectedLint: Lint | null = useMemo(() => {
|
|
return activeLints.find((lint) => lint.cache_key === id) ?? null
|
|
}, [id, activeLints])
|
|
|
|
useAdvisorPageShortcuts({
|
|
setCurrentTab,
|
|
refetch,
|
|
hasSelectedLint: selectedLint !== null,
|
|
isRefreshDisabled: isLoading || isRefetching,
|
|
})
|
|
|
|
return (
|
|
<div className="h-full flex flex-col">
|
|
<FormHeader className="py-4 px-6 -mb-px!" title="Health Advisor" />
|
|
<LintPageTabs
|
|
activeLints={activeLints}
|
|
isLoading={isLoading}
|
|
currentTab={currentTab}
|
|
setCurrentTab={setCurrentTab}
|
|
/>
|
|
<LinterFilters
|
|
filterOptions={filterOptions}
|
|
filteredLints={filteredLints}
|
|
activeLints={activeLints}
|
|
currentTab={currentTab}
|
|
filters={filters}
|
|
isLoading={isLoading || isRefetching}
|
|
setFilters={setFilters}
|
|
onClickRefresh={refetch}
|
|
/>
|
|
<LoadingLine loading={isRefetching} />
|
|
<LinterDataGrid
|
|
filteredLints={filteredLints}
|
|
currentTab={currentTab}
|
|
selectedLint={selectedLint}
|
|
isLoading={isLoading}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function AdvisorsHealthPage() {
|
|
const isIssuesInboxEnabled = useFlag('issuesInbox')
|
|
return isIssuesInboxEnabled ? (
|
|
<IssuesCategoryRedirect category="health" />
|
|
) : (
|
|
<ProjectHealthLints />
|
|
)
|
|
}
|