johnandersen777.bsky.social/knotless
git that lives in your Atmosphere account
Forked from chadtmiller.com/knotless
0
0
<script lang="ts">
import type * as requestRerun from '#lib/lexicons/dev/knotless/requestRerun.ts';
import type { AtUriString } from '@atproto/lex';
import { call } from '#lib/data.ts';
import Icon from '#lib/atoms/Icon.svelte';
/**
* Asking the runners of the repository `repo` to run the pull `pull`'s
* checks again, or those of the ref `ref`: all of them, or one of
* `workflows`, as `knotless run rerun` does. For its owner alone.
*/
let {
repo,
pull,
ref,
workflows
}: { repo: AtUriString; pull?: AtUriString; ref?: string; workflows: string[] } = $props();
let open = $state(false);
let said = $state('');
let problem = $state('');
// The workflow being asked for again, or 'all'.
let busy = $state('');
async function rerun(workflow?: string) {
busy = workflow ? `run ${workflow}` : 'all';
problem = '';
try {
await call<typeof requestRerun.main>('dev.knotless.requestRerun', {
repo,
pull,
ref,
workflow
});
said = workflow ? `Asked for ${workflow} again` : 'Asked for all again';
open = false;
} catch (e) {
problem = (e as Error).message;
}
busy = '';
}
</script>
<details class="popover rerun-menu" data-held={busy || undefined} bind:open>
<summary class="btn" title="Ask the runners to run them again"
><Icon name="sync" /><span>{said || 'Re-run'}</span><Icon name="caret" /></summary
>
<div class="menu">
<button
class="menu-item"
type="button"
disabled={!!busy}
aria-busy={busy === 'all'}
onclick={() => rerun()}>{busy === 'all' ? 'Asking…' : 'Re-run all'}</button
>
{#each workflows as w (w)}<button
class="menu-item"
type="button"
disabled={!!busy}
aria-busy={busy === `run ${w}`}
onclick={() => rerun(w)}>{busy === `run ${w}` ? 'Asking…' : `Re-run ${w}`}</button
>{/each}
{#if problem}<p class="problem" role="alert">{problem}</p>{/if}
</div>
</details>