Something went wrong. Try again.
Monorepo for Tangled
Something went wrong. Try again.
Svelte
at icy/tmrrpn
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596<script lang="ts"> import { filterCommentsByCommit, groupCommentsByVersion, type CommentView } from "$lib/components/comment/comments"; import ArrowRight from "$icon/arrow-right"; import type { CommitSummary } from "$lib/components/repo/types"; import TimeAgo from "$lib/components/ui/TimeAgo.svelte"; import type { MarkupContext } from "$lib/markup"; import PullReviewComment from "./PullReviewComment.svelte"; import type { CommitStatuses } from "$lib/api/commitStatuses"; import PipelineWorkflows from "../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-4 px-4 pt-4 pb-80"> {#if !visible.length} <p class="p-2 text-foreground-subtle">No comments yet.</p> {:else} {#each groups as group (group.version ?? "pre")} {#if group.version && group.version > 0} <Separator variant="line" /> {/if} <div class="space-y-2"> {#if group.version !== undefined} {@const isActive = group.version === currentVersion} {@const version = versions[group.version]} <div class="flex h-6 items-center justify-between"> <div class="flex items-center gap-2"> {#if isActive} <ArrowRight class="size-3.5" /> {/if} <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>