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

johnandersen777.bsky.social/knotless

git that lives in your Atmosphere account

Forked from chadtmiller.com/knotless

0
0
38 lines · 1.4 KB Raw History
<script lang="ts">
	import type { RepoViewBasic, RepoViewDetailed } from '#lib/lexicons/dev/knotless/defs.ts';
	import type * as acceptTransfer from '#lib/lexicons/dev/knotless/acceptTransfer.ts';
	import { goto } from '$app/navigation';
	import { call } from '#lib/data.ts';
	import { repoHref } from '#lib/format.ts';
	/**
	 * What the account a repository's owner offered it `to` sees on its
	 * pages: the offer, and taking it up, as `knotless repo accept` does, which
	 * moves it there with its pulls, issues and forks.
	 */
	let { repo, to }: { repo: RepoViewDetailed; to: RepoViewBasic } = $props();
	let problem = $state('');
	let busy = $state(false);
	async function accept() {
		busy = true;
		problem = '';
		try {
			const made = await call<typeof acceptTransfer.main>('dev.knotless.acceptTransfer', {
				repo: repo.uri
			});
			await goto(repoHref(to.handle, made.name));
		} catch (err) {
			problem = (err as Error).message;
		}
		busy = false;
	}
</script>

<div class="notice offer" role="status">
	<p>
		{`${repo.owner.handle} offered this repository to you: taking it up moves it to ${to.handle}/${to.name}, with its pulls, issues and forks.`}
	</p>
	<button class="btn primary" type="button" disabled={busy} aria-busy={busy} onclick={accept}
		>{busy ? 'Taking it up…' : 'Accept transfer'}</button
	>
	{#if problem}<p class="problem" role="alert">{problem}</p>{/if}
</div>