mirror of
https://github.com/supabase/supabase.git
synced 2026-09-22 13:37:53 +08:00
a31ca2bad0
## What kind of change does this PR introduce? Bug fix and design-system update. Resolves DEPR-316. Follow-up rename (`text-brand` → `text-primary`) is in a dedicated PR (https://github.com/supabase/supabase/pull/50564) stacked on this one. ## What is the current behavior? `text-brand` resolves to the canonical bright brand green in places that need readable text, which fails WCAG AA on light surfaces. A separate `text-brand-display` token adds another green for large type. ## What is the new behavior? - `text-brand` maps to accessible `--primary` (light mode darkened to meet ~4.5:1 AA) - `--hue` / `--primary-hue` aligned to 157.5 - `text-brand-display` removed; former display callsites use `text-brand` - Bright fills/borders stay on `brand-default` - Design-system colour and typography docs updated | Before | After | | --- | --- | | <img width="514" height="112" alt="CleanShot 2026-09-02 at 11 13 09@2x" src="https://github.com/user-attachments/assets/4e0138a9-a32d-4e4c-a426-90736706e1e7" /> | <img width="512" height="138" alt="CleanShot 2026-09-21 at 11 42 05@2x" src="https://github.com/user-attachments/assets/164cc5b1-a0c5-4e93-95f1-80016641a114" /> | | <img width="864" height="266" alt="CleanShot 2026-09-02 at 11 13 53@2x" src="https://github.com/user-attachments/assets/3c1ca53f-bf9e-431e-bc15-816b4a275b8e" /> | <img width="882" height="248" alt="CleanShot 2026-09-21 at 11 41 37@2x" src="https://github.com/user-attachments/assets/24828e7b-ed6b-44cb-b9dc-becc3398bdfc" /> | | <img width="782" height="692" alt="CleanShot 2026-09-02 at 11 16 30@2x" src="https://github.com/user-attachments/assets/fc871977-77bc-47fb-9e0e-9284e0ecd5cc" /> | <img width="730" height="690" alt="CleanShot 2026-09-21 at 11 42 52@2x" src="https://github.com/user-attachments/assets/bf479515-d5f9-471e-b82d-f097c0f4b56c" /> | | <img width="480" height="306" alt="CleanShot 2026-09-02 at 11 18 53@2x" src="https://github.com/user-attachments/assets/03f341f4-f02e-44f8-a2b2-8c31670d0427" /> | <img width="470" height="300" alt="CleanShot 2026-09-21 at 11 43 19@2x" src="https://github.com/user-attachments/assets/9df18217-d5e6-48b8-ba0b-579d2664b94b" /> | | <img width="960" height="300" alt="CleanShot 2026-09-02 at 11 32 04@2x" src="https://github.com/user-attachments/assets/6b1d9373-7a71-4247-81ff-26441604b09d" /> | <img width="980" height="306" alt="CleanShot 2026-09-21 at 11 44 13@2x" src="https://github.com/user-attachments/assets/41ad4784-02ec-4b29-b860-32af9fa79aa8" /> | | <img width="924" height="214" alt="CleanShot 2026-09-02 at 11 34 44@2x" src="https://github.com/user-attachments/assets/1de661fe-c7b6-499b-a94f-e4737436ec79" /> | <img width="752" height="162" alt="CleanShot 2026-09-21 at 11 44 56@2x" src="https://github.com/user-attachments/assets/1811890f-0660-4445-84e9-447720954fa1" /> | ## To test Test each callsite **in light mode** (dark mode is largely unchanged). ### WWW - [Homepage](https://zone-www-dot-com-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/): “Scale to millions” uses readable brand text (display token is gone) - [Careers](https://zone-www-dot-com-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/careers): small “Careers” eyebrow readable; green dividers stay bright `brand-default` - [Contact](https://zone-www-dot-com-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/contact-us): email / policy links use readable brand text - [Regions](https://zone-www-dot-com-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/regions): “Ask about early access to BYOC” readable ### Docs - [Docs homepage](https://docs-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs): “DOCS” wordmark and resource links readable - [Database overview](https://docs-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs/guides/database/overview): nav / footer brand links readable - [JavaScript reference](https://docs-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs/reference/javascript/introduction): active sidebar treatment readable ### Design system - [Typography](https://design-system-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs/typography): documents `text-brand` only (no display) - [Colour usage](https://design-system-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/docs/color-usage): `text-brand` vs `bg-brand-default` - [Design-system homepage](https://design-system-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/): brand text examples across themes ### Studio - [Auth providers](https://studio-staging-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/dashboard/project/_/auth/providers): enabled provider badge text readable; status dot stays bright - [Database policies](https://studio-staging-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/dashboard/project/_/database/policies?new=true): template hover text more legible - [Database connections](https://studio-staging-git-dnywh-depr-316-brand-text-tokens-supabase.vercel.app/dashboard/project/_/observability/connections): “Live” status readable; animated dot stays bright green --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
241 lines
7.7 KiB
TypeScript
241 lines
7.7 KiB
TypeScript
import { useParams } from 'common'
|
|
import {
|
|
ArrowUpCircle,
|
|
CircleStop,
|
|
Edit,
|
|
Eye,
|
|
MoreVertical,
|
|
Play,
|
|
RotateCcw,
|
|
Trash,
|
|
} from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { parseAsInteger, useQueryState } from 'nuqs'
|
|
import { toast } from 'sonner'
|
|
import {
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
WarningIcon,
|
|
} from 'ui'
|
|
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
|
|
|
|
import { getStatusName } from './Pipeline.utils'
|
|
import { PipelineStatusName } from './Replication.constants'
|
|
import { ReplicationPipelineStatusData } from '@/data/replication/pipeline-status-query'
|
|
import { Pipeline } from '@/data/replication/pipelines-query'
|
|
import { useRestartPipelineMutation } from '@/data/replication/restart-pipeline-mutation'
|
|
import { useStartPipelineMutation } from '@/data/replication/start-pipeline-mutation'
|
|
import { useStopPipelineMutation } from '@/data/replication/stop-pipeline-mutation'
|
|
import {
|
|
PipelineStatusRequestStatus,
|
|
usePipelineRequestStatus,
|
|
} from '@/state/replication-pipeline-request-status'
|
|
import type { ResponseError } from '@/types'
|
|
|
|
interface RowMenuProps {
|
|
destinationId: number
|
|
pipeline: Pipeline | undefined
|
|
pipelineStatus?: ReplicationPipelineStatusData['status']
|
|
error: ResponseError | null
|
|
isLoading: boolean
|
|
isError: boolean
|
|
hasUpdate?: boolean
|
|
onDeleteClick: () => void
|
|
onUpdateClick?: () => void
|
|
}
|
|
|
|
export const RowMenu = ({
|
|
destinationId,
|
|
pipeline,
|
|
pipelineStatus,
|
|
error,
|
|
isLoading,
|
|
isError,
|
|
hasUpdate = false,
|
|
onDeleteClick,
|
|
onUpdateClick,
|
|
}: RowMenuProps) => {
|
|
const { ref: projectRef } = useParams()
|
|
const statusName = getStatusName(pipelineStatus)
|
|
|
|
const [, setEdit] = useQueryState(
|
|
'edit',
|
|
parseAsInteger.withOptions({ history: 'push', clearOnDefault: true })
|
|
)
|
|
|
|
const { mutateAsync: startPipeline } = useStartPipelineMutation({ onError: () => {} })
|
|
const { mutateAsync: stopPipeline } = useStopPipelineMutation({ onError: () => {} })
|
|
const { mutateAsync: restartPipeline } = useRestartPipelineMutation()
|
|
const { getRequestStatus, isRequestPending, runWithRequestStatus } = usePipelineRequestStatus()
|
|
const requestStatus = pipeline?.id
|
|
? getRequestStatus(pipeline.id)
|
|
: PipelineStatusRequestStatus.None
|
|
|
|
const isPipelineRequestPending = !!pipeline && isRequestPending(pipeline.id)
|
|
|
|
// Show actions when not in a transitional state
|
|
const canPerformActions =
|
|
!isError &&
|
|
!!pipeline &&
|
|
!isPipelineRequestPending &&
|
|
requestStatus === PipelineStatusRequestStatus.None &&
|
|
statusName !== PipelineStatusName.STARTING &&
|
|
[PipelineStatusName.STOPPED, PipelineStatusName.STARTED, PipelineStatusName.FAILED].includes(
|
|
statusName as PipelineStatusName
|
|
)
|
|
|
|
// Show both stop and restart for started/failed states
|
|
const showStopAndRestart =
|
|
canPerformActions &&
|
|
(statusName === PipelineStatusName.STARTED || statusName === PipelineStatusName.FAILED)
|
|
|
|
// Show only start for stopped state
|
|
const showStart = canPerformActions && statusName === PipelineStatusName.STOPPED
|
|
|
|
const onEnablePipeline = async () => {
|
|
if (!projectRef) return console.error('Project ref is required')
|
|
if (!pipeline) return toast.error('No pipeline found')
|
|
|
|
try {
|
|
await runWithRequestStatus(pipeline.id, PipelineStatusRequestStatus.StartRequested, () =>
|
|
startPipeline({ projectRef, pipelineId: pipeline.id })
|
|
)
|
|
} catch (error) {
|
|
toast.error(`Failed to start pipeline: ${(error as ResponseError).message}`)
|
|
}
|
|
}
|
|
|
|
const onDisablePipeline = async () => {
|
|
if (!projectRef) return console.error('Project ref is required')
|
|
if (!pipeline) return toast.error('No pipeline found')
|
|
|
|
try {
|
|
await runWithRequestStatus(pipeline.id, PipelineStatusRequestStatus.StopRequested, () =>
|
|
stopPipeline({ projectRef, pipelineId: pipeline.id })
|
|
)
|
|
} catch (error) {
|
|
toast.error(`Failed to stop pipeline: ${(error as ResponseError).message}`)
|
|
}
|
|
}
|
|
|
|
const onRestartPipeline = async () => {
|
|
if (!projectRef) return console.error('Project ref is required')
|
|
if (!pipeline) return toast.error('No pipeline found')
|
|
|
|
try {
|
|
await runWithRequestStatus(pipeline.id, PipelineStatusRequestStatus.StopRequested, () =>
|
|
restartPipeline({ projectRef, pipelineId: pipeline.id })
|
|
)
|
|
} catch (error) {
|
|
toast.error(`Failed to restart pipeline: ${(error as ResponseError).message}`)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="flex justify-end items-center space-x-2">
|
|
{isLoading && <ShimmeringLoader />}
|
|
|
|
{isError && (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<span className="flex items-center" tabIndex={0}>
|
|
<WarningIcon />
|
|
</span>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="bottom" className="max-w-xs">
|
|
Couldn't load status{error?.message ? `: ${error.message}` : '.'}
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
)}
|
|
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<div className="relative">
|
|
<Button
|
|
variant="default"
|
|
className="px-1.25 hit-area-2"
|
|
aria-label={hasUpdate ? 'Pipeline options, update available' : 'Pipeline options'}
|
|
icon={<MoreVertical />}
|
|
/>
|
|
{hasUpdate && (
|
|
<span
|
|
className="absolute -top-0.5 -right-0.5 h-2 w-2 bg-brand-default rounded-full"
|
|
aria-hidden
|
|
/>
|
|
)}
|
|
</div>
|
|
</DropdownMenuTrigger>
|
|
|
|
<DropdownMenuContent side="bottom" align="end" className="w-44">
|
|
<DropdownMenuItem className="space-x-2" asChild disabled={!pipeline}>
|
|
<Link href={`/project/${projectRef}/database/replication/${pipeline?.id}`}>
|
|
<Eye size={14} />
|
|
<p>View details</p>
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
{hasUpdate && (
|
|
<>
|
|
<DropdownMenuItem
|
|
className="space-x-2"
|
|
onClick={() => onUpdateClick?.()}
|
|
disabled={isPipelineRequestPending}
|
|
>
|
|
<ArrowUpCircle size={14} />
|
|
<p>Update available</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
</>
|
|
)}
|
|
{showStart && (
|
|
<>
|
|
<DropdownMenuItem className="space-x-2" onClick={onEnablePipeline}>
|
|
<Play size={14} />
|
|
<p>Start pipeline</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
</>
|
|
)}
|
|
{showStopAndRestart && (
|
|
<>
|
|
<DropdownMenuItem className="space-x-2" onClick={onRestartPipeline}>
|
|
<RotateCcw size={14} />
|
|
<p>Restart pipeline</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem className="space-x-2" onClick={onDisablePipeline}>
|
|
<CircleStop size={14} />
|
|
<p>Stop pipeline</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
</>
|
|
)}
|
|
|
|
<DropdownMenuItem
|
|
className="space-x-2"
|
|
onClick={() => setEdit(destinationId)}
|
|
disabled={isPipelineRequestPending}
|
|
>
|
|
<Edit size={14} />
|
|
<p>Edit pipeline</p>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem
|
|
className="space-x-2"
|
|
onClick={onDeleteClick}
|
|
disabled={isPipelineRequestPending}
|
|
>
|
|
<Trash size={14} />
|
|
<p>Delete pipeline</p>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</div>
|
|
)
|
|
}
|