Files
supabase/apps/studio/components/interfaces/Database/Replication/PipelineStatePill.tsx
Danny White 1c85e3efb7 fix(studio): clarify OAuth permission labels (#53699)
## Problem

OAuth mixes abbreviated access levels with permission names whose
meaning is hard to infer.

## Solution

Use **Read and write** and **Read only** consistently, and add
keyboard-accessible definitions for Database management and Environment.
Reuse the dotted underline from Pipelines and document above-label
placement.

| Before | After |
| --- | --- |
| <img width="926" height="1936" alt="CleanShot 2026-11-20 at 12 20
42@2x"
src="https://github.com/user-attachments/assets/053b4afa-f428-4c0d-8f3b-dbc3f3dd5cf8"
/> | <img width="886" height="1902" alt="CleanShot 2026-11-20 at 12 21
20@2x"
src="https://github.com/user-attachments/assets/8277064b-1e73-43ff-b7b5-4d4af7d6c68f"
/> |
| _No tooltips, old “READ-WRITE”._ | _Tooltips for ambiguous
permissions, “READ AND WRITE” for clarity and to match setup
terminology._ |

## Review instructions

1. **Before:** Open the [Scoped OAuth
tester](https://api.supabase.green/v1/oauth/authorize?response_type=code&client_id=a3999bfe-cfc7-4584-9c5a-ab6828d35aa3&redirect_uri=http%3A%2F%2Flocalhost%3A8765%2Foauth%2Fcallback)
and leave consent open.
2. **After:** Open the [deploy preview consent
screen](https://studio-staging-git-dnywh-oauth-permission-labels-supabase.vercel.app/dashboard/authorize?auth_id=606dbb8e-60ea-4155-bb36-70a7d31378dd).

**What to check**

1. Open consent for a test app that requests database read/write,
environment read, and projects read access.
2. Check the small **Read and write** and **Read only** headings. Hover
or Tab to Database management and Environment. Each definition should
appear above its dotted-underlined label.
3. Optionally open an existing Pipeline and hover over an annotated
status label to check the shared underline.
2026-11-24 10:13:36 +11:00

94 lines
3.2 KiB
TypeScript

import { cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
import { getPipelineDisplayState, getStatusName } from './Pipeline.utils'
import type { PipelineDisplayType } from './Pipeline.utils'
import { PipelineStatusName } from './Replication.constants'
import { StateDot, type StateDotVariant } from '@/components/ui/StateDot'
import { TOOLTIP_UNDERLINE_CLASS_NAME } from '@/components/ui/tooltip-styles'
import { ReplicationPipelineStatusData } from '@/data/replication/pipeline-status-query'
import type { StudioError } from '@/lib/errors/studio-errors'
import { PipelineStatusRequestStatus } from '@/state/replication-pipeline-request-status'
const VARIANT_BY_TYPE: Record<PipelineDisplayType, StateDotVariant> = {
success: 'success',
failure: 'destructive',
loading: 'warning',
idle: 'default',
}
interface PipelineStatePillProps {
pipelineStatus: ReplicationPipelineStatusData['status'] | undefined
error: StudioError | null
isLoading: boolean
isError: boolean
isSuccess: boolean
requestStatus: PipelineStatusRequestStatus
projectRef?: string
pipelineId?: string
}
/**
* Status of a pipeline as a dot and label. The label carries a dotted underline because its
* explanation lives in the tooltip. Tooltips stay plain text (no links).
*/
export const PipelineStatePill = ({
pipelineStatus,
error,
isLoading,
isError,
isSuccess,
requestStatus,
}: PipelineStatePillProps) => {
const statusName = getStatusName(pipelineStatus)
const { type, message, label } = getPipelineDisplayState(requestStatus, statusName)
const isRequestPending = requestStatus !== PipelineStatusRequestStatus.None
const shouldShowError = isError && !isRequestPending
const shouldShowLogsHint =
isSuccess &&
!isRequestPending &&
[PipelineStatusName.UNKNOWN, PipelineStatusName.FAILED].includes(
statusName as PipelineStatusName
)
if (isLoading && !isRequestPending) {
return (
<span className="inline-flex" aria-live="polite" aria-atomic="true">
<span className="sr-only">Loading pipeline status</span>
<ShimmeringLoader className="h-5 w-20 py-0" />
</span>
)
}
let tooltipMessage = message
if (shouldShowError) {
tooltipMessage = `Unable to retrieve status: ${error?.message}`
} else if (shouldShowLogsHint) {
tooltipMessage = `${message}. Check the logs for more information.`
}
return (
<span className="inline-flex" aria-live="polite" aria-atomic="true">
<Tooltip>
<TooltipTrigger asChild>
<StateDot
tabIndex={0}
variant={shouldShowError ? 'default' : VARIANT_BY_TYPE[type]}
isPulsing={!shouldShowError && type === 'loading'}
labelClassName={cn('text-foreground-light', TOOLTIP_UNDERLINE_CLASS_NAME)}
>
{shouldShowError ? 'Unknown' : label}
</StateDot>
</TooltipTrigger>
<TooltipContent side="bottom" className="max-w-64">
{tooltipMessage}
{isError && isRequestPending && (
<span>{` Unable to refresh status: ${error?.message}.`}</span>
)}
</TooltipContent>
</Tooltip>
</span>
)
}