mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
Several supabase.com URLs still return a 404 to real browsers every day: an old Database Hooks route, card icons for brands we never shipped an image for, two dashboard links to docs pages that miss the `/guides` prefix, and a few URLs that search engines and feed readers keep requesting. **Changed:** - **Old Database Hooks links land on Webhooks**: #29671 renamed `/project/:ref/database/hooks` without a redirect, so bookmarks and older guides hit a 404. I added a redirect to the Integrations Webhooks page, the same target as the existing `database/webhooks` redirect. - **Card brands without an icon show a generic card**: payment method rows built the image URL straight from the card brand name, so UnionPay and other brands without a PNG rendered a broken image. I added a `CardBrandIcon` in `CreditCard.tsx`, used by both views, that only requests the brand images we ship, labels each with its brand name, and shows a generic card icon for every other brand. - **Branching "Learn more" links open the right docs**: #51393 linked the branching empty state to `/docs/deployment/branching/...` without `/guides`. I fixed both links and added a redirect for the GitHub integration URL, which search engines already indexed (the dashboard one already had a redirect). - **Indexed docs and feed URLs redirect**: I added redirects for `/docs/guides/mcp`, the old hashed architecture diagram path that other sites still embed, and `/changelog/rss.xml`. I also added an RSS `alternate` link to `/changelog` so feed readers find `/changelog-rss.xml` instead of guessing. **Note:** Studio and www changes are independent, so either app can deploy first. ## To test Tested on the PR preview: - [x] Open `/dashboard/project/<ref>/database/hooks`, expect a redirect to `/dashboard/project/<ref>/integrations/webhooks/overview` (`database/hooks-nope` still 404s) - [x] Open org billing with a Visa or Mastercard on file, expect the brand logo as before - [x] With a card whose brand has no image (e.g. UnionPay), expect a generic card icon instead of a broken image in the payment methods list (checked with a mocked UnionPay row: generic icon, no `unionpay.png` request, Visa rows unchanged) - [ ] Same check in the plan change payment method select (not exercised: reaching it starts the plan change flow) - [x] On a project without branching, open Branches and click both "Learn more" buttons, expect the dashboard and GitHub integration branching guides to load - [x] On the www preview, open `/changelog/rss.xml`, `/docs/guides/mcp` and `/docs/deployment/branching/github-integration`, expect 308s to `/changelog-rss.xml`, `/docs/guides/ai-tools/mcp` and `/docs/guides/deployment/branching/github-integration` - [x] View source on `/changelog`, expect a `rel="alternate"` RSS link to `/changelog-rss.xml` ## Linear - fixes GROWTH-1364
211 lines
7.3 KiB
TypeScript
211 lines
7.3 KiB
TypeScript
import { CreditCardIcon, MoreHorizontalIcon } from 'lucide-react'
|
|
import {
|
|
Badge,
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
} from 'ui'
|
|
|
|
import { DropdownMenuItemTooltip } from '@/components/ui/DropdownMenuItemTooltip'
|
|
import PartnerIcon from '@/components/ui/PartnerIcon'
|
|
import type { OrganizationPaymentMethod } from '@/data/organizations/organization-payment-methods-query'
|
|
import type { PlanId } from '@/data/subscriptions/types'
|
|
import { BASE_PATH } from '@/lib/constants'
|
|
import { MANAGED_BY } from '@/lib/constants/infrastructure'
|
|
|
|
const BRANDS_WITH_ICON = new Set(['amex', 'discover', 'jcb', 'mastercard', 'visa'])
|
|
|
|
export const CardBrandIcon = ({ brand }: { brand: string | null | undefined }) => {
|
|
if (!brand || !BRANDS_WITH_ICON.has(brand)) {
|
|
return (
|
|
<CreditCardIcon
|
|
aria-label="Credit card"
|
|
strokeWidth={1.5}
|
|
className="h-6 w-8 text-foreground-lighter"
|
|
/>
|
|
)
|
|
}
|
|
|
|
return <img alt={brand} src={`${BASE_PATH}/img/payment-methods/${brand}.png`} width="32" />
|
|
}
|
|
|
|
interface CreditCardProps {
|
|
paymentMethod: OrganizationPaymentMethod
|
|
canUpdatePaymentMethods?: boolean
|
|
paymentMethodType?: string
|
|
paymentMethodCount: number
|
|
subscriptionPlan?: PlanId
|
|
setSelectedMethodForUse?: (paymentMethod: OrganizationPaymentMethod) => void
|
|
setSelectedMethodToDelete?: (paymentMethod: OrganizationPaymentMethod) => void
|
|
}
|
|
|
|
const CreditCard = ({
|
|
paymentMethod,
|
|
canUpdatePaymentMethods = true,
|
|
paymentMethodType,
|
|
subscriptionPlan,
|
|
paymentMethodCount,
|
|
setSelectedMethodForUse,
|
|
setSelectedMethodToDelete,
|
|
}: CreditCardProps) => {
|
|
const isSpt = paymentMethod.type === 'shared_payment_token'
|
|
const spt = paymentMethod.shared_payment_token
|
|
const isActive = paymentMethod.is_default
|
|
const isRemovable =
|
|
!paymentMethod.is_default || (subscriptionPlan === 'free' && paymentMethodCount === 1)
|
|
|
|
const expiryYear = paymentMethod.card?.exp_year ?? 0
|
|
const expiryMonth = paymentMethod.card?.exp_month ?? 0
|
|
|
|
const currentMonth = new Date().getMonth() + 1
|
|
const currentYear = new Date().getFullYear()
|
|
|
|
const isCardExpiringSoon = expiryYear === currentYear && expiryMonth === currentMonth
|
|
const isCardExpired =
|
|
expiryYear < currentYear || (expiryYear === currentYear && expiryMonth < currentMonth)
|
|
const isTokenExpired = spt?.is_expired ?? false
|
|
const tokenExpiry = spt?.expires_at
|
|
? `${new Date(spt.expires_at * 1000).getMonth() + 1}/${new Date(spt.expires_at * 1000).getFullYear()}`
|
|
: undefined
|
|
|
|
const stripeStatus = (() => {
|
|
if (!isSpt) return null
|
|
if (isTokenExpired) {
|
|
return {
|
|
label: 'Token expired',
|
|
variant: 'destructive' as const,
|
|
description: 'Stripe Projects token has expired',
|
|
}
|
|
}
|
|
if (isCardExpired) {
|
|
return {
|
|
label: 'Needs review',
|
|
variant: 'warning' as const,
|
|
description: 'Underlying card has expired',
|
|
}
|
|
}
|
|
if (isCardExpiringSoon) {
|
|
return {
|
|
label: 'Needs review',
|
|
variant: 'warning' as const,
|
|
description: 'Underlying card expires soon',
|
|
}
|
|
}
|
|
return {
|
|
label: 'Active',
|
|
variant: 'success' as const,
|
|
description: 'Stripe Projects token is active',
|
|
}
|
|
})()
|
|
|
|
if (!paymentMethod.card) return null
|
|
|
|
return (
|
|
<div key={paymentMethod.id} className="space-y-3">
|
|
<div className="flex items-center justify-between gap-8">
|
|
<div className="flex items-center gap-8">
|
|
<div className="relative shrink-0">
|
|
<CardBrandIcon brand={paymentMethod.card.brand} />
|
|
{isSpt && (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<span className="absolute -bottom-1.5 -right-2 rounded-md bg-background outline outline-2 outline-background">
|
|
<PartnerIcon
|
|
organization={{ managed_by: MANAGED_BY.STRIPE_PROJECTS }}
|
|
showTooltip={false}
|
|
size="small"
|
|
/>
|
|
</span>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="top">Handled via Stripe Projects</TooltipContent>
|
|
</Tooltip>
|
|
)}
|
|
</div>
|
|
<div className="flex flex-col gap-0.5">
|
|
<div className="flex items-center gap-8">
|
|
<p className="prose text-sm font-mono">**** **** **** {paymentMethod.card.last4}</p>
|
|
<p className="text-sm tabular-nums">
|
|
Expires: {paymentMethod.card.exp_month}/{paymentMethod.card.exp_year}
|
|
</p>
|
|
</div>
|
|
{isSpt && spt && (
|
|
<div className="mt-2.5 flex items-center gap-2 border-t pt-2.5 text-xs text-foreground-light">
|
|
<p className="m-0">
|
|
Managed via Stripe Projects · Token ending in <code>{spt.last4}</code>
|
|
{tokenExpiry && <span> · Expires {tokenExpiry}</span>}
|
|
</p>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="flex items-center gap-2">
|
|
{!isSpt && isCardExpiringSoon && <Badge variant="warning">Expiring soon</Badge>}
|
|
{!isSpt && isCardExpired && <Badge variant="destructive">Expired</Badge>}
|
|
{!isSpt && !isCardExpired && isActive && <Badge variant="success">Active</Badge>}
|
|
{stripeStatus && (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<span>
|
|
<Badge variant={stripeStatus.variant}>{stripeStatus.label}</Badge>
|
|
</span>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="left">{stripeStatus.description}</TooltipContent>
|
|
</Tooltip>
|
|
)}
|
|
|
|
{canUpdatePaymentMethods && !isSpt && (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
variant="outline"
|
|
className="hover:border-muted px-1"
|
|
icon={<MoreHorizontalIcon />}
|
|
aria-label="More options"
|
|
/>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-36">
|
|
{paymentMethodType === 'card' && !isActive && (
|
|
<>
|
|
<DropdownMenuItem
|
|
key="make-default"
|
|
onClick={() => setSelectedMethodForUse?.(paymentMethod)}
|
|
>
|
|
<p>Use this card</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
</>
|
|
)}
|
|
<DropdownMenuItemTooltip
|
|
key="delete-method"
|
|
disabled={!isRemovable}
|
|
className="pointer-events-auto!"
|
|
onClick={() => setSelectedMethodToDelete?.(paymentMethod)}
|
|
tooltip={{
|
|
content: {
|
|
side: 'left',
|
|
text: !isRemovable
|
|
? 'Unable to delete a card that is currently active'
|
|
: undefined,
|
|
},
|
|
}}
|
|
>
|
|
<p>Delete card</p>
|
|
</DropdownMenuItemTooltip>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default CreditCard
|