mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45: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
105 lines
3.3 KiB
TypeScript
105 lines
3.3 KiB
TypeScript
import { LOCAL_STORAGE_KEYS, useParams } from 'common'
|
|
import { CircleHelpIcon, Undo2, X } from 'lucide-react'
|
|
import { useRouter } from 'next/router'
|
|
import { Badge, Button, cn } from 'ui'
|
|
|
|
import {
|
|
useFeaturePreviewModal,
|
|
useUnifiedLogsPreview,
|
|
} from '../App/FeaturePreview/FeaturePreviewContext'
|
|
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
|
|
import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
|
|
import { IS_PLATFORM } from '@/lib/constants'
|
|
|
|
interface UnifiedLogsBannerProps {
|
|
className?: string
|
|
}
|
|
|
|
export function UnifiedLogsBanner({ className = 'mx-4 mt-4' }: UnifiedLogsBannerProps) {
|
|
const router = useRouter()
|
|
const { ref } = useParams()
|
|
|
|
const { selectFeaturePreview } = useFeaturePreviewModal()
|
|
const { enable, disable, isDefaultOptIn, isEnabled } = useUnifiedLogsPreview()
|
|
const [isDismissed, setIsDismissed] = useLocalStorageQuery(
|
|
LOCAL_STORAGE_KEYS.UNIFIED_LOGS_SIDEBAR_BANNER_DISMISSED,
|
|
false
|
|
)
|
|
|
|
if (!IS_PLATFORM) return null
|
|
|
|
// Keep the "Go back" banner visible even after dismissal so manually opted-in users can switch back
|
|
if (isDismissed && !(isEnabled && !isDefaultOptIn)) return null
|
|
|
|
const cardClassName = cn(
|
|
'rounded-lg border p-4 space-y-3 text-left',
|
|
'bg-muted/10 border-border/50',
|
|
className
|
|
)
|
|
|
|
const onSwitchBack = () => {
|
|
disable()
|
|
router.push(`/project/${ref}/logs/explorer`)
|
|
}
|
|
|
|
const onEnable = () => {
|
|
enable()
|
|
router.push(`/project/${ref}/logs`)
|
|
}
|
|
|
|
if (isEnabled && !isDefaultOptIn) {
|
|
return (
|
|
<div className={cn('rounded-lg border px-4 py-3', 'bg-muted/10 border-border/50', className)}>
|
|
<div className="flex items-center justify-between gap-3">
|
|
<p className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">
|
|
Go back to old logs
|
|
</p>
|
|
<ButtonTooltip
|
|
className="shrink-0 px-1.5"
|
|
icon={<Undo2 />}
|
|
onClick={onSwitchBack}
|
|
tooltip={{ content: { side: 'bottom', text: 'Switch back' } }}
|
|
/>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<div className={cardClassName}>
|
|
<div className="flex items-start justify-between">
|
|
<Badge variant="success">New</Badge>
|
|
<Button
|
|
variant="text"
|
|
size="tiny"
|
|
icon={<X size={14} strokeWidth={1.5} />}
|
|
onClick={() => setIsDismissed(true)}
|
|
className="opacity-75 hover:opacity-100 -mt-1 -mr-1 px-1"
|
|
aria-label="Dismiss banner"
|
|
/>
|
|
</div>
|
|
<h3 className="font-medium text-sm text-foreground">Introducing unified logs</h3>
|
|
<div className="flex justify-start items-start gap-x-2">
|
|
{isDefaultOptIn ? (
|
|
<Button
|
|
icon={<CircleHelpIcon />}
|
|
onClick={() => selectFeaturePreview('supabase-ui-preview-unified-logs')}
|
|
>
|
|
More information
|
|
</Button>
|
|
) : (
|
|
<>
|
|
<Button onClick={onEnable}>Enable preview</Button>
|
|
<ButtonTooltip
|
|
className="px-1.5"
|
|
icon={<CircleHelpIcon />}
|
|
onClick={() => selectFeaturePreview('supabase-ui-preview-unified-logs')}
|
|
tooltip={{ content: { side: 'bottom', text: 'More information' } }}
|
|
/>
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|