johnandersen777.bsky.social/knotless
git that lives in your Atmosphere account
Forked from chadtmiller.com/knotless
0
0
<script lang="ts">
import type { Image } from '#lib/lexicons/dev/knotless/defs.ts';
import type { AtUriString } from '@atproto/lex';
import { plural } from '#lib/format.ts';
import Icon from '#lib/atoms/Icon.svelte';
import Composer, { type Verdict } from '#lib/organisms/Composer.svelte';
/**
* A pull's review being written, as GitHub's "Review changes" menu has
* it: what it says, then sent with the `pending` line comments kept for
* it, or with `review`, a verdict too. `send` answers why it failed, or
* nothing; `discard` drops the comments kept.
*/
let {
pending,
review,
repo,
send,
discard
}: {
pending: number;
review: boolean;
repo?: AtUriString;
send: (body: string, verdict?: Verdict, images?: Image[]) => Promise<string | undefined>;
discard: () => void;
} = $props();
let open = $state(false);
async function sent(body: string, verdict?: Verdict, images?: Image[]) {
const failed = await send(body, verdict, images);
if (!failed) open = false;
return failed;
}
</script>
<details class="popover review-menu" bind:open>
<summary class="btn primary"
>{pending ? 'Finish your review' : 'Review changes'}{#if pending}<span class="count"
>{pending}</span
>{/if}<Icon name="caret" /></summary
>
<div class="menu">
{#if pending}<p class="mute pending">
{`${plural(pending, 'comment', 'comments')} on its lines will go with it.`}<button
class="btn"
type="button"
onclick={discard}>Discard</button
>
</p>{/if}
<Composer
in
label="Submit review"
placeholder="Leave a comment"
{review}
ready={pending > 0}
{repo}
send={sent}
/>
</div>
</details>