Something went wrong. Try again.
Monorepo for Tangled
Something went wrong. Try again.
Svelte
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293<script lang="ts"> import { filterCommentsByCommit, groupCommentsByVersion, type CommentView } from "$lib/components/comment/comments"; import type { CommitSummary } from "$lib/components/repo/types"; import EmptyState from "$lib/components/ui/EmptyState.svelte"; import TimeAgo from "$lib/components/ui/TimeAgo.svelte"; import type { MarkupContext } from "$lib/markup"; import PullReviewComment from "$lib/components/repo/pulls/PullReviewComment.svelte"; import type { CommitStatuses } from "$lib/api/commitStatuses"; import PipelineWorkflows from "$lib/components/repo/pipelines/PipelineWorkflows.svelte"; import Separator from "$lib/components/ui/Separator.svelte";
interface PullVersion { base: string; head: string; createdAt: string; }
interface Props { markup: MarkupContext; currentVersion: number; versions: PullVersion[]; comments: CommentView[]; // the commits a comment's pin can name, so a filter sees the commit and not the oid commits: CommitSummary[]; pipelineStatuses?: Promise<CommitStatuses>; filter?: (commit: CommitSummary) => boolean; onUpdateComment: (edited: CommentView) => Promise<void>; }
let { markup, currentVersion, versions, comments, commits, pipelineStatuses, filter, onUpdateComment }: Props = $props();
const visible = $derived(filterCommentsByCommit(comments, commits, filter)); const groups = $derived(groupCommentsByVersion(visible, versions));</script>
<div class="space-y-md px-xs pt-xs pb-48"> {#if !visible.length} <EmptyState size="inline" message="No comments yet." class="p-xs" /> {:else} {#each groups as group (group.version ?? "pre")} {#if group.version && group.version > 0} <Separator variant="line" /> {/if} <div class="space-y-xs"> {#if group.version !== undefined} {@const isActive = group.version === currentVersion} {@const version = versions[group.version]} <div class="flex h-6 items-center justify-between px-xs"> <div class="flex items-center gap-xs"> <span class:text-foreground-muted={!isActive}>v{group.version}</span> <TimeAgo class="text-foreground-subtle" value={version.createdAt} /> </div> {#if pipelineStatuses} {#await pipelineStatuses then statuses} {#if statuses[version.head]} <PipelineWorkflows ownerHandle="tangled.org" repoName="core" size="mini" variant="symbol" pipeline={statuses[version.head]} /> {/if} {/await} {/if} </div> {/if} {#each group.comments as comment (comment.uri)} <PullReviewComment {comment} {markup} onedit={onUpdateComment} active={group.version === currentVersion} /> {/each} </div> {/each} {/if}</div>