github.com/freiheit-com/kuberpult@v1.24.2-0.20240328135542-315d5630abe6/services/frontend-service/src/ui/components/ReleaseCardMini/ReleaseCardMini.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 classNames from 'classnames'; 17 import React from 'react'; 18 import { useOpenReleaseDialog, useReleaseOrThrow } from '../../utils/store'; 19 import { EnvironmentGroupChipList } from '../chip/EnvironmentGroupChip'; 20 import { undeployTooltipExplanation } from '../ReleaseDialog/ReleaseDialog'; 21 import { FormattedDate } from '../FormattedDate/FormattedDate'; 22 import { ReleaseVersionWithLinks } from '../ReleaseVersion/ReleaseVersion'; 23 24 export type ReleaseCardMiniProps = { 25 className?: string; 26 version: number; 27 app: string; 28 }; 29 30 export const ReleaseCardMini: React.FC<ReleaseCardMiniProps> = (props) => { 31 const { className, app, version } = props; 32 // the ReleaseCardMini only displays actual releases, so we can assume that it exists here: 33 const { createdAt, sourceMessage, sourceAuthor, undeployVersion } = useReleaseOrThrow(app, version); 34 const openReleaseDialog = useOpenReleaseDialog(app, version); 35 const displayedMessage = undeployVersion ? 'Undeploy Version' : sourceMessage; 36 const displayedTitle = undeployVersion ? undeployTooltipExplanation : ''; 37 const release = useReleaseOrThrow(app, version); 38 return ( 39 <div className={classNames('release-card-mini', className)} onClick={openReleaseDialog}> 40 <div className={classNames('release__details-mini', className)}> 41 <div className="release__details-header" title={displayedTitle}> 42 <div className="release__details-header-title">{displayedMessage}</div> 43 <div className="release__environments-mini"> 44 <EnvironmentGroupChipList app={props.app} version={props.version} /> 45 </div> 46 </div> 47 <div className={'release__details-source-line'}> 48 <ReleaseVersionWithLinks application={app} release={release} /> 49 </div> 50 <div className="release__details-msg"> 51 {sourceAuthor + ' | '} 52 {!!createdAt && <FormattedDate createdAt={createdAt} className="release__metadata-mini" />} 53 </div> 54 </div> 55 </div> 56 ); 57 };