File size: 1,274 Bytes
af1bee9
fb43301
af1bee9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { usePatchWatch, usePodProfile, usePods } from '../../api/hooks';
import { shortWhen } from '../../domain/runName';

/** The release the readiness is about, as the page's one-line sub-title: "Patch 26C. Test environment release 26C, checked 18 Oct 23:53."

 * "Next Oracle update" is shown only when the API gives a date; it is never guessed. The environment cue lives in the top bar. */
export function ReleaseLine({ podId, patch, nextUpdate }: { podId: number | null; patch: string | null; nextUpdate?: string | null }) {
  const pods = usePods().data ?? [];
  const pod = pods.find((p) => p.id === podId);
  const profile = usePodProfile();
  const watch = usePatchWatch();
  const release = profile.data?.about?.release ?? pod?.release ?? null;
  const checked = watch.data?.last_checked_at ?? profile.data?.scanned_at ?? null;
  const parts = [
    patch ? `Patch ${patch}.` : '',
    release ? `Test environment release ${release}${checked ? `, checked ${shortWhen(checked)}` : ''}.` : '',
    nextUpdate ? `Next Oracle update: ${shortWhen(nextUpdate).replace(/ \d\d:\d\d$/, '')}.` : '',
  ].filter(Boolean);
  if (!parts.length) return null;
  return <span className="fpt-release-line" data-testid="release-line">{parts.join(' ')}</span>;
}