[web] Design review: last row's menu not clipped, Hostname focused after loading, popover closes on Esc and outside click, phone engine chip in the top bar, paused and needs-attention copy with Restore in the panel, change bar offers and countdown, focus after share and kept, fingerprint check when signing by hand, draft kept through sign-in
This commit is contained in:
@@ -4,10 +4,10 @@
|
||||
<script lang="ts">
|
||||
// Handoff §7.4 and §7.5: the last-change bar with Undo (1 click), and the reverted / not
|
||||
// applied banner that stands in for its first line.
|
||||
import { Banner, Button, Icon, Progress } from "@ianitor/ui";
|
||||
import { Banner, Button, Details, Icon, Progress } from "@ianitor/ui";
|
||||
import { ApiError, call, del, newKey, post, sentence } from "../lib/api";
|
||||
import { app, refresh, secondsLeft, toast } from "../lib/app.svelte";
|
||||
import { firstSentence, when } from "../lib/format";
|
||||
import { atTime, firstSentence, when } from "../lib/format";
|
||||
import type { ApplyView } from "../lib/types";
|
||||
|
||||
let { onshowsteps, onedit }: { onshowsteps: (id: string) => void; onedit: (a: ApplyView, field?: string) => void } = $props();
|
||||
@@ -21,7 +21,7 @@
|
||||
let pushing = $state(false);
|
||||
const dismissKey = $derived(last ? `apply:${last.id}` : "");
|
||||
|
||||
function runningHeading(summary: string, a: ApplyView | null): string {
|
||||
function runningHeading(summary: string, a: { kind: string; hosts: string[]; summary: string } | null): string {
|
||||
if (!a) return summary;
|
||||
const h = a.hosts[0] ?? "";
|
||||
switch (a.kind) {
|
||||
@@ -29,6 +29,8 @@
|
||||
case "remove": return `Removing ${h}`;
|
||||
case "edit": return `Changing ${h}`;
|
||||
case "share_links": return `Turning on share links for ${h}`;
|
||||
case "undo": return `Undoing: ${a.summary.replace(/^Undid: /, "")}`;
|
||||
case "restore": return a.summary.replace(/^Restored /, "Restoring ");
|
||||
default: return summary;
|
||||
}
|
||||
}
|
||||
@@ -85,7 +87,29 @@
|
||||
});
|
||||
const pushFailed = $derived(last?.state === "kept" && last.push?.state === "failed");
|
||||
const undoReason = $derived(undo?.blocked && undo.blocked.code !== "undo.nothing" ? undo.blocked.message : null);
|
||||
const watchLeft = $derived(last?.watch ? secondsLeft(last.watch.ends_at) : null);
|
||||
// Ticks every second on the local clock (§7.2), not only on the 5 s poll.
|
||||
const watchLeft = $derived(
|
||||
active?.watch_ends_at ? secondsLeft(active.watch_ends_at) : active?.seconds_left != null ? active.seconds_left : null,
|
||||
);
|
||||
// The outcome's offer, by code (§7.5).
|
||||
const offer = $derived.by(() => {
|
||||
const c = last?.reason?.code ?? "";
|
||||
if (/^apply\.reverted\.(not_found|redirect|sign_in)$/.test(c)) return { label: "Edit health check", field: "health_check.path" };
|
||||
if (/^apply\.(interrupted|reverted\.edge_lost|interrupted\.queued)$/.test(c)) return { label: "Try again", field: last?.reason?.field ?? undefined };
|
||||
if (/^apply\.failed\.(reload|build|edge_unreachable)$/.test(c)) return null;
|
||||
if (last?.attempted_host) return { label: "Edit and try again", field: last?.reason?.field ?? undefined };
|
||||
return null;
|
||||
});
|
||||
const pushLine = $derived.by(() => {
|
||||
const p = last?.push;
|
||||
const remote = "Gitea";
|
||||
switch (p?.error_code) {
|
||||
case "push.failed.rejected": return `Kept, but ${remote} has changes Ianitor does not have, so nothing was sent. Nothing is lost on this server.`;
|
||||
case "push.failed.auth": return `Kept, but ${remote} refused Ianitor's access key. Check the key in Custos.`;
|
||||
default: return `Kept, but not yet saved to ${remote}: ${remote} did not answer.${p?.next_try_at ? ` Ianitor tries again ${atTime(p.next_try_at, app.now)}.` : " Ianitor tries again by itself."}`;
|
||||
}
|
||||
});
|
||||
const canPushNow = $derived(pushFailed && last?.push?.error_code !== "push.failed.rejected");
|
||||
</script>
|
||||
|
||||
{#if last && (last.state === "reverted" || last.state === "failed") && !app.dismissed.includes(dismissKey)}
|
||||
@@ -93,8 +117,9 @@
|
||||
<Banner tone="notice" ondismiss={() => (app.dismissed = [...app.dismissed, dismissKey])}>
|
||||
{#snippet title()}<span class="ia-status" data-s="reverted"><Icon name="undo" /><span class="word">{last.state === "failed" ? "not applied" : "reverted"}</span></span> <strong>{parts[0]}</strong>{/snippet}
|
||||
{#if parts[1]}Reason: {parts[1]}{/if}
|
||||
{#if last.reason?.detail && last.reason.code.startsWith("apply.failed.")}<Details detail={last.reason.detail} />{/if}
|
||||
{#snippet actions()}
|
||||
{#if last.attempted_host}<Button variant="outline" onclick={() => onedit(last, last.reason?.field ?? undefined)}>Edit and try again</Button>{/if}
|
||||
{#if offer}<Button variant="outline" onclick={() => onedit(last, offer?.field)}>{offer.label}</Button>{/if}
|
||||
{/snippet}
|
||||
</Banner>
|
||||
{/if}
|
||||
@@ -104,8 +129,8 @@
|
||||
{#if active}
|
||||
<div class="grow">
|
||||
<div class="ia-status" data-s="running"><Icon name="clock" /><span class="word">{active.state === "queued" ? "waiting" : active.state === "watching" ? "watching" : "applying"}</span>
|
||||
<span>{runningHeading(active.summary, last && last.id === active.id ? last : null)}</span></div>
|
||||
<div class="ia-sub">{active.state === "queued" ? "Waiting for another change to finish" : `${watchLeft ?? active.seconds_left ?? 0} s left`}</div>
|
||||
<span>{runningHeading(active.summary, active.kind ? active : null)}</span></div>
|
||||
<div class="ia-sub">{active.state === "queued" ? "Waiting for another change to finish" : active.state === "watching" ? `${watchLeft ?? 0} s left` : "Checking and loading the change"}</div>
|
||||
{#if active.state === "watching" && watchLeft != null}
|
||||
{@const total = o?.site?.watch_seconds ?? 60}
|
||||
<Progress label="Health watch" max={total} now={total - watchLeft} text="{watchLeft} seconds left" />
|
||||
@@ -116,7 +141,7 @@
|
||||
<div class="grow">
|
||||
{#if last.state === "kept"}
|
||||
<div><span class="ia-status" data-s="kept"><Icon name="check" /><span class="word">kept</span></span> {last.summary}</div>
|
||||
<div class="ia-sub" class:warn={pushFailed}>{pushFailed ? "Kept, but not yet saved to Gitea. Ianitor tries again by itself." : keptLine}</div>
|
||||
<div class="ia-sub" class:warn={pushFailed}>{pushFailed ? pushLine : keptLine}</div>
|
||||
{:else if undo?.target}
|
||||
<div>Undo: {undo.target.summary}</div>
|
||||
{/if}
|
||||
@@ -125,7 +150,7 @@
|
||||
{#if undoReason}<div class="ia-sub" id="undo-reason">{undoReason}</div>{/if}
|
||||
{#if !undo?.target}<div class="ia-sub">Nothing to undo yet.</div>{/if}
|
||||
</div>
|
||||
{#if pushFailed}<Button onclick={pushNow} pending={pushing}>Try now</Button>{/if}
|
||||
{#if canPushNow}<Button onclick={pushNow} pending={pushing}>Try now</Button>{/if}
|
||||
{#if undo?.target}
|
||||
<Button icon="undo" onclick={doUndo} pending={undoing} disabled={!!undoReason || !undo.available}
|
||||
describedby={undoReason ? "undo-reason" : undefined}
|
||||
|
||||
Reference in New Issue
Block a user