github.com/freiheit-com/kuberpult@v1.24.2-0.20240328135542-315d5630abe6/services/frontend-service/src/ui/components/ServiceLane/Warnings.tsx (about) 1 /*This file is part of kuberpult. 2 3 Kuberpult is free software: you can redistribute it and/or modify 4 it under the terms of the Expat(MIT) License as published by 5 the Free Software Foundation. 6 7 Kuberpult is distributed in the hope that it will be useful, 8 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 MIT License for more details. 11 12 You should have received a copy of the MIT License 13 along with kuberpult. If not, see <https://directory.fsf.org/wiki/License:Expat>. 14 15 Copyright 2023 freiheit.com*/ 16 import * as React from 'react'; 17 import { Application, UnusualDeploymentOrder, UpstreamNotDeployed, Warning } from '../../../api/api'; 18 19 export const WarningBoxes: React.FC<{ application: Application }> = (props) => { 20 const { application } = props; 21 22 return ( 23 <div className="warnings"> 24 {application.warnings.map((warning: Warning, index: number) => ( 25 <div key={'warning-' + String(index)} className={'service-lane__warning'}> 26 <WarningBox warning={warning} /> 27 </div> 28 ))} 29 </div> 30 ); 31 }; 32 33 export const WarningBoxUnusualDeploymentOrder: React.FC<{ warning: UnusualDeploymentOrder }> = (props) => { 34 const warning = props.warning; 35 const tooltip = 36 warning.thisEnvironment + 37 ' may be overridden with the next release train from ' + 38 warning.upstreamEnvironment + 39 ' to ' + 40 warning.thisEnvironment + 41 '. Suggestion: Create a lock on ' + 42 warning.thisEnvironment + 43 ' or deploy the same version to both environments.'; 44 45 return ( 46 <div className={'warning'} title={tooltip}> 47 <b>Warning: {warning.thisEnvironment}</b> is not locked and has a newer version than{' '} 48 <b>{warning.upstreamEnvironment}</b>! ⓘ 49 </div> 50 ); 51 }; 52 53 export const WarningUpstreamNotDeployed: React.FC<{ warning: UpstreamNotDeployed }> = (props) => { 54 const warning = props.warning; 55 const tooltip = 56 warning.thisEnvironment + 57 ' may be overridden with the next release train from ' + 58 warning.upstreamEnvironment + 59 ' to ' + 60 warning.thisEnvironment + 61 '. Suggestion: Create a lock on ' + 62 warning.thisEnvironment + 63 ' or deploy the same version to both environments.'; 64 65 return ( 66 <div className={'warning'} title={tooltip}> 67 <b>Warning: {warning.upstreamEnvironment}</b> has no version deployed, but {warning.thisEnvironment} does! ⓘ 68 </div> 69 ); 70 }; 71 72 export const WarningBox: React.FC<{ warning: Warning }> = (props) => { 73 const { warning } = props; 74 switch (warning.warningType?.$case) { 75 case 'unusualDeploymentOrder': 76 return <WarningBoxUnusualDeploymentOrder warning={warning.warningType.unusualDeploymentOrder} />; 77 case 'upstreamNotDeployed': 78 return <WarningUpstreamNotDeployed warning={warning.warningType.upstreamNotDeployed} />; 79 default: 80 // eslint-disable-next-line no-console 81 console.error('Warning type not recognized: ', JSON.stringify(warning)); 82 return <div>Could not render Warning</div>; 83 } 84 };