Hub 2.21.0: install the Church Website; Website storage bought in steps

- New install offers the Church Website: Accounts first when the church has
  none, at accounts.<its address> (www. dropped); the FastPanel email sends a
  www. site's bare domain to www. with a 301.
- Licence.extraStorageSteps (migration): the token sends a Website its limit
  (5 GB + steps, limits.storageBytes, contracts 1.17.0); invoices bill the
  steps bought instead of the storage reported. Edit popup field 0-99.
- A Website/App licence starts on its plan however it's made (New install too).
- Vendored @crosscode/contracts 1.17.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 00:03:21 +02:00
co-authored by Claude Opus 5.5
parent 6f8242064f
commit c6f734ab20
21 changed files with 235 additions and 36 deletions
@@ -17,6 +17,12 @@ type Msg = { type: "ok" | "err"; text: string } | null;
type Customer = { id: string; name: string; domain?: string | null };
type InstallRow = { id: string; name: string; url: string; customer: { id: string; name: string } | null; version: string | null };
/** The Accounts domain the Hub makes when none is given (backend accountsDomainFor). */
function accountsPlaceholder(product: string, domain: string) {
if (!domain) return "accounts.hope.co.za";
return product === "website" ? `accounts.${domain.replace(/^www\./, "")}` : domain.replace(/^[^.]+./, "accounts.");
}
const emptyNew = { product: "events", customerId: "", serverId: "", shortName: "", domain: "", accountsDomain: "", timezone: "", adminName: "", adminEmail: "", version: "" };
const emptyLink = { installId: "", serverId: "", shortName: "", webPort: "", apiPort: "" };
const changedFrom = <T extends Record<string, string>>(form: T, empty: T) => (Object.keys(empty) as (keyof T)[]).some(k => form[k] !== empty[k]);
@@ -57,18 +63,21 @@ function NewInstallModal({ servers, onClose }: { servers: ServerSummary[]; onClo
<select id="n-product" className="input" value={form.product} onChange={e => setForm({ ...form, product: e.target.value, version: "" })}>
<option value="events">Cross Events</option>
<option value="accounts">Accounts (the church&apos;s sign-in)</option>
<option value="website">Church Website</option>
</select>
<p className="mt-1 text-xs text-slate-500">
{form.product === "accounts"
? "Install Accounts before the Website, the App or Cross Events 3.0. Use the church's short name to add it next to its Events on the same server."
: "A church that already has a product here keeps its short name: the new one is added next to it on the same server."}
: form.product === "website"
? "On the church's own address: www.hope.co.za (its bare domain is sent to www.), or a Cross Code address like hope.crosscode.co.za. A church that already has a product here keeps its short name."
: "A church that already has a product here keeps its short name: the new one is added next to it on the same server."}
</p>
</div>
<div><label className="label" htmlFor="n-cust">Customer</label><select id="n-cust" className="input" required {...f("customerId")}><option value="">Choose…</option>{customers.map(c => <option key={c.id} value={c.id}>{c.name}</option>)}</select></div>
<div><label className="label" htmlFor="n-short">Short name</label><input id="n-short" className="input" required pattern="[a-z][a-z0-9-]{1,30}" placeholder="hope" {...f("shortName")} /><p className="mt-1 text-xs text-slate-500">Folders, database and tunnels: a-z, 0-9 and -.</p></div>
<div><label className="label" htmlFor="n-domain">Domain</label><input id="n-domain" className="input" required placeholder={form.product === "accounts" ? "accounts.hope.co.za" : "events.hope.co.za"} {...f("domain")} /></div>
{form.product === "events" && (
<div><label className="label" htmlFor="n-acc">Accounts domain</label><input id="n-acc" className="input" placeholder={form.domain ? form.domain.replace(/^[^.]+./, "accounts.") : "accounts.hope.co.za"} {...f("accountsDomain")} /><p className="mt-1 text-xs text-slate-500">Cross Events 3 signs in through the church&apos;s Accounts: a church without it gets it installed first, here.</p></div>
<div><label className="label" htmlFor="n-domain">Domain</label><input id="n-domain" className="input" required placeholder={form.product === "accounts" ? "accounts.hope.co.za" : form.product === "website" ? "www.hope.co.za" : "events.hope.co.za"} {...f("domain")} /></div>
{(form.product === "events" || form.product === "website") && (
<div><label className="label" htmlFor="n-acc">Accounts domain</label><input id="n-acc" className="input" placeholder={accountsPlaceholder(form.product, form.domain)} {...f("accountsDomain")} /><p className="mt-1 text-xs text-slate-500">{form.product === "website" ? "The Website" : "Cross Events 3"} signs in through the church&apos;s Accounts: a church without it gets it installed first, here.</p></div>
)}
<div><label className="label" htmlFor="n-tz">Time zone</label><input id="n-tz" className="input" placeholder="Africa/Johannesburg" {...f("timezone")} /></div>
<div><label className="label" htmlFor="n-an">Site admin name</label><input id="n-an" className="input" {...f("adminName")} /></div>
@@ -177,6 +186,7 @@ export default function InstallsPage() {
<option value="">Every product</option>
<option value="events">{PRODUCT_NAMES.events}</option>
<option value="accounts">{PRODUCT_NAMES.accounts}</option>
<option value="website">{PRODUCT_NAMES.website}</option>
</select>
<SearchInput className="w-full sm:w-72" value={query} onChange={setQuery} placeholder="Search a church, domain or server" />
</div>
@@ -56,6 +56,7 @@ export function ProductCard({ licence, billing, plans, nextInvoiceDate, onDone }
billed ? (billing?.billedFrom ? `charged from ${day(billing.billedFrom)}` : "not charged") : null,
];
facts.push(licence.expiresAt ? `expires ${fmtDate(licence.expiresAt, false)}` : "expires never", `grace ${licence.graceDays} days`);
if (licence.product === "website") facts.push(licence.extraStorageSteps ? `${5 + 5 * licence.extraStorageSteps} GB storage (${licence.extraStorageSteps} extra × 5 GB)` : "5 GB storage");
return (
<article className={`card space-y-2 ${revoked ? "bg-slate-50 opacity-80" : ""}`}>
@@ -100,7 +101,8 @@ export function ProductCard({ licence, billing, plans, nextInvoiceDate, onDone }
/** One popup, one Save: the licence fields and the billing fields, each sent only if changed. */
function EditProduct({ licence, billing, onClose, onDone }: { licence: Licence; billing: BillingLicence | undefined; onClose: () => void; onDone: Done }) {
const lic0 = { plan: licence.plan, expiresAt: dateInput(licence.expiresAt), graceDays: String(licence.graceDays), notes: licence.notes || "" };
const website = licence.product === "website";
const lic0 = { plan: licence.plan, expiresAt: dateInput(licence.expiresAt), graceDays: String(licence.graceDays), notes: licence.notes || "", storage: String(licence.extraStorageSteps ?? 0) };
const bill0 = { billedFrom: billing?.billedFrom || "", custom: randInput(billing?.customMonthlyCents) };
const [lic, setLic] = useState(lic0);
const [bill, setBill] = useState(bill0);
@@ -119,7 +121,7 @@ function EditProduct({ licence, billing, onClose, onDone }: { licence: Licence;
try {
const said: string[] = [];
if (licChanged) {
await api(`/api/admin/licences/${licence.id}`, { method: "PUT", body: { plan: lic.plan, expiresAt: endOfDay(lic.expiresAt), graceDays: lic.graceDays, notes: lic.notes } });
await api(`/api/admin/licences/${licence.id}`, { method: "PUT", body: { plan: lic.plan, expiresAt: endOfDay(lic.expiresAt), graceDays: lic.graceDays, notes: lic.notes, ...(website ? { extraStorageSteps: Number(lic.storage) } : {}) } });
said.push(`Licence saved. ${HEARTBEAT}`);
}
if (billChanged && billing) {
@@ -155,6 +157,13 @@ function EditProduct({ licence, billing, onClose, onDone }: { licence: Licence;
<div><label className="label" htmlFor="p-grace">Grace (days)</label><input id="p-grace" type="number" min={0} max={90} className="input" value={lic.graceDays} onChange={e => setLic({ ...lic, graceDays: e.target.value })} /></div>
</div>
<p className="text-xs text-slate-500">{licence.product === "accounts" ? "Free: comes with the church's other products." : "The tier is shown on the church's Licence page and priced on its invoices."}</p>
{website && (
<div>
<label className="label" htmlFor="p-storage">Extra storage (5 GB steps)</label>
<input id="p-storage" type="number" min={0} max={99} className="input w-32" value={lic.storage} onChange={e => setLic({ ...lic, storage: e.target.value })} />
<p className="mt-1 text-xs text-slate-500">The site can hold {5 + 5 * (Number(lic.storage) || 0)} GB; uploads stop when it&apos;s full. R20 a month per step, from the next invoice, never discounted. The site gets the new limit with its next heartbeat.</p>
</div>
)}
<div><label className="label" htmlFor="p-notes">Notes</label><input id="p-notes" className="input" value={lic.notes} onChange={e => setLic({ ...lic, notes: e.target.value })} placeholder="Anything worth remembering about this licence" /></div>
</section>
+2
View File
@@ -28,6 +28,8 @@ export type Licence = {
expiresAt: string | null;
graceDays: number;
notes: string | null;
/** Hub 2.21.0, Church Website: extra 5 GB storage steps bought (the site's limit is 5 GB + these). */
extraStorageSteps?: number;
createdAt: string;
install?: { id: string; name: string; url: string; lastHeartbeatAt: string | null } | null;
};