~ knotless Search/
↑↓ move↵ open⇧↵ all results

johnandersen777.bsky.social/knotless

git that lives in your Atmosphere account

Forked from chadtmiller.com/knotless

0
0
40 lines · 1.5 KB Raw History
<script lang="ts">
	import type * as createIssue from '#lib/lexicons/dev/knotless/createIssue.ts';
	import type { Image } from '#lib/lexicons/dev/knotless/defs.ts';
	import { goto } from '$app/navigation';
	import { call } from '#lib/data.ts';
	import { itemHref, repoHref } from '#lib/format.ts';
	import OpenForm from '#lib/organisms/OpenForm.svelte';
	import OpenFacts from '#lib/organisms/OpenFacts.svelte';
	import RepoPage from '#lib/templates/RepoPage.svelte';
	let { data } = $props();
	const r = $derived(data.repo);
	const base = $derived(repoHref(data.authority, r.name));
	/** The labels whoever is looking may put on it, and those chosen, by name. */
	const offered = $derived(r.viewer?.labels ?? []);
	let labels = $state<string[]>([]);
	async function open(title: string, body: string, images?: Image[]) {
		const opened = await call<typeof createIssue.main>('dev.knotless.createIssue', {
			repo: r.uri,
			title,
			body: body || undefined,
			images,
			labels: labels.length ? labels.map((name) => ({ name })) : undefined
		}).catch((e: Error) => e);
		if (opened instanceof Error) return opened.message;
		await goto(itemHref(base, opened.uri));
	}
</script>

<RepoPage repo={r} tab="issues" title="New issue · {r.name}">
	<h2 class="form-title">New issue</h2>
	<OpenForm
		repo={`at://${data.authority}/dev.knotless.repo/${r.name}`}
		in={!!data.viewer?.actor}
		label="Open issue"
		text={data.template}
		send={open}
	>
		{#snippet facts()}<OpenFacts {offered} bind:labels />{/snippet}
	</OpenForm>
</RepoPage>