~james/core

core/web/src/lib/components/repo/CommitLogView.svelte -rw-r--r-- 2.0 KiB
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 16 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<script lang="ts">
	import EmptyState from "#lib/components/ui/EmptyState.svelte";
	import Pagination from "#lib/components/ui/Pagination.svelte";
	import type { CommitStatuses } from "#lib/api/commitStatuses.ts";
	import CommitRows from "#lib/components/repo/CommitRows.svelte";
	import CommitRow from "#lib/components/repo/CommitRow.svelte";
	import type { CommitSummary } from "#lib/components/repo/types.ts";
	import Card from "#lib/components/ui/Card.svelte";
	import GitCommitVertical from "$icon/git-commit-vertical";

	interface Props {
		ownerHandle: string;
		repoName: string;
		ref: string;
		commits: CommitSummary[];
		tagsByCommit?: Record<string, string[]> | Promise<Record<string, string[]>>;
		pipelineStatuses?: Promise<CommitStatuses>;
		hasCi?: boolean;
		page: number;
		pageCount: number;
		onPageChange?: (page: number) => void;
	}

	let {
		ownerHandle,
		repoName,
		ref,
		commits,
		tagsByCommit,
		pipelineStatuses,
		hasCi = false,
		page,
		pageCount,
		onPageChange
	}: Props = $props();

	const changeIds = $derived(commits.flatMap(({ changeId }) => (changeId ? [changeId] : [])));
</script>

<Card padding="none">
	{#if commits.length === 0}
		<EmptyState size="inline" message="No commits at {ref}." class="justify-center py-xl" />
	{:else}
		<h2
			class="flex flex-wrap items-center gap-xs p-md typography-paragraph-regular font-medium"
		>
			<GitCommitVertical class="size-3.5 shrink-0" aria-hidden="true" />
			Commits on
			<span
				class="flex min-w-0 rounded-md bg-background-inset px-2xs typography-monospace-regular font-normal text-foreground-default"
				>{ref}</span
			>
		</h2>

		<CommitRows class="divide-y divide-border-default border-t border-border-default">
			{#each commits as commit (commit.hash)}
				<CommitRow
					{ownerHandle}
					{repoName}
					{commit}
					{changeIds}
					{tagsByCommit}
					{pipelineStatuses}
					{hasCi}
				/>
			{/each}
		</CommitRows>
	{/if}
</Card>

{#if pageCount > 1}
	<div class="mt-md flex justify-center">
		<Pagination {page} total={pageCount} labels onchange={onPageChange} />
	</div>
{/if}