diff --git a/src/components/repo.tsx b/src/components/repo.tsx index 1ec2d0f..0470ac5 100644 --- a/src/components/repo.tsx +++ b/src/components/repo.tsx @@ -10,7 +10,6 @@ import { FileText, FoldVertical, Folder, - Minimize2, PanelLeftClose, PanelLeftOpen, PanelRightClose, @@ -420,20 +419,32 @@ export const OverviewFileRow: Component<{ href: string; icon: JSX.Element; lastCommit?: TreeEntry['last_commit']; + lastCommitHref?: string; class?: string; onMouseEnter?: JSX.EventHandlerUnion; onMouseLeave?: JSX.EventHandlerUnion; onClick?: JSX.EventHandlerUnion; }> = (props) => ( - - ); export const FileRow: Component<{ @@ -441,6 +452,7 @@ export const FileRow: Component<{ href: string; icon: JSX.Element; lastCommit?: TreeEntry['last_commit']; + lastCommitHref?: string; commitMessage?: string; }> = (props) => (
@@ -460,7 +472,17 @@ export const FileRow: Component<{
- {props.lastCommit ? formatRelativeTime(props.lastCommit.when) : ''} + + {(when) => ( + {formatRelativeTime(when())}}> + {(href) => ( + + {formatRelativeTime(when())} + + )} + + )} +
); @@ -788,31 +810,64 @@ const parseDiffFiles = (patch: string): DiffFile[] => { return files; }; -export const DiffView: Component<{ patch: string; maxHeight?: string; wrap?: boolean }> = (props) => { +const changedFilesLabel = (count: number) => `${count} changed file${count === 1 ? '' : 's'}`; + +const DiffToolbarStats: Component<{ additions: number; deletions: number; fileCount: number; class?: string }> = (props) => ( + <> + + {changedFilesLabel(props.fileCount)} + +); + +const DiffCollapseButton: Component<{ expanded: boolean; onToggle: () => void }> = (props) => ( + +); + +export const DiffView: Component<{ + patch: string; + maxHeight?: string; + wrap?: boolean; + defaultExpanded?: boolean; + showFileTree?: boolean; + variant?: 'default' | 'commit'; +}> = (props) => { const files = createMemo(() => parseDiffFiles(props.patch)); const stats = createMemo(() => totalDiffStats(files())); - const [expanded, setExpanded] = createSignal(false); + const [expanded, setExpanded] = createSignal(props.defaultExpanded ?? false); + const [filesVisible, setFilesVisible] = createSignal(true); const previewLimit = 5; - const visibleFiles = createMemo(() => files().slice(0, previewLimit)); - const hiddenFiles = createMemo(() => files().slice(previewLimit)); + const showFileTree = createMemo(() => Boolean(props.showFileTree && files().length > 0)); + const tree = createMemo(() => diffFileTree(files())); + const visibleFiles = createMemo(() => (showFileTree() ? files() : files().slice(0, previewLimit))); + const hiddenFiles = createMemo(() => (showFileTree() ? [] : files().slice(previewLimit))); return ( -
+
- - - {files().length} changed file{files().length === 1 ? '' : 's'} - + + + +
- + setExpanded(!expanded())} />
-
- - {(file) => ( -
- -
+
+ + + + +
+ + {(file) => ( +
+ +
+ + + {file.path} +
+
+ +
+ )} +
+ 0}> +
+ + - - {file.path} -
+ Show {hiddenFiles().length} more file{hiddenFiles().length === 1 ? '' : 's'} + + + + Hide {hiddenFiles().length} file{hiddenFiles().length === 1 ? '' : 's'} +
- +
+ + {(file) => ( +
+ +
+ + + {file.path} +
+
+ +
+ )} +
+
- )} -
- 0}> -
- - - - Show {hiddenFiles().length} more file{hiddenFiles().length === 1 ? '' : 's'} - - - - Hide {hiddenFiles().length} file{hiddenFiles().length === 1 ? '' : 's'} - - -
- - {(file) => ( -
- -
- - - {file.path} -
-
- -
- )} -
-
-
-
- -
No differences found.
-
+ + +
No differences found.
+
+
@@ -1031,8 +1094,7 @@ export const PullDiffView: Component<{ patch: string; roundLabel: string; histor - - {files().length} changed files +