import type { AppStatus, Project, ReleaseTrain, StoreRelease } from '../api'; import type { Data } from '../App'; import { shortPath } from '../paths'; export type Tone = 'ok' | 'warn' | 'bad' | 'muted' | 'local'; /** Tag text and tone of one app's offline config check. */ export function checkState(e: Pick): { text: string; tone: Tone } { if (e.errors.length || !e.check) return { text: 'not loaded', tone: 'bad' }; if (e.check.problems.length) return { text: `${e.check.problems.length} problem${e.check.problems.length === 1 ? '' : 's'}`, tone: 'bad' }; if (e.check.warnings.length) return { text: `${e.check.warnings.length} warning${e.check.warnings.length === 1 ? '' : 's'}`, tone: 'warn' }; return { text: 'config ok', tone: 'ok' }; } const PHASE_TONE: Record = { live: 'ok', rollout: 'local', halted: 'bad', approved: 'local', review: 'warn', rejected: 'bad', testing: 'local', draft: 'muted', other: 'muted' }; /** "live", "rollout 20%", "review" ... for one store of a train. */ export function phaseText(r: StoreRelease | null): { text: string; tone: Tone } { if (!r) return { text: 'not on this store', tone: 'muted' }; const pct = r.fraction !== null && r.phase === 'rollout' ? ` ${Math.round(r.fraction * 100)}%` : ''; return { text: `${r.phase}${pct}`, tone: PHASE_TONE[r.phase] }; } export function trainText(t: ReleaseTrain | null, source: 'none' | 'live'): string { if (source === 'none') return 'not read'; return t ? t.version : 'none'; } export function Portfolio({ data, open, go }: { data: Data; open: (p: Project) => void; go: (s: 'apps') => void }) { const busy = data.portfolioBusy; return ( <>

Portfolio

Every app in this workspace on iOS and Android: identity, release train (current and next version on both stores), in-app catalog and config check.

{data.portfolioError &&
{data.portfolioError}
} {!data.projects.length ? (

No apps yet

Add an app folder (one storebound.config.ts per app) to see it here.

) : (
{data.projects.map(p => { const e = data.statusOf(p); const st = e ? checkState(e) : { text: busy ? 'checking' : 'not checked', tone: 'muted' as const }; const ios = e?.app?.platforms.ios, android = e?.app?.platforms.android; const cat = e?.catalog; return ( ); })}
AppiOSAndroidLiveNextCatalogConfig
{shortPath(p.path, data.home)}
{ios ? ios.bundleId : none}{e?.storeErrors.ios &&
unreadable
}
{android ? android.packageName : none}{e?.storeErrors.android &&
unreadable
}
{e ? trainText(e.release.current, e.release.source) : ''} {e ? trainText(e.release.next, e.release.source) : ''} {cat ? {cat.products} products ยท {cat.subscriptions} subs : ''} {st.text}
)} {data.portfolio &&

Last read {new Date(data.portfolio.at).toLocaleString()}

} ); }