Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ScopedThreadRef, ThreadPullRequestLink } from "@t3tools/contracts";
import {
normalizeThreadPullRequestKey,
resolveThreadPullRequestChains,
visibleThreadPullRequests,
} from "@t3tools/shared/threadPullRequests";
Expand Down Expand Up @@ -66,10 +67,16 @@ function ChecksGlyph({
function LinkRow({
line,
threadRef,
repositoryLabel,
onUnlink,
}: {
line: PullRequestListLine;
threadRef: ScopedThreadRef;
/**
* How much of the repository identity to show: none when the thread links a single
* repository, the host too when its links span hosts.
*/
repositoryLabel: "none" | "repository" | "host";
onUnlink: (link: ThreadPullRequestLink) => void;
}) {
const openPrLink = useOpenPrLink(threadRef);
Expand Down Expand Up @@ -160,6 +167,13 @@ function LinkRow({
labelClassName="max-w-28"
/>
) : null}
{repositoryLabel !== "none" && snapshot !== null ? (
// Never truncated: it is what tells otherwise alike rows apart, and the branches
// beside it already give way with a middle ellipsis.
<span className="shrink-0">
{repositoryLabel === "host" ? `${link.host}/${link.repository}` : link.repository}
</span>
) : null}
{snapshot !== null ? (
<PullRequestRowBranches head={snapshot.headBranch} base={snapshot.baseBranch} />
) : (
Expand Down Expand Up @@ -239,6 +253,13 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
const unlink = useAtomCommand(threadEnvironment.unlinkPullRequest, { reportFailure: true });
const links = useMemo(() => visibleThreadPullRequests(thread?.pullRequests ?? []), [thread]);
const lines = useMemo(() => pullRequestListLines(resolveThreadPullRequestChains(links)), [links]);
const repositoryLabel = useMemo(() => {
const keys = links.map(normalizeThreadPullRequestKey);
const repositories = new Set(keys.map((key) => `${key.host}/${key.repository}`));
if (repositories.size < 2) return "none";
const hosts = new Set(keys.map((key) => key.host));
return hosts.size > 1 ? "host" : "repository";
}, [links]);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
const handleUnlink = useCallback(
(link: ThreadPullRequestLink) => {
void unlink({
Expand Down Expand Up @@ -292,6 +313,7 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
key={`${line.link.host}/${line.link.repository}#${line.link.number}`}
line={line}
threadRef={threadRef}
repositoryLabel={repositoryLabel}
onUnlink={handleUnlink}
/>
))}
Expand Down
Loading