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

johnandersen777.bsky.social/knotless

git that lives in your Atmosphere account

Forked from chadtmiller.com/knotless

0
0
78 lines · 2.9 KB Raw History
<script lang="ts">
	import { scrollRow } from '#lib/rows.ts';
	import { repoHref } from '#lib/format.ts';
	import Icon from '#lib/atoms/Icon.svelte';
	import More from '#lib/atoms/More.svelte';
	import AskedFor from '#lib/organisms/AskedFor.svelte';
	import RunList from '#lib/organisms/RunList.svelte';
	import RunWorkflow from '#lib/organisms/RunWorkflow.svelte';
	import RepoPage from '#lib/templates/RepoPage.svelte';
	import { Pages } from '#lib/pages.svelte.ts';
	import Empty from '#lib/molecules/Empty.svelte';
	let { data } = $props();
	const r = $derived(data.repo);
	const base = $derived(repoHref(data.authority, r.name, '/checks'));
	/** Whether the owner is looking, who may ask for a workflow to run, and name the runners. */
	const owns = $derived(data.viewer?.actor?.did === r.owner.did);
	const asked = $derived(data.runs.workflows.filter((w) => w.asked));
	/** The workflows to pick from that run on a push or pull: those on the default branch, and any these runs ran that it no longer has. */
	const names = $derived(
		[
			...new Set([
				...data.runs.workflows.map((w) => w.name),
				...data.runs.runs.map((r) => r.check.workflow),
				...(data.workflow ? [data.workflow] : [])
			])
		]
			.filter((n) => !asked.some((w) => w.name === n))
			.sort()
	);
	/** The workflow picked, when it runs only when asked. */
	const picked = $derived(asked.find((w) => w.name === data.workflow));
	/** `workflow`'s runs, or every workflow's. */
	const at = (workflow?: string) =>
		workflow ? `${base}?${new URLSearchParams({ workflow })}` : base;
	const runs = new Pages(
		() => data,
		(d) => ({ items: d.runs.runs, cursor: d.runs.cursor }),
		(r) => r.check.uri
	);
</script>

<RepoPage repo={r} tab="checks" title="Checks · {r.name}">
	{#if owns}<div class="toolbar">
			<RunWorkflow repo={r} /><a
				class="btn end"
				href={repoHref(data.authority, r.name, '/settings/actions')}><Icon name="gear" />Runners</a
			>
		</div>{/if}
	<nav class="chips" {@attach scrollRow(data.workflow)}>
		<a href={at()} aria-current={data.workflow ? undefined : 'page'}>All</a>
		{#each names as name (name)}<a
				href={at(name)}
				aria-current={data.workflow === name ? 'page' : undefined}>{name}</a
			>{/each}
		{#if asked.length}<span class="sep"></span>{/if}
		{#each asked as w (w.name)}<a
				class="asked"
				href={at(w.name)}
				title="Runs only when asked"
				aria-current={data.workflow === w.name ? 'page' : undefined}>{w.name}</a
			>{/each}
	</nav>
	{#if picked}<AskedFor workflow={picked} />{/if}
	{#if runs.items.length}
		<RunList runs={runs.items} />
	{:else}
		<div class="box">
			<Empty title="No runs yet"
				>{picked
					? owns
						? 'It runs once you ask for it, with Run workflow.'
						: 'It runs once the owner asks for it.'
					: 'The runners this repository names file a check for each run of its workflows, and they show here.'}</Empty
			>
		</div>
	{/if}
	<More pages={runs} label="Older runs" />
</RepoPage>