// Checks: the offline config check (every time) and the read-only store readiness report (`validate`, on demand) // with its ordered blockers and fix hints. import type { Project } from '../../api'; import { t } from '../../i18n'; import { ago } from '../../lib/format'; import type { Finding, ValidateResult } from '../../lib/model'; import { useData, useRead } from '../../store'; import { Icon } from '../../ui/icons'; import { Card, Chip, Empty, ErrorNotice, Skeleton } from '../../ui/kit'; import { exportName, validateMd } from '../../lib/exports'; import { useExports } from '../../ui/Exports'; const LEVEL: Record = { blocker: ['bad', 'alertCircle'], warn: ['warn', 'alert'], ok: ['ok', 'check'] }; export function ChecksTab({ project }: { project: Project }) { const d = useData(); const e = d.statusOf(project); const v = useRead(project.id, 'validate', { network: true, title: t('checks.validate') }); const name = e?.summary?.name ?? project.name; useExports('checks', [{ id: 'validate-md', label: t('export.validate'), icon: 'shield', kind: 'md', file: exportName(name, 'store readiness'), disabled: v.data ? false : t('export.readFirst'), build: () => validateMd(name, v.data!, v.at) }]); const problems = [...(e?.errors ?? []), ...(e?.check?.problems ?? [])]; const warnings = e?.check?.warnings ?? []; const findings = [...(v.data?.findings ?? [])].sort((a, b) => ['blocker', 'warn', 'ok'].indexOf(a.level) - ['blocker', 'warn', 'ok'].indexOf(b.level)); return (
d.refreshPortfolio(false)} disabled={!!d.portfolioBusy}>{t('checks.again')}}> {!e ?
: !problems.length && !warnings.length ? ( {t('checks.cleanText')} ) : (
{problems.map((p, i) =>
{p}{t('checks.problem')}
)} {warnings.map((w, i) =>
{w}{t('checks.warning')}
)}
)}
{v.data ? t('action.refresh') : t('checks.run')}}> {v.error &&
} {!v.data ? ( v.loading && !v.error ?
: {t('checks.validateEmptyText')} ) : !findings.length ? {t('checks.readyText')} : (
{findings.map((f, i) => { const [tone, icon] = LEVEL[f.level]; return (
{f.msg} {f.fix && {f.fix}}
{f.store === 'apple' ? 'App Store' : 'Google Play'}
); })}
)}
); }