mirror of
https://github.com/supabase/supabase.git
synced 2026-05-19 11:30:47 +08:00
## What kind of change does this PR introduce? Chore. Follow-up to DEPR-551, #45302, #45535, and #45618. ## What is the current behaviour? Some short Studio Admonitions still put their entire message in `title` or legacy `label`, so body-copy callouts render as headings. ## What is the new behaviour? Moves selected single-message Studio Admonitions to `description`, keeping the follow-up deliberately limited to Studio callsites. This PR does not touch Docs content, shared Alert styling, ui-patterns, design-system registry/docs, or Tailwind config. | Before | After | | --- | --- | | <img width="1818" height="388" alt="Image" src="https://github.com/user-attachments/assets/283a1853-348a-4d74-a408-013957350e5e" /> | <img width="1380" height="462" alt="Image" src="https://github.com/user-attachments/assets/e5761e8e-3697-423b-805b-45110205099a" /> | | <img width="1640" height="716" alt="CleanShot 2026-04-28 at 15 17 25@2x" src="https://github.com/user-attachments/assets/a5be4d5f-2bf7-4dc2-b396-56129fe64ec9" /> | <img width="1630" height="716" alt="CleanShot 2026-04-28 at 15 16 00@2x" src="https://github.com/user-attachments/assets/0d589252-aaf8-4efc-9d81-15ec4f99ec61" /> | <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Style** * Refined message displays and admonition styling across settings, database, dashboard, and admin interfaces for improved visual consistency and clarity. * **UI Updates** * Updated search input layouts and form element styling in publications tables and other admin pages. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46049?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
153 lines
5.1 KiB
TypeScript
153 lines
5.1 KiB
TypeScript
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
|
import { useParams } from 'common'
|
|
import { Search } from 'lucide-react'
|
|
import { useMemo, useRef, useState } from 'react'
|
|
import { Card, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from 'ui'
|
|
import { Admonition } from 'ui-patterns'
|
|
import { Input } from 'ui-patterns/DataInputs/Input'
|
|
|
|
import { PublicationTablesSkeleton } from './PublicationSkeleton'
|
|
import { PublicationsTableItem } from './PublicationsTableItem'
|
|
import { AlertError } from '@/components/ui/AlertError'
|
|
import { NoSearchResults } from '@/components/ui/NoSearchResults'
|
|
import { useDatabasePublicationsQuery } from '@/data/database-publications/database-publications-query'
|
|
import { useTablesQuery } from '@/data/tables/tables-query'
|
|
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
|
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
|
import { onSearchInputEscape } from '@/lib/keyboard'
|
|
import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
|
|
import { useShortcut } from '@/state/shortcuts/useShortcut'
|
|
|
|
export const PublicationsTables = () => {
|
|
const { id } = useParams()
|
|
const { data: project } = useSelectedProjectQuery()
|
|
const [filterString, setFilterString] = useState<string>('')
|
|
const searchInputRef = useRef<HTMLInputElement>(null)
|
|
|
|
const { can: canUpdatePublications, isLoading: isLoadingPermissions } = useAsyncCheckPermissions(
|
|
PermissionAction.TENANT_SQL_ADMIN_WRITE,
|
|
'publications'
|
|
)
|
|
|
|
useShortcut(
|
|
SHORTCUT_IDS.LIST_PAGE_FOCUS_SEARCH,
|
|
() => {
|
|
searchInputRef.current?.focus()
|
|
searchInputRef.current?.select()
|
|
},
|
|
{ label: 'Search publications' }
|
|
)
|
|
|
|
const { data: publications = [] } = useDatabasePublicationsQuery({
|
|
projectRef: project?.ref,
|
|
connectionString: project?.connectionString,
|
|
})
|
|
const selectedPublication = publications.find((pub) => pub.id === Number(id))
|
|
|
|
const {
|
|
data: tablesData = [],
|
|
isPending: isLoading,
|
|
isSuccess,
|
|
isError,
|
|
error,
|
|
} = useTablesQuery({
|
|
projectRef: project?.ref,
|
|
connectionString: project?.connectionString,
|
|
})
|
|
|
|
const tables = useMemo(() => {
|
|
return tablesData.filter((table) =>
|
|
filterString.length === 0 ? table : table.name.includes(filterString)
|
|
)
|
|
}, [tablesData, filterString])
|
|
|
|
return (
|
|
<>
|
|
<div className="flex items-center justify-between mb-4">
|
|
<Input
|
|
size="tiny"
|
|
ref={searchInputRef}
|
|
icon={<Search />}
|
|
className="w-48"
|
|
placeholder="Search for a table"
|
|
value={filterString}
|
|
onChange={(e) => setFilterString(e.target.value)}
|
|
onKeyDown={onSearchInputEscape(filterString, setFilterString)}
|
|
/>
|
|
</div>
|
|
|
|
{!isLoadingPermissions && !canUpdatePublications && (
|
|
<Admonition
|
|
type="warning"
|
|
className="mb-4 w-full"
|
|
description="You need additional permissions to update database replications."
|
|
/>
|
|
)}
|
|
|
|
<Card>
|
|
<Table>
|
|
<TableHeader>
|
|
<TableRow>
|
|
<TableHead>Name</TableHead>
|
|
<TableHead>Schema</TableHead>
|
|
<TableHead className="hidden lg:table-cell">Description</TableHead>
|
|
{/*
|
|
We've disabled All tables toggle for publications.
|
|
See https://github.com/supabase/supabase/pull/7233.
|
|
*/}
|
|
<TableHead />
|
|
</TableRow>
|
|
</TableHeader>
|
|
<TableBody>
|
|
{(isLoading || isLoadingPermissions) &&
|
|
Array.from({ length: 2 }).map((_, i) => (
|
|
<PublicationTablesSkeleton key={i} index={i} />
|
|
))}
|
|
|
|
{isError && (
|
|
<TableRow>
|
|
<TableCell colSpan={4}>
|
|
<AlertError error={error} subject="Failed to retrieve tables" />
|
|
</TableCell>
|
|
</TableRow>
|
|
)}
|
|
|
|
{!isLoading && !isLoadingPermissions && tables.length === 0 && (
|
|
<TableRow>
|
|
<TableCell colSpan={4}>
|
|
<NoSearchResults
|
|
className="border-none !p-0"
|
|
searchString={filterString}
|
|
onResetFilter={() => setFilterString('')}
|
|
/>
|
|
</TableCell>
|
|
</TableRow>
|
|
)}
|
|
|
|
{isSuccess ? (
|
|
!!selectedPublication ? (
|
|
tables.map((table) => (
|
|
<PublicationsTableItem
|
|
key={table.id}
|
|
table={table}
|
|
selectedPublication={selectedPublication}
|
|
/>
|
|
))
|
|
) : (
|
|
<TableRow>
|
|
<TableCell colSpan={4}>
|
|
<p>The selected publication with ID {id} cannot be found</p>
|
|
<p className="text-foreground-light">
|
|
Head back to the list of publications to select one from there
|
|
</p>
|
|
</TableCell>
|
|
</TableRow>
|
|
)
|
|
) : null}
|
|
</TableBody>
|
|
</Table>
|
|
</Card>
|
|
</>
|
|
)
|
|
}
|