- app view: 12 tabs become 5 sections, each with a header (what it is for, the one next step from state already read) and its sub views in a segmented control; 1-5 jump, Ctrl+Shift+[ ] cycle, Ctrl+K and the context menu list sections and sub views; old tab ids, section and section/sub links all resolve - Players > Game services (games only): both stores, one row per leaderboard / achievement with its languages and each store's state, Game Center locale map, Play API-disabled state with the console plan - games status --json: items, localeMap, playApiDisabled; inspect summary: games - sidebar: apps grouped by attention / in progress / live / not on a store, one status line each, studio filter, workspace as a footer icon row - boot check opens places like a person (section, then sub view)
60 lines
3.7 KiB
TypeScript
60 lines
3.7 KiB
TypeScript
// The header of one app section (docs IA): the section's name, one line on what it is for, the single next step
|
|
// derived from state that is already read (lib/sections.ts), and the sub views as a segmented control (only when the
|
|
// section has more than one).
|
|
import type { ListingsResult, StoreRelease } from '../api';
|
|
import { t } from '../i18n';
|
|
import type { UnifiedApp } from '../lib/identity';
|
|
import type { Attention } from '../lib/model';
|
|
import { sectionNext } from '../lib/sections';
|
|
import { type AppSection, type AppTab, SECTION_ICON, SECTION_KEY, TAB_ICON, TAB_KEY } from '../nav';
|
|
import { useCachedRead, useData } from '../store';
|
|
import type { GameServicesStatus } from '../ui/GameServicesCard';
|
|
import { Icon } from '../ui/icons';
|
|
|
|
const PURPOSE: Record<AppSection, 'sec.release.for' | 'sec.store.for' | 'sec.revenue.for' | 'sec.players.for' | 'sec.health.for'> = {
|
|
release: 'sec.release.for', store: 'sec.store.for', revenue: 'sec.revenue.for', players: 'sec.players.for', health: 'sec.health.for',
|
|
};
|
|
|
|
export function SectionHead({ app, section, tab, subs, att, all, next, unsaved, editCount, onTab }: {
|
|
app: UnifiedApp; section: AppSection; tab: AppTab; subs: AppTab[]; att: Attention[]; all: StoreRelease[]; next: string | null; unsaved: number;
|
|
editCount: (t: AppTab) => number; onTab: (t: AppTab) => void;
|
|
}) {
|
|
const d = useData();
|
|
const e = d.statusFor(app);
|
|
const pid = app.project && !app.project.missing ? app.project.id : null;
|
|
// cached reads only: the header never starts a store call
|
|
const listings = useCachedRead<ListingsResult>(section === 'store' ? pid : null, 'project.listings');
|
|
const reviews = useCachedRead<{ reply?: unknown }[]>(section === 'players' ? app.target : null, 'reviews.list', { days: 30 });
|
|
const games = useCachedRead<GameServicesStatus>(section === 'players' && subs.includes('games') ? pid : null, 'games.status');
|
|
const validate = useCachedRead<{ findings?: { level: string }[] }>(section === 'health' || section === 'release' ? pid : null, 'validate');
|
|
const n = sectionNext(section, {
|
|
project: !!app.project, att, all, next, summary: e?.summary ?? null, catalog: (d.liveFor(app) ?? e)?.catalog ?? null, unsaved, listings,
|
|
reviews: Array.isArray(reviews) ? reviews : null, readiness: validate?.findings ? validate.findings.filter(f => f.level === 'blocker').length : null,
|
|
games: games ? { changes: (games.apple?.changes.length ?? 0) + (games.play?.changes.length ?? 0), blockers: games.findings.filter(f => f.level === 'error').length, apiOff: !!games.playApiDisabled } : null,
|
|
});
|
|
return (
|
|
<div className="sec-head" data-testid="section-head">
|
|
<div className="sec-head-t">
|
|
<h2 className="sec-head-name"><Icon name={SECTION_ICON[section]} />{t(SECTION_KEY[section])}</h2>
|
|
<p className="sec-head-for">{t(PURPOSE[section])}</p>
|
|
</div>
|
|
<div className={`sec-next tone-${n.tone}`} role="status" data-testid="section-next">
|
|
<Icon name={n.icon} />
|
|
<span className="sec-next-t">{n.text}</span>
|
|
{n.tab && n.tab !== tab && <button className="btn btn-sm" onClick={() => onTab(n.tab!)}>{t('next.open', { where: t(TAB_KEY[n.tab]) })}<Icon name="arrowRight" /></button>}
|
|
</div>
|
|
{subs.length > 1 && (
|
|
<div className="seg sec-subs" role="group" aria-label={t('sec.views', { section: t(SECTION_KEY[section]) })}>
|
|
{subs.map(x => {
|
|
const c = editCount(x);
|
|
return (
|
|
<button key={x} id={`sub-${x}`} type="button" aria-pressed={tab === x} aria-controls="tabpanel" onClick={() => onTab(x)}>
|
|
<Icon name={TAB_ICON[x]} />{t(TAB_KEY[x])}{c > 0 && <span className="ed-dot" title={t('ed.unsaved', { count: c })} />}
|
|
</button>
|
|
);
|
|
})}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|