Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion apps/dashboard/src/components/layouts/dashboard-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
ArchiveIcon,
ChevronRightIcon,
CloseIcon,
GitCommitIcon,
GitPullRequestIcon,
IssuesIcon,
Remove01Icon,
Expand Down Expand Up @@ -33,6 +34,7 @@ const tabIconMap = {
issue: IssuesIcon,
review: ReviewsIcon,
repo: ArchiveIcon,
commit: GitCommitIcon,
} as const;

function useScrollShadows(tabCount: number) {
Expand Down Expand Up @@ -371,7 +373,7 @@ const DetailTab = memo(function DetailTab({
/>
)}
<span className="max-w-32 truncate">{tab.title}</span>
{tab.type === "review" ? (
{tab.type === "review" || tab.type === "commit" ? (
<span className="flex items-center gap-1 font-mono text-[11px] font-medium tabular-nums">
{tab.additions != null && (
<span className="text-green-500">+{tab.additions}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const ReviewFileDiffBlock = memo(function ReviewFileDiffBlock({
file,
diffStyle,
isNearViewport,
readOnly = false,
annotations,
repliesByCommentId,
owner,
Expand All @@ -103,6 +104,7 @@ export const ReviewFileDiffBlock = memo(function ReviewFileDiffBlock({
file: PullFile;
diffStyle: "unified" | "split";
isNearViewport: boolean;
readOnly?: boolean;
annotations: DiffLineAnnotation<PullReviewComment>[];
repliesByCommentId: ReadonlyMap<number, PullReviewComment[]>;
owner: string;
Expand Down Expand Up @@ -131,6 +133,10 @@ export const ReviewFileDiffBlock = memo(function ReviewFileDiffBlock({
);

const allAnnotations = useMemo(() => {
if (readOnly) {
return [] as DiffLineAnnotation<ReviewAnnotation>[];
}

const result: DiffLineAnnotation<ReviewAnnotation>[] = [...annotations];

for (const pending of pendingComments) {
Expand All @@ -157,7 +163,7 @@ export const ReviewFileDiffBlock = memo(function ReviewFileDiffBlock({
}

return result;
}, [annotations, pendingComments, activeCommentForm]);
}, [readOnly, annotations, pendingComments, activeCommentForm]);

const useWordDiff =
file.changes <= LARGE_PATCH_CHANGE_THRESHOLD &&
Expand All @@ -175,9 +181,9 @@ export const ReviewFileDiffBlock = memo(function ReviewFileDiffBlock({
hunkSeparators: "line-info" as const,
overflow: "scroll" as const,
disableFileHeader: true,
enableGutterUtility: true,
enableLineSelection: true,
onGutterUtilityClick: handleGutterUtilityClick,
enableGutterUtility: !readOnly,
enableLineSelection: !readOnly,
...(readOnly ? {} : { onGutterUtilityClick: handleGutterUtilityClick }),
unsafeCSS: [
`:host { color-scheme: ${isDark ? "dark" : "light"}; }`,
`:host { --diffs-font-family: 'Geist Mono Variable', 'SF Mono', ui-monospace, 'Cascadia Code', monospace; }`,
Expand All @@ -187,7 +193,7 @@ export const ReviewFileDiffBlock = memo(function ReviewFileDiffBlock({
`[data-diff] { border: 1px solid var(--border); border-top: 0; border-radius: 0 0 4px 4px; overflow: hidden; }`,
].join("\n"),
}),
[diffStyle, handleGutterUtilityClick, isDark, useWordDiff],
[diffStyle, handleGutterUtilityClick, isDark, readOnly, useWordDiff],
);
const patchString = useMemo(() => buildPatchString(file), [file]);

Expand Down Expand Up @@ -236,6 +242,8 @@ export const ReviewFileDiffBlock = memo(function ReviewFileDiffBlock({
renderAnnotation={(
annotation: DiffLineAnnotation<ReviewAnnotation>,
) => {
if (readOnly) return null;

const data = annotation.metadata as
| PendingComment
| PullReviewComment
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/pulls/review/review-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ const ReviewToolbar = memo(function ReviewToolbar({
// ReviewSidebar — owns file filter state, reads activeFile from store
// ---------------------------------------------------------------------------

const ReviewSidebar = memo(function ReviewSidebar({
export const ReviewSidebar = memo(function ReviewSidebar({
sidebarFiles,
sidebarFileCount,
activeFileStore,
Expand Down
30 changes: 15 additions & 15 deletions apps/dashboard/src/components/repo/code-file-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from "@diffkit/ui/components/tooltip";
import { cn } from "@diffkit/ui/lib/utils";
import { useQuery } from "@tanstack/react-query";
import { Link } from "@tanstack/react-router";
import { Suspense, use, useCallback, useMemo, useRef, useState } from "react";
import { formatRelativeTime } from "#/lib/format-relative-time";
import {
Expand Down Expand Up @@ -216,7 +217,7 @@ export function CodeFileView({
const rawUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${currentRef}/${path}`;
return (
<div className="flex flex-col gap-4">
<FileCommitBar commit={commit} />
<FileCommitBar owner={owner} repo={repo} commit={commit} />
<div className="overflow-hidden rounded-lg border">
<FileViewHeader
fileName={fileName}
Expand Down Expand Up @@ -277,7 +278,7 @@ export function CodeFileView({

return (
<div className="flex flex-col gap-4">
<FileCommitBar commit={commit} />
<FileCommitBar owner={owner} repo={repo} commit={commit} />
<div className="overflow-hidden rounded-lg border">
<FileViewHeader
fileName={fileName}
Expand Down Expand Up @@ -327,7 +328,7 @@ function SvgFileView({

return (
<div className="flex flex-col gap-4">
<FileCommitBar commit={commit} />
<FileCommitBar owner={owner} repo={repo} commit={commit} />
<div className="overflow-hidden rounded-lg border">
<FileViewHeader
fileName={fileName}
Expand Down Expand Up @@ -464,8 +465,12 @@ function FileViewHeader({
}

function FileCommitBar({
owner,
repo,
commit,
}: {
owner: string;
repo: string;
commit: FileLastCommit | null | undefined;
}) {
if (!commit) {
Expand All @@ -490,18 +495,13 @@ function FileCommitBar({
/>
)}
<span className="font-medium">{commit.author?.login ?? "Unknown"}</span>
<Tooltip>
<TooltipTrigger asChild>
<span className="min-w-0 flex-1 truncate text-muted-foreground">
{firstLine}
</span>
</TooltipTrigger>
{firstLine.length > 60 && (
<TooltipContent side="bottom" className="max-w-sm">
{firstLine}
</TooltipContent>
)}
</Tooltip>
<Link
to="/$owner/$repo/commit/$sha"
params={{ owner, repo, sha: commit.sha }}
className="min-w-0 flex-1 truncate text-left text-muted-foreground transition-colors hover:text-foreground hover:underline"
>
{firstLine}
</Link>
<div className="flex shrink-0 items-center gap-3 text-xs text-muted-foreground">
<Tooltip>
<TooltipTrigger asChild>
Expand Down
Loading
Loading