mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
## What kind of change does this PR introduce? Mechanical cleanup on top of the Button default-variant change (#50160). ## What is the current behavior? Many callsites still pass `variant="default"` even though that is now the component default. ## What is the new behavior? Removes redundant static `variant="default"` from legacy `Button` and `ButtonTooltip` callsites. Keeps explicit defaults where they document the API: - `button-default.tsx` and `button-sizes.tsx` demos - `DocsButton`, which pins neutral styling at the wrapper boundary ## To test Studio: - [Auth → Rate Limits](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/auth/rate-limits): dirty the form so Cancel appears; Cancel stays neutral, Save stays green - [Project Settings → API Keys](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/settings/api-keys): `DocsButton` in the header actions stays neutral Design system: - [Design system → Button](https://design-system-git-dnywh-dc924ac1-supabase.vercel.app/design-system/docs/components/button): `button-default` / `button-sizes` still show explicit default styling; Primary (green) is restricted to the Primary section (and `asChild`) WWW: - [www → Brand assets](https://zone-www-dot-com-git-dnywh-dc924ac1-supabase.vercel.app/brand-assets): Download logo kit / Download button kit stay neutral
117 lines
3.9 KiB
TypeScript
117 lines
3.9 KiB
TypeScript
import { Archive, ArchiveRestoreIcon, ExternalLink } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { Button } from 'ui'
|
|
|
|
import { Markdown } from '@/components/interfaces/Markdown'
|
|
import { Notification, NotificationData } from '@/data/notifications/notifications-v2-query'
|
|
import { useOrganizationsQuery } from '@/data/organizations/organizations-query'
|
|
import { useProjectDetailQuery } from '@/data/projects/project-detail-query'
|
|
|
|
interface NotificationDetailProps {
|
|
notification: Notification
|
|
onUpdateStatus: (id: string, status: 'archived' | 'seen') => void
|
|
}
|
|
|
|
export const NotificationDetail = ({ notification, onUpdateStatus }: NotificationDetailProps) => {
|
|
const data = notification.data as NotificationData
|
|
|
|
const { data: project } = useProjectDetailQuery({ ref: data.project_ref })
|
|
const { data: organizations } = useOrganizationsQuery()
|
|
|
|
const organization =
|
|
data.org_slug !== undefined
|
|
? organizations?.find((org) => org.slug === data.org_slug)
|
|
: project !== undefined
|
|
? organizations?.find((org) => org.id === project.organization_id)
|
|
: undefined
|
|
|
|
const onButtonAction = (type?: string) => {
|
|
// [Joshen] Implement accordingly - BE team will need to give us a heads up on this
|
|
console.log('Action', type)
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
{(project !== undefined || organization !== undefined) && (
|
|
<>
|
|
<h3 className="text-sm mb-2">Context</h3>
|
|
<div className="flex items-center gap-2 flex-wrap mb-6">
|
|
{organization !== undefined && (
|
|
<Link
|
|
title={organization.name}
|
|
href={`/org/${organization.slug}/general`}
|
|
className="text-sm text-link"
|
|
>
|
|
{organization.name}
|
|
</Link>
|
|
)}
|
|
{project !== undefined && (
|
|
<Link
|
|
title={project.name}
|
|
href={`/project/${project.ref}`}
|
|
className="text-sm text-link"
|
|
>
|
|
{project.name}
|
|
</Link>
|
|
)}
|
|
</div>
|
|
</>
|
|
)}
|
|
|
|
{data.message !== undefined && (
|
|
<>
|
|
<h3 className="text-sm mb-2">Message</h3>
|
|
<Markdown
|
|
className="leading-6 text-sm text-foreground-light mb-6"
|
|
content={data.message}
|
|
/>
|
|
</>
|
|
)}
|
|
|
|
<h3 className="text-sm mb-2">Actions</h3>
|
|
<div className="flex items-center gap-2">
|
|
{(data.actions ?? []).map((action, idx) => {
|
|
const key = `${notification.id}-action-${idx}`
|
|
if (action.url !== undefined) {
|
|
const url = action.url.includes('[ref]')
|
|
? action.url.replace('[ref]', project?.ref ?? data.project_ref ?? '_')
|
|
: action.url.includes('[slug]')
|
|
? action.url.replace('[slug]', organization?.slug ?? data.org_slug ?? '_')
|
|
: action.url
|
|
return (
|
|
<Button key={key} icon={<ExternalLink strokeWidth={1.5} />} asChild>
|
|
<Link href={url} target="_blank" rel="noreferrer">
|
|
{action.label}
|
|
</Link>
|
|
</Button>
|
|
)
|
|
} else if (action.action_type !== undefined) {
|
|
return (
|
|
<Button key={key} onClick={() => onButtonAction(action.action_type)}>
|
|
{action.label}
|
|
</Button>
|
|
)
|
|
} else {
|
|
return null
|
|
}
|
|
})}
|
|
{notification.status === 'archived' ? (
|
|
<Button
|
|
icon={<ArchiveRestoreIcon size={14} strokeWidth={1.5} />}
|
|
onClick={() => onUpdateStatus(notification.id, 'seen')}
|
|
>
|
|
Unarchive
|
|
</Button>
|
|
) : (
|
|
<Button
|
|
icon={<Archive size={14} strokeWidth={1.5} />}
|
|
onClick={() => onUpdateStatus(notification.id, 'archived')}
|
|
>
|
|
Archive
|
|
</Button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|