mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 18:05:11 +03:00
## Context Main fix is to adjust the new home page + connect dialog (and connect sheet) to render the project's custom domain if available <img width="471" height="255" alt="image" src="https://github.com/user-attachments/assets/3a208b2e-bdeb-43f5-a2e7-3495881dbaaa" /> <img width="1065" height="233" alt="image" src="https://github.com/user-attachments/assets/2a7b8f81-8c0b-4803-bf0a-fc16a2f1e0e1" /> ## Changes involved - Created a `useProjectApiUrl` hook that will return the API URL depending if custom domains is available, otherwise default to default project API URL - Refactored all the other places that were manually deriving the project's endpoint - Storage Explorer -> copy URL - Edge Functions - Integrations -> Data API + API Docs - Auth Providers -> Callback URL - Also updated the copy CTA for the addons page - Instead of just "Change xxx", make it a bit more actionable - For add ons with binary states (Custom domains, IPv4) - If not enabled yet, "Enable xxx", otherwise "Toggle xxx" - For PITR - If not enabled yet, "Enable PITR", otherwise "Change recovery duration" - Also added "Edit custom domain" CTA if enabled <img width="1144" height="518" alt="image" src="https://github.com/user-attachments/assets/4f152ea5-0cc7-412c-95e8-ad5bb37c19c3" /> ## To test - [ ] Verify that for a project with custom domain set up, all the affected UI mentioned in the above section look correct
96 lines
3.2 KiB
TypeScript
96 lines
3.2 KiB
TypeScript
import { IS_PLATFORM } from 'common'
|
|
import { useParams } from 'common/hooks'
|
|
import dayjs from 'dayjs'
|
|
import { Check, Copy } from 'lucide-react'
|
|
import { useRouter } from 'next/router'
|
|
import { useState } from 'react'
|
|
import { copyToClipboard, TableCell, TableRow } from 'ui'
|
|
import { TimestampInfo } from 'ui-patterns'
|
|
|
|
import { useProjectApiUrl } from '@/data/config/project-endpoint-query'
|
|
import type { EdgeFunctionsResponse } from '@/data/edge-functions/edge-functions-query'
|
|
import { createNavigationHandler } from '@/lib/navigation'
|
|
|
|
interface EdgeFunctionsListItemProps {
|
|
function: EdgeFunctionsResponse
|
|
}
|
|
|
|
export const EdgeFunctionsListItem = ({ function: item }: EdgeFunctionsListItemProps) => {
|
|
const router = useRouter()
|
|
const { ref } = useParams()
|
|
const [isCopied, setIsCopied] = useState(false)
|
|
|
|
const { data: endpoint } = useProjectApiUrl({ projectRef: ref })
|
|
const functionUrl = `${endpoint}/functions/v1/${item.slug}`
|
|
|
|
const handleNavigation = createNavigationHandler(
|
|
`/project/${ref}/functions/${item.slug}${IS_PLATFORM ? '' : `/details`}`,
|
|
router
|
|
)
|
|
|
|
return (
|
|
<TableRow
|
|
key={item.id}
|
|
onClick={handleNavigation}
|
|
onAuxClick={handleNavigation}
|
|
onKeyDown={handleNavigation}
|
|
tabIndex={0}
|
|
className="cursor-pointer inset-focus"
|
|
>
|
|
<TableCell>
|
|
<p className="text-sm text-foreground whitespace-nowrap py-2">{item.name}</p>
|
|
</TableCell>
|
|
<TableCell>
|
|
<div className="text-xs text-foreground-light flex gap-2 items-center truncate">
|
|
<p title={functionUrl} className="font-mono truncate hidden md:inline max-w-[30rem]">
|
|
{functionUrl}
|
|
</p>
|
|
<button
|
|
type="button"
|
|
className="text-foreground-lighter hover:text-foreground transition"
|
|
onClick={(event: any) => {
|
|
function onCopy(value: any) {
|
|
setIsCopied(true)
|
|
copyToClipboard(value)
|
|
setTimeout(() => setIsCopied(false), 3000)
|
|
}
|
|
event.stopPropagation()
|
|
onCopy(functionUrl)
|
|
}}
|
|
>
|
|
{isCopied ? (
|
|
<div className="text-brand">
|
|
<Check size={14} strokeWidth={3} />
|
|
</div>
|
|
) : (
|
|
<div className="relative">
|
|
<div className="block">
|
|
<Copy size={14} strokeWidth={1.5} />
|
|
</div>
|
|
</div>
|
|
)}
|
|
</button>
|
|
</div>
|
|
</TableCell>
|
|
<TableCell className="hidden 2xl:table-cell whitespace-nowrap">
|
|
<p className="text-foreground-light">
|
|
{dayjs(item.created_at).format('DD MMM, YYYY HH:mm')}
|
|
</p>
|
|
</TableCell>
|
|
<TableCell className="lg:table-cell">
|
|
<TimestampInfo
|
|
className="text-sm text-foreground-light whitespace-nowrap"
|
|
utcTimestamp={item.updated_at}
|
|
label={dayjs(item.updated_at).fromNow()}
|
|
/>
|
|
</TableCell>
|
|
<TableCell className="lg:table-cell">
|
|
<p className="text-foreground-light">{item.version}</p>
|
|
<button tabIndex={-1} className="sr-only">
|
|
Go to function details
|
|
</button>
|
|
</TableCell>
|
|
</TableRow>
|
|
)
|
|
}
|