feat(lint): ban native title tooltips and migrate to styled Tooltip (#7209)
This commit is contained in:
1 parent
bab4b6f02b
commit
fee10def1a
27 files changed
+730
-355
No files matched your search
@@ -11,6 +11,7 @@ import { pullRequestEnvironment } from "~/state/pullRequests";
|
||||
import { useEnvironmentQuery } from "~/state/query";
|
||||
|
||||
import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
import {
|
||||
PullRequestCheckStatusIcon,
|
||||
pullRequestCheckStatusLabel,
|
||||
@@ -57,9 +58,12 @@ function ChecksBody({ checks }: { checks: ReadonlyArray<PullRequestCheck> }) {
|
||||
{checks.map((check, index) => (
|
||||
<li key={`${index}:${check.name}`} className="flex items-center gap-2 text-xs">
|
||||
<PullRequestCheckStatusIcon status={check.status} />
|
||||
<span className="min-w-0 flex-1 truncate" title={check.description ?? check.name}>
|
||||
{check.name}
|
||||
</span>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={<span className="min-w-0 flex-1 truncate">{check.name}</span>}
|
||||
/>
|
||||
<TooltipPopup side="top">{check.description ?? check.name}</TooltipPopup>
|
||||
</Tooltip>
|
||||
<span className="shrink-0 text-muted-foreground">
|
||||
{pullRequestCheckStatusLabel(check.status)}
|
||||
</span>
|
||||
|
||||
@@ -1006,9 +1006,12 @@ export function PullRequestCodeTab({
|
||||
>
|
||||
{/* Headlines run long, and the abbreviated oid after one is what a reader
|
||||
matches against the commit list on the host. */}
|
||||
<span className="min-w-0 truncate" title={entry.messageHeadline}>
|
||||
{entry.messageHeadline}
|
||||
</span>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={<span className="min-w-0 truncate">{entry.messageHeadline}</span>}
|
||||
/>
|
||||
<TooltipPopup side="top">{entry.messageHeadline}</TooltipPopup>
|
||||
</Tooltip>
|
||||
<span className="ml-auto shrink-0 font-mono text-xs text-muted-foreground">
|
||||
{entry.oid.slice(0, 7)}
|
||||
</span>
|
||||
@@ -1264,9 +1267,14 @@ export function PullRequestCodeTab({
|
||||
<div className="max-h-64 space-y-3 overflow-auto px-4 pb-3">
|
||||
{[...orphanFiles].map(([path, threads]) => (
|
||||
<div key={path}>
|
||||
<p className="truncate px-3 text-xs text-muted-foreground" title={path}>
|
||||
{path}
|
||||
</p>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<p className="truncate px-3 text-xs text-muted-foreground">{path}</p>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">{path}</TooltipPopup>
|
||||
</Tooltip>
|
||||
<div className="mt-1 space-y-2">
|
||||
{threads.map((thread) => (
|
||||
<div key={thread.id}>
|
||||
|
||||
@@ -85,6 +85,7 @@ import {
|
||||
} from "../ui/menu";
|
||||
import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover";
|
||||
import { toastManager } from "../ui/toast";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
import { PullRequestDetailGhost, PullRequestTimelineGhost } from "./PullRequestGhosts";
|
||||
import { PullRequestActivityUnavailableState } from "./PullRequestActivityUnavailableState";
|
||||
import { DiffPanelLoadingState } from "../DiffPanelShell";
|
||||
@@ -1086,22 +1087,31 @@ export function PullRequestDetailPanel({
|
||||
>
|
||||
{detail && statePresentation ? (
|
||||
<>
|
||||
<span className="min-w-0 truncate" title={detail.repository}>
|
||||
{detail.repository}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void readLocalApi()?.shell.openExternal(detail.url)}
|
||||
onContextMenu={(event) => openNumberContextMenu(event, detail)}
|
||||
className={cn(
|
||||
"shrink-0 font-medium underline-offset-2 hover:underline",
|
||||
statePresentation.toneClassName,
|
||||
)}
|
||||
title={openOnHostLabel(detail.provider)}
|
||||
aria-label={`Open pull request #${detail.number} on host`}
|
||||
>
|
||||
#{detail.number}
|
||||
</button>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={<span className="min-w-0 truncate">{detail.repository}</span>}
|
||||
/>
|
||||
<TooltipPopup side="top">{detail.repository}</TooltipPopup>
|
||||
</Tooltip>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void readLocalApi()?.shell.openExternal(detail.url)}
|
||||
onContextMenu={(event) => openNumberContextMenu(event, detail)}
|
||||
className={cn(
|
||||
"shrink-0 font-medium underline-offset-2 hover:underline",
|
||||
statePresentation.toneClassName,
|
||||
)}
|
||||
aria-label={`Open pull request #${detail.number} on host`}
|
||||
>
|
||||
#{detail.number}
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">{openOnHostLabel(detail.provider)}</TooltipPopup>
|
||||
</Tooltip>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
@@ -1117,23 +1127,36 @@ export function PullRequestDetailPanel({
|
||||
>
|
||||
{detail && statePresentation ? (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
tabIndex={condensed ? 0 : -1}
|
||||
onClick={() => void readLocalApi()?.shell.openExternal(detail.url)}
|
||||
onContextMenu={(event) => openNumberContextMenu(event, detail)}
|
||||
className={cn(
|
||||
"shrink-0 font-medium underline-offset-2 hover:underline",
|
||||
statePresentation.toneClassName,
|
||||
)}
|
||||
title={openOnHostLabel(detail.provider)}
|
||||
aria-label={`Open pull request #${detail.number} on host`}
|
||||
>
|
||||
#{detail.number}
|
||||
</button>
|
||||
<span className="min-w-0 truncate font-medium text-foreground" title={detail.title}>
|
||||
{detail.title}
|
||||
</span>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
tabIndex={condensed ? 0 : -1}
|
||||
onClick={() => void readLocalApi()?.shell.openExternal(detail.url)}
|
||||
onContextMenu={(event) => openNumberContextMenu(event, detail)}
|
||||
className={cn(
|
||||
"shrink-0 font-medium underline-offset-2 hover:underline",
|
||||
statePresentation.toneClassName,
|
||||
)}
|
||||
aria-label={`Open pull request #${detail.number} on host`}
|
||||
>
|
||||
#{detail.number}
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">{openOnHostLabel(detail.provider)}</TooltipPopup>
|
||||
</Tooltip>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<span className="min-w-0 truncate font-medium text-foreground">
|
||||
{detail.title}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">{detail.title}</TooltipPopup>
|
||||
</Tooltip>
|
||||
{conflicting ? (
|
||||
<Badge
|
||||
variant="error"
|
||||
@@ -1385,14 +1408,22 @@ export function PullRequestDetailPanel({
|
||||
{/* Said where the Merge button is, because it is the answer to why nobody has
|
||||
pressed it: the merge is already asked for, and the host is holding it. */}
|
||||
{autoMergeArmed ? (
|
||||
<Badge
|
||||
variant="info"
|
||||
className="h-5 shrink-0 gap-1 rounded px-1.5 text-[10px]"
|
||||
title="The host will merge this on its own once its requirements are met"
|
||||
>
|
||||
<GitMergeIcon aria-hidden className="size-3" />
|
||||
Auto-merge
|
||||
</Badge>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<Badge
|
||||
variant="info"
|
||||
className="h-5 shrink-0 gap-1 rounded px-1.5 text-[10px]"
|
||||
>
|
||||
<GitMergeIcon aria-hidden className="size-3" />
|
||||
Auto-merge
|
||||
</Badge>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">
|
||||
The host will merge this on its own once its requirements are met
|
||||
</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
{primaryAction === "ready" ? (
|
||||
<Button size="xs" disabled={actionPending} onClick={() => void perform("ready")}>
|
||||
@@ -1465,11 +1496,13 @@ export function PullRequestDetailPanel({
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
<span
|
||||
className="ml-auto inline-flex min-w-0 shrink items-center gap-1 font-mono text-[11px] text-muted-foreground"
|
||||
title={`${detail.baseBranch} ← ${detail.headBranch}`}
|
||||
>
|
||||
<span className="truncate">{detail.baseBranch}</span>
|
||||
<span className="ml-auto inline-flex min-w-0 shrink items-center gap-1 font-mono text-[11px] text-muted-foreground">
|
||||
<Tooltip>
|
||||
<TooltipTrigger render={<span className="truncate" />}>
|
||||
{detail.baseBranch}
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">{`${detail.baseBranch} ← ${detail.headBranch}`}</TooltipPopup>
|
||||
</Tooltip>
|
||||
{freshness ? (
|
||||
<PullRequestBaseFreshnessWarning
|
||||
baseBranch={detail.baseBranch}
|
||||
@@ -1480,7 +1513,12 @@ export function PullRequestDetailPanel({
|
||||
/>
|
||||
) : null}
|
||||
<ArrowLeftIcon aria-label="receives changes from" className="size-3 shrink-0" />
|
||||
<span className="truncate">{detail.headBranch}</span>
|
||||
<Tooltip>
|
||||
<TooltipTrigger render={<span className="truncate" />}>
|
||||
{detail.headBranch}
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">{`${detail.baseBranch} ← ${detail.headBranch}`}</TooltipPopup>
|
||||
</Tooltip>
|
||||
</span>
|
||||
<span className="ml-2 inline-flex shrink-0 items-center gap-2 text-[11px] text-muted-foreground">
|
||||
<span className="inline-flex items-center gap-1 tabular-nums">
|
||||
@@ -1594,12 +1632,16 @@ export function PullRequestDetailPanel({
|
||||
</PullRequestMetaLine>
|
||||
|
||||
<div className="mt-4 flex min-w-0 items-center gap-2 text-xs text-muted-foreground">
|
||||
<code
|
||||
className="min-w-0 max-w-48 shrink truncate rounded-md bg-muted px-2 py-1 font-mono text-xs text-foreground"
|
||||
title={detail.baseBranch}
|
||||
>
|
||||
{detail.baseBranch}
|
||||
</code>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<code className="min-w-0 max-w-48 shrink truncate rounded-md bg-muted px-2 py-1 font-mono text-xs text-foreground">
|
||||
{detail.baseBranch}
|
||||
</code>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">{detail.baseBranch}</TooltipPopup>
|
||||
</Tooltip>
|
||||
{freshness ? (
|
||||
<PullRequestBaseFreshnessWarning
|
||||
baseBranch={detail.baseBranch}
|
||||
@@ -1609,32 +1651,41 @@ export function PullRequestDetailPanel({
|
||||
/>
|
||||
) : null}
|
||||
<ArrowLeftIcon aria-label="receives changes from" className="size-4 shrink-0" />
|
||||
<button
|
||||
type="button"
|
||||
className="grid min-w-0 max-w-64 shrink cursor-pointer rounded-md bg-muted px-2 py-1 font-mono text-xs text-foreground outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"
|
||||
aria-label={isBranchCopied ? "Branch name copied" : "Copy pull request branch"}
|
||||
title={isBranchCopied ? "Copied" : "Copy pull request branch"}
|
||||
onClick={() => copyBranchToClipboard(detail.headBranch)}
|
||||
>
|
||||
<code
|
||||
className={cn(
|
||||
"col-start-1 row-start-1 min-w-0 truncate transition-opacity duration-150 motion-reduce:transition-none",
|
||||
isBranchCopied ? "opacity-0" : "opacity-100",
|
||||
)}
|
||||
title={detail.headBranch}
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
className="grid min-w-0 max-w-64 shrink cursor-pointer rounded-md bg-muted px-2 py-1 font-mono text-xs text-foreground outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"
|
||||
aria-label={
|
||||
isBranchCopied ? "Branch name copied" : "Copy pull request branch"
|
||||
}
|
||||
onClick={() => copyBranchToClipboard(detail.headBranch)}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{detail.headBranch}
|
||||
</code>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
"col-start-1 row-start-1 truncate text-center transition-opacity duration-150 motion-reduce:transition-none",
|
||||
isBranchCopied ? "opacity-100" : "opacity-0",
|
||||
)}
|
||||
>
|
||||
Copied
|
||||
</span>
|
||||
</button>
|
||||
<code
|
||||
className={cn(
|
||||
"col-start-1 row-start-1 min-w-0 truncate transition-opacity duration-150 motion-reduce:transition-none",
|
||||
isBranchCopied ? "opacity-0" : "opacity-100",
|
||||
)}
|
||||
>
|
||||
{detail.headBranch}
|
||||
</code>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
"col-start-1 row-start-1 truncate text-center transition-opacity duration-150 motion-reduce:transition-none",
|
||||
isBranchCopied ? "opacity-100" : "opacity-0",
|
||||
)}
|
||||
>
|
||||
Copied
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">
|
||||
{`${isBranchCopied ? "Copied" : "Copy pull request branch"}: ${detail.headBranch}`}
|
||||
</TooltipPopup>
|
||||
</Tooltip>
|
||||
<span className="ml-auto inline-flex shrink-0 items-center justify-end gap-2">
|
||||
<span className="inline-flex items-center gap-1.5 tabular-nums">
|
||||
<FileDiffIcon className="size-3.5" />
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
MenuSeparator,
|
||||
MenuTrigger,
|
||||
} from "../ui/menu";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
|
||||
export interface PullRequestFilterOption<Value extends string> {
|
||||
readonly value: Value;
|
||||
@@ -156,21 +157,32 @@ function PullRequestFilterRadioGroup<Value extends string>({
|
||||
}}
|
||||
>
|
||||
<MenuGroupLabel>{label}</MenuGroupLabel>
|
||||
{options.map((option) => (
|
||||
<MenuRadioItem
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
// A host the server has already said it cannot read is not a choice here: offering
|
||||
// it would answer the press by replacing a working list with that failure.
|
||||
disabled={option.unavailable !== undefined}
|
||||
title={option.unavailable}
|
||||
>
|
||||
<span className="flex min-w-0 items-center gap-2">
|
||||
<option.Icon aria-hidden className="size-3.5" />
|
||||
{option.label}
|
||||
</span>
|
||||
</MenuRadioItem>
|
||||
))}
|
||||
{options.map((option) => {
|
||||
// A host the server has already said it cannot read is not a choice here: offering
|
||||
// it would answer the press by replacing a working list with that failure.
|
||||
const item = (
|
||||
<MenuRadioItem
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
className={option.unavailable ? "data-disabled:pointer-events-auto" : undefined}
|
||||
disabled={option.unavailable !== undefined}
|
||||
>
|
||||
<span className="flex min-w-0 items-center gap-2">
|
||||
<option.Icon aria-hidden className="size-3.5" />
|
||||
{option.label}
|
||||
</span>
|
||||
</MenuRadioItem>
|
||||
);
|
||||
if (!option.unavailable) return item;
|
||||
return (
|
||||
<Tooltip key={option.value}>
|
||||
<TooltipTrigger render={item} />
|
||||
<TooltipPopup side="top" className="max-w-80">
|
||||
{option.unavailable}
|
||||
</TooltipPopup>
|
||||
</Tooltip>
|
||||
);
|
||||
})}
|
||||
</MenuRadioGroup>
|
||||
);
|
||||
}
|
||||
@@ -375,12 +387,12 @@ export function PullRequestFiltersMenu({
|
||||
)
|
||||
.map((project) => {
|
||||
const reason = unavailable.get(pullRequestProjectKey(project));
|
||||
return (
|
||||
const item = (
|
||||
<MenuRadioItem
|
||||
key={pullRequestProjectKey(project)}
|
||||
value={pullRequestProjectKey(project)}
|
||||
className={reason !== undefined ? "data-disabled:pointer-events-auto" : undefined}
|
||||
disabled={reason !== undefined}
|
||||
title={reason}
|
||||
>
|
||||
<span className="flex min-w-0 flex-1 items-center gap-2">
|
||||
<ProjectFavicon
|
||||
@@ -398,6 +410,15 @@ export function PullRequestFiltersMenu({
|
||||
</span>
|
||||
</MenuRadioItem>
|
||||
);
|
||||
if (reason === undefined) return item;
|
||||
return (
|
||||
<Tooltip key={pullRequestProjectKey(project)}>
|
||||
<TooltipTrigger render={item} />
|
||||
<TooltipPopup side="top" className="max-w-80">
|
||||
{reason}
|
||||
</TooltipPopup>
|
||||
</Tooltip>
|
||||
);
|
||||
})}
|
||||
</MenuRadioGroup>
|
||||
</MenuPopup>
|
||||
|
||||
@@ -172,9 +172,14 @@ function CollapsedComment({
|
||||
{open ? (
|
||||
<div className="px-3 pb-3">
|
||||
{comment.path ? (
|
||||
<p className="truncate text-xs text-muted-foreground" title={comment.path}>
|
||||
{comment.path}
|
||||
</p>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<p className="truncate text-xs text-muted-foreground">{comment.path}</p>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">{comment.path}</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
<CommentBody className="mt-2" comment={comment} editing={editing} />
|
||||
{reactionBar}
|
||||
@@ -475,6 +480,7 @@ export function PullRequestSummaryTab({
|
||||
>
|
||||
<PullRequestActorLabel
|
||||
actor={actor}
|
||||
tooltip={false}
|
||||
className="gap-0 [&>img]:ring-2 [&>img]:ring-background [&>span:first-child]:ring-2 [&>span:first-child]:ring-background [&>span:last-child]:sr-only"
|
||||
/>
|
||||
</TooltipTrigger>
|
||||
@@ -754,12 +760,16 @@ export function PullRequestSummaryTab({
|
||||
) : null}
|
||||
</div>
|
||||
{comment.path ? (
|
||||
<p
|
||||
className="mt-1 truncate text-xs text-muted-foreground"
|
||||
title={comment.path}
|
||||
>
|
||||
{comment.path}
|
||||
</p>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<p className="mt-1 truncate text-xs text-muted-foreground">
|
||||
{comment.path}
|
||||
</p>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">{comment.path}</TooltipPopup>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
<CommentBody className="mt-2" comment={comment} editing={commentEditing} />
|
||||
<PullRequestReactionBar
|
||||
|
||||
@@ -226,16 +226,31 @@ export function PullRequestActorAvatar({
|
||||
export function PullRequestActorLabel({
|
||||
actor,
|
||||
className,
|
||||
tooltip = true,
|
||||
}: {
|
||||
actor: PullRequestActor | null;
|
||||
className?: string;
|
||||
tooltip?: boolean;
|
||||
}) {
|
||||
const login = actor?.login ?? "ghost";
|
||||
return (
|
||||
<span className={cn("flex min-w-0 items-center gap-1.5", className)} title={login}>
|
||||
const label = (
|
||||
<>
|
||||
<PullRequestActorAvatar actor={actor} />
|
||||
<span className="truncate">{login}</span>
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
if (!tooltip) {
|
||||
return <span className={cn("flex min-w-0 items-center gap-1.5", className)}>{label}</span>;
|
||||
}
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={<span className={cn("flex min-w-0 items-center gap-1.5", className)} />}
|
||||
>
|
||||
{label}
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">{login}</TooltipPopup>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user