fix(dashboard): name the plan on self-hosted installs instead of "--"

A self-hosted install has no /marketplace/subscriptions/current route, and
Home treated its 404 like any failed read, leaving "Your Plan" at "--" for
good. A 404 now shows the plan every account starts on. The upgrade badge
and link, which have nothing to reach there, go too, unless the hosted
upgrade dialog is loaded.
This commit is contained in:
Nariman Jelveh committed 2026-10-23 15:11:26 -07:00
1 parent b3073990ec
commit c33edecb1a
1 file changed
+12 -2
+12 -2
View File
@@ -487,14 +487,19 @@ const TabHome = {
*/
async _renderPlanCard($el_window) {
let subscription = null;
// A self-hosted install has no billing routes; its users have the
// plan every account starts on, with nothing to upgrade to (no
// upgrade dialog either, which only hosted Puter loads).
let noBilling = false;
try {
const resp = await fetch(
`${window.api_origin}/marketplace/subscriptions/current`,
{ headers: { Authorization: `Bearer ${puter.authToken}` } },
);
noBilling = resp.status === 404;
// A refusal is not a free plan: a seat owing a password change 403s.
if (!resp.ok) return;
const data = await resp.json();
if (!resp.ok && !noBilling) return;
const data = noBilling ? null : await resp.json();
subscription = data?.subscription ?? null;
} catch (e) {
console.error('Failed to load plan data:', e);
@@ -595,6 +600,11 @@ const TabHome = {
$el_window.find('.bento-plan-upgrade').hide();
}
if (noBilling && typeof window.UIUpgradeAccount !== 'function') {
$badge.text('').removeClass('free');
$el_window.find('.bento-plan-upgrade').hide();
}
$el_window
.find('.bento-plan-upgrade')
.off('click.billing')