go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/milo/ui/src/bisection/components/status_info/status_info.tsx (about) 1 // Copyright 2023 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 import Typography from '@mui/material/Typography'; 16 17 import { 18 AnalysisStatus, 19 RerunStatus, 20 } from '@/proto/go.chromium.org/luci/bisection/proto/v1/common.pb'; 21 22 interface LabelProps { 23 text: string; 24 color: string; 25 } 26 27 const RERUN_STATUS_LABELS: Record<RerunStatus, LabelProps> = { 28 [RerunStatus.UNSPECIFIED]: { 29 text: 'Unknown', 30 color: 'var(--default-text-color)', 31 }, 32 [RerunStatus.PASSED]: { 33 text: 'Passed', 34 color: 'var(--success-color)', 35 }, 36 [RerunStatus.FAILED]: { 37 text: 'Failed', 38 color: 'var(--failure-color)', 39 }, 40 [RerunStatus.IN_PROGRESS]: { 41 text: 'In progress', 42 color: 'var(--started-color)', 43 }, 44 [RerunStatus.INFRA_FAILED]: { 45 text: 'Infra failed', 46 color: 'var(--critical-failure-color)', 47 }, 48 [RerunStatus.CANCELED]: { 49 text: 'Canceled', 50 color: 'var(--canceled-color)', 51 }, 52 [RerunStatus.TEST_SKIPPED]: { 53 text: 'Test skipped', 54 color: 'var(--critical-failure-color)', 55 }, 56 }; 57 58 const ANALYSIS_STATUS_LABELS: Record<AnalysisStatus, LabelProps> = { 59 [AnalysisStatus.UNSPECIFIED]: { 60 text: 'Unknown', 61 color: 'var(--default-text-color)', 62 }, 63 [AnalysisStatus.CREATED]: { 64 text: 'Created', 65 color: 'var(--scheduled-color)', 66 }, 67 [AnalysisStatus.RUNNING]: { text: 'Running', color: 'var(--started-color)' }, 68 [AnalysisStatus.FOUND]: { 69 text: 'Culprit found', 70 color: 'var(--success-color)', 71 }, 72 [AnalysisStatus.NOTFOUND]: { 73 text: 'Suspect not found', 74 color: 'var(--failure-color)', 75 }, 76 [AnalysisStatus.SUSPECTFOUND]: { 77 text: 'Suspect found', 78 color: 'var(--suspect-found-color)', 79 }, 80 [AnalysisStatus.ERROR]: { 81 text: 'Error', 82 color: 'var(--critical-failure-color)', 83 }, 84 [AnalysisStatus.UNSUPPORTED]: { 85 text: 'Unsupported', 86 color: 'var(--canceled-color)', 87 }, 88 [AnalysisStatus.DISABLED]: { 89 text: 'Disabled', 90 color: 'var(--canceled-color)', 91 }, 92 [AnalysisStatus.INSUFFICENTDATA]: { 93 text: 'Insufficient data', 94 color: 'var(--canceled-color)', 95 }, 96 }; 97 98 export interface RerunStatusInfoProps { 99 readonly status: RerunStatus; 100 } 101 102 export function RerunStatusInfo({ status }: RerunStatusInfoProps) { 103 const statusLabel = RERUN_STATUS_LABELS[status]; 104 105 return <Typography color={statusLabel.color}>{statusLabel.text}</Typography>; 106 } 107 108 export interface AnalysisStatusInfoProps { 109 status: AnalysisStatus; 110 } 111 112 export function AnalysisStatusInfo({ status }: AnalysisStatusInfoProps) { 113 const statusLabel = ANALYSIS_STATUS_LABELS[status]; 114 115 return <Typography color={statusLabel.color}>{statusLabel.text}</Typography>; 116 }