Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
import { ChevronDown, ChevronUp, MessagesSquare, X } from "lucide-react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
import { Tooltip } from "@/components/ui/tooltip";
// Touch has no hover and keeps focus on the tapped arrow, so coarse pointers
// get no ring: the flash on the target card is the feedback there.
// The strip takes its height from the shared "sm" buttons.
const ARROW_CLASS =
"rounded-none border-l border-control-border text-control-light hover:text-control focus-visible:ring-inset focus-visible:ring-offset-0 pointer-coarse:focus-visible:ring-0";
// Steps through the unresolved threads placed on the displayed statement, or
// with a filter, through one reviewer's findings in one state across the
// plan. `count` is what the arrows can visit; `remainder` is how many of this
// change's matching threads are not placed on this version.
export function StatementThreadWalker({
announcement,
count,
filterLabel,
onClearFilter,
position,
onNext,
onPrevious,
remainder,
}: {
announcement: string;
count: number;
filterLabel?: string;
onClearFilter?: () => void;
position: number;
onNext: () => void;
onPrevious: () => void;
remainder: number;
}) {
const { t } = useTranslation();
const title = [
t("plan.review.thread.walker.count", { count }),
remainder > 0
? t("plan.review.thread.walker.remainder", { count: remainder })
: undefined,
]
.filter(Boolean)
.join(" · ");
return (
<div
className="flex items-stretch overflow-hidden rounded-sm border border-control-border bg-background text-xs shadow-sm pointer-coarse:shadow-none"
data-testid="thread-walker"
>
<Tooltip
content={title}
render={
<span
aria-label={title}
className="inline-flex items-center gap-1 px-2 font-medium text-accent tabular-nums"
tabIndex={0}
/>
}
>
<MessagesSquare className="size-3.5" />
{filterLabel && <span className="text-control">{filterLabel}</span>}
{position}/{count}
</Tooltip>
<Button
appearance="secondary"
aria-label={t("plan.review.thread.walker.previous")}
className={ARROW_CLASS}
onClick={onPrevious}
size="sm"
>
<ChevronUp className="size-4" />
</Button>
<Button
appearance="secondary"
aria-label={t("plan.review.thread.walker.next")}
className={ARROW_CLASS}
onClick={onNext}
size="sm"
>
<ChevronDown className="size-4" />
</Button>
{filterLabel && onClearFilter && (
<Button
appearance="secondary"
aria-label={t("plan.review.thread.walker.clear-filter")}
className={ARROW_CLASS}
onClick={onClearFilter}
size="sm"
>
<X className="size-4" />
</Button>
)}
<span aria-live="polite" className="sr-only">
{announcement}
</span>
</div>
);
}