Hub 2.12.0: one product uninstalled at a time, stale installs removed, customers archived
- Uninstalls name the product (agent 1.5.0); a whole-church uninstall marks every product of the church on that server removed. Older agents are refused while the church has others. - A second product's uninstall joins one already planned (one export and one uninstall) or gets its own time; the last product removes the whole church. Accounts goes last. - Remove an install from the Hub after 24 hours without a heartbeat (POST .../forget). - Archive and restore customers (migration 20261123090000_customer_archive). - Several addresses for a customer's email and billing email, with a + button. - Statements show R0 invoices' amounts. Vendors contracts 1.16.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
"use client";
|
||||
|
||||
import React from "react";
|
||||
import { Plus, X } from "lucide-react";
|
||||
|
||||
/** The addresses in a stored value ("a@x.org, b@x.org"). */
|
||||
export const emailsOf = (value: string | null | undefined) => String(value || "").split(/[\s,;]+/).map(s => s.trim()).filter(Boolean);
|
||||
|
||||
/**
|
||||
* Hub 2.12.0: one or more email addresses, one per row, with + to add another. The value is the
|
||||
* comma-separated list the API stores ("a@x.org, b@x.org"); empty rows are dropped when saved.
|
||||
*/
|
||||
export function EmailList({ id, label, value, onChange, placeholder, max = 10 }: {
|
||||
id: string; label: string; value: string; onChange: (v: string) => void; placeholder?: string; max?: number;
|
||||
}) {
|
||||
// Keep an empty row while typing: split on commas only, so a half-typed address stays put.
|
||||
const rows = value === "" ? [""] : value.split(",").map(s => s.trim());
|
||||
const set = (next: string[]) => onChange(next.join(", "));
|
||||
return (
|
||||
<div>
|
||||
<label className="label" htmlFor={`${id}-0`}>{label}</label>
|
||||
<div className="space-y-2">
|
||||
{rows.map((r, i) => (
|
||||
<div key={i} className="flex gap-2">
|
||||
<input id={`${id}-${i}`} type="email" className="input" value={r} placeholder={i === 0 ? placeholder : "another@church.org"}
|
||||
aria-label={i === 0 ? undefined : `${label} ${i + 1}`}
|
||||
onChange={e => set(rows.map((x, j) => (j === i ? e.target.value.replace(/[,;\s]/g, "") : x)))} />
|
||||
{rows.length > 1 && (
|
||||
<button type="button" className="btn-secondary px-2" aria-label={`Remove ${r || "this address"}`} onClick={() => set(rows.filter((_, j) => j !== i))}><X className="h-4 w-4" /></button>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{rows.length < max && (
|
||||
<button type="button" className="mt-2 inline-flex items-center gap-1 text-sm text-indigo-600 hover:underline" onClick={() => set([...rows, ""])}>
|
||||
<Plus className="h-4 w-4" /> Add another address
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { fmtDate } from "@/lib/format";
|
||||
import { CYCLE, EMAIL_KIND, METHOD, StateBadge, centsFrom, day, money, randInput, todayYmd, type BillingCycle, type BillingEmail, type Invoice, type LicenceChange, type Line, type Payment, type PlanChange } from "@/lib/billing";
|
||||
import { PRODUCT_NAMES, byProduct, type Product } from "@/lib/products";
|
||||
import { RecordPayment } from "./RecordPayment";
|
||||
import { EmailList } from "@/components/EmailList";
|
||||
|
||||
type Msg = { type: "ok" | "err"; text: string } | null;
|
||||
/** A plan of a product: the Events tiers have an income ceiling (upTo), the App tiers a member band. */
|
||||
@@ -303,7 +304,10 @@ export function CustomerBilling({ customerId }: { customerId: string }) {
|
||||
<div><label className="label" htmlFor="f-note">Note</label><input id="f-note" className="input" value={form.foundingNote} onChange={e => setForm({ ...form, foundingNote: e.target.value })} placeholder="e.g. Founding church 3 of 10" /></div>
|
||||
</div>
|
||||
)}
|
||||
<div><label className="label" htmlFor="b-email">Billing email</label><input id="b-email" type="email" className="input" value={form.billingEmail} onChange={e => setForm({ ...form, billingEmail: e.target.value })} placeholder={c.sendsTo || ""} /><p className="mt-1 text-xs text-slate-500">Blank: the site's admin contact, then the customer's email. Now going to {c.sendsTo || "nobody (add one)"}.</p></div>
|
||||
<div>
|
||||
<EmailList id="b-email" label="Billing email" value={form.billingEmail} onChange={billingEmail => setForm({ ...form, billingEmail })} placeholder={c.sendsTo || "accounts@church.org"} />
|
||||
<p className="mt-1 text-xs text-slate-500">Invoices, statements and receipts go to every address here. Blank: the site's admin contact, then the customer's email. Now going to {c.sendsTo || "nobody (add one)"}.</p>
|
||||
</div>
|
||||
<div><label className="label" htmlFor="b-addr">Postal address (on invoices)</label><textarea id="b-addr" className="input" rows={2} value={form.billingAddress} onChange={e => setForm({ ...form, billingAddress: e.target.value })} /></div>
|
||||
<button className="btn-secondary">Save billing details</button>
|
||||
</form>
|
||||
|
||||
@@ -49,6 +49,8 @@ const STATUS: Record<string, [string, string]> = {
|
||||
// deployments
|
||||
installing: ["Installing", "blue"], waiting_for_proxy: ["Waiting for proxy", "amber"], live: ["Live", "green"], failed: ["Failed", "red"],
|
||||
uninstalling: ["Uninstalling", "amber"], removed: ["Removed", "grey"],
|
||||
// 2.12.0: on the Hub as live, but no heartbeat for 24 hours
|
||||
stale: ["No heartbeat", "red"],
|
||||
// servers: busy = running a job the Hub handed it (agents before 1.1.1 go quiet then)
|
||||
busy: ["Running a job", "blue"],
|
||||
// jobs
|
||||
@@ -64,6 +66,19 @@ export function StatusPill({ status }: { status: string }) {
|
||||
return <span className={`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ring-1 ring-inset ${TONE[tone]}`}>{label}</span>;
|
||||
}
|
||||
|
||||
/** Hub 2.12.0: an install can be removed from the Hub after this long without a heartbeat. */
|
||||
export const STALE_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
/** When an install was last heard from: its last heartbeat, else when it went live or was made (as the Hub counts it). */
|
||||
export const lastHeardAt = (d: Deployment) => d.install?.lastHeartbeatAt || d.liveAt || d.createdAt || null;
|
||||
|
||||
/** The status to show: "stale" for an install still on the Hub that's sent nothing for 24 hours. */
|
||||
export function shownStatus(d: Deployment, now = Date.now()) {
|
||||
if (["removed", "failed", "installing"].includes(d.status)) return d.status;
|
||||
const at = lastHeardAt(d);
|
||||
return at && now - new Date(at).getTime() >= STALE_MS ? "stale" : d.status;
|
||||
}
|
||||
|
||||
export const pct = (n: number | null | undefined) => (n == null ? "–" : `${Math.round(n)}%`);
|
||||
|
||||
// <input type="datetime-local"> works in the browser's time; the API takes ISO.
|
||||
|
||||
Reference in New Issue
Block a user