22 lines
1.9 KiB
TypeScript
22 lines
1.9 KiB
TypeScript
export type StatusTone = 'neutral' | 'online' | 'warning' | 'danger' | 'info';
|
|
const states: Record<string, [string, StatusTone]> = {
|
|
provisioning: ['Provisioning', 'info'],
|
|
online: ['Online', 'online'], offline: ['Offline', 'danger'], stale: ['Report outdated', 'warning'], starting: ['Starting', 'info'],
|
|
queued: ['Queued', 'neutral'], pending: ['Queued for restart', 'neutral'], running: ['In progress', 'info'], active: ['In progress', 'info'],
|
|
deploying: ['Installing files', 'info'], restarting: ['Restarting', 'info'],
|
|
observing: ['Collecting test evidence', 'info'], 'rolling-back': ['Rolling back', 'info'],
|
|
'awaiting-empty': ['Waiting for empty lobby', 'neutral'], waiting: ['Waiting', 'neutral'],
|
|
'awaiting-health': ['Verifying health', 'info'], 'awaiting-match': ['Waiting for a match', 'neutral'],
|
|
ready: ['Ready', 'online'], 'ready-promote': ['Ready to promote', 'online'],
|
|
done: ['Completed', 'online'], passed: ['Test passed', 'online'], tested: ['Test passed', 'online'],
|
|
promoted: ['Promoted', 'online'], 'rolled-back': ['Rolled back', 'neutral'], cancelled: ['Cancelled', 'neutral'],
|
|
failed: ['Failed', 'danger'], 'test-failed': ['Test failed', 'danger'], interrupted: ['Interrupted', 'danger'],
|
|
warning: ['Completed with warnings', 'warning'], held: ['On hold', 'neutral'], skipped: ['Withdrawn', 'neutral'],
|
|
manual: ['Manual action needed', 'warning'], paused: ['Paused', 'warning'], inconclusive: ['Missing evidence', 'warning'],
|
|
untested: ['Needs testing', 'neutral'], testing: ['Beta active', 'info'], empty: ['No versions', 'neutral'], attention: ['Needs attention', 'warning']
|
|
};
|
|
export function statusPresentation(state: string): { label: string; tone: StatusTone } {
|
|
const result = states[state];
|
|
return result ? { label: result[0], tone: result[1] } : { label: (state.charAt(0).toUpperCase() + state.slice(1)).replaceAll('-', ' '), tone: 'neutral' };
|
|
}
|