Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | 100x 100x 100x 100x 100x 100x 100x 100x 100x 20x 20x 20x 20x 17x 17x 20x 2x 23x 23x 23x 23x 23x 23x 23x 2x 100x | /* * Copyright 2021 Harness Inc. All rights reserved. * Use of this source code is governed by the PolyForm Shield 1.0.0 license * that can be found in the licenses directory at the root of this repository, also available at * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt. */ import React from 'react' import { Layout, Text, Icon, getMultiTypeFromValue, MultiTypeInputType, Button, ButtonSize, ButtonVariation, Container } from '@wings-software/uicore' import cx from 'classnames' import { Color, FontVariation } from '@harness/design-system' import { useStrings } from 'framework/strings' import { getConnectorNameFromValue, getStatus } from '@pipeline/components/PipelineStudio/StageBuilder/StageBuilderUtil' import type { SidecarArtifactWrapper } from 'services/cd-ng' import { ArtifactIconByType, ENABLED_ARTIFACT_TYPES, ModalViewFor } from '@pipeline/components/ArtifactsSelection/ArtifactHelper' import type { ArtifactListViewProps, ArtifactType } from '../ArtifactInterface' import { showConnectorStep } from '../ArtifactUtils' import css from '../ArtifactsSelection.module.scss' function ArtifactRepositoryTooltip({ artifactType, artifactConnectorName, artifactConnectorRef }: { artifactType: ArtifactType artifactConnectorName?: string artifactConnectorRef: string }): React.ReactElement | null { if (artifactType === ENABLED_ARTIFACT_TYPES.CustomArtifact) { return null } return ( <Container className={css.borderRadius} padding="medium"> <div> <Text font="small" color={Color.GREY_100}> {artifactConnectorName} </Text> <Text font="small" color={Color.GREY_300}> {artifactConnectorRef} </Text> </div> </Container> ) } function ArtifactListView({ accountId, fetchedConnectorResponse, primaryArtifact, sideCarArtifact, isReadonly, editArtifact, overrideSetIdentifier, removePrimary, removeSidecar, addNewArtifact }: ArtifactListViewProps): React.ReactElement { const { getString } = useStrings() const { color: primaryConnectorColor } = getStatus( primaryArtifact?.spec?.connectorRef, fetchedConnectorResponse, accountId ) const primaryConnectorName = getConnectorNameFromValue(primaryArtifact?.spec?.connectorRef, fetchedConnectorResponse) const getPrimaryArtifactRepository = (artifactType: ArtifactType): string => { Iif (artifactType === ENABLED_ARTIFACT_TYPES.CustomArtifact) { return getString('common.repo_provider.customLabel') } return primaryConnectorName ?? primaryArtifact.spec?.connectorRef } return ( <Layout.Vertical style={{ width: '100%' }}> <Layout.Vertical spacing="small" style={{ flexShrink: 'initial' }}> {!!(sideCarArtifact?.length || primaryArtifact?.type) && ( <div className={cx(css.artifactList, css.listHeader)}> <span></span> <Text font={{ variation: FontVariation.TABLE_HEADERS }}>{getString('artifactRepository')}</Text> <Text font={{ variation: FontVariation.TABLE_HEADERS }}>{getString('location')}</Text> <span></span> </div> )} <Layout.Vertical style={{ flexShrink: 'initial' }}> <section> {primaryArtifact && ( <section className={cx(css.artifactList, css.rowItem)} key={'Dockerhub'}> <div> <Text width={200} className={css.type} color={Color.BLACK} lineClamp={1}> {getString('primary')} </Text> </div> <div className={css.connectorNameField}> <Icon padding={{ right: 'small' }} name={ArtifactIconByType[primaryArtifact.type]} size={18} /> <Text tooltip={ <ArtifactRepositoryTooltip artifactConnectorName={primaryConnectorName} artifactConnectorRef={primaryArtifact.spec?.connectorRef} artifactType={primaryArtifact.type} /> } tooltipProps={{ isDark: true }} alwaysShowTooltip={showConnectorStep(primaryArtifact.type)} className={css.connectorName} lineClamp={1} > {getPrimaryArtifactRepository(primaryArtifact.type)} </Text> {getMultiTypeFromValue(primaryArtifact.spec?.connectorRef) === MultiTypeInputType.FIXED && ( <Icon name="full-circle" size={8} color={primaryConnectorColor} /> )} </div> <div> <Text width={340} lineClamp={1} style={{ color: Color.GREY_500 }}> <span className={css.noWrap}> {primaryArtifact.spec.imagePath ?? primaryArtifact.spec.artifactPath} </span> </Text> </div> {overrideSetIdentifier?.length === 0 && !isReadonly && ( <Layout.Horizontal> <Button icon="Edit" minimal iconProps={{ size: 18 }} onClick={() => editArtifact(ModalViewFor.PRIMARY, primaryArtifact.type)} /> <Button iconProps={{ size: 18 }} minimal icon="main-trash" onClick={removePrimary} /> </Layout.Horizontal> )} </section> )} </section> {sideCarArtifact && sideCarArtifact?.length > 0 && ( <section> {sideCarArtifact?.map((data: SidecarArtifactWrapper, index: number) => { const { sidecar } = data const { color: sideCarConnectionColor } = getStatus( sidecar?.spec?.connectorRef, fetchedConnectorResponse, accountId ) const sidecarConnectorName = getConnectorNameFromValue( sidecar?.spec?.connectorRef, fetchedConnectorResponse ) const getSidecarArtifactRepository = (artifactType: ArtifactType): string => { Iif (artifactType === ENABLED_ARTIFACT_TYPES.CustomArtifact) { return getString('common.repo_provider.customLabel') } return sidecarConnectorName ?? sidecar?.spec?.connectorRef } return ( <section className={cx(css.artifactList, css.rowItem)} key={`${sidecar?.identifier}-${index}`}> <div> <Text width={200} className={css.type} color={Color.BLACK} lineClamp={1}> {getString('sidecar')} <Text lineClamp={1} className={css.artifactId}> ({getString('common.ID')}: {sidecar?.identifier}) </Text> </Text> </div> <div className={css.connectorNameField}> <Icon padding={{ right: 'small' }} name={ArtifactIconByType[sidecar?.type as ArtifactType]} size={18} /> <Text className={css.connectorName} lineClamp={1} tooltip={ <ArtifactRepositoryTooltip artifactConnectorName={sidecarConnectorName} artifactConnectorRef={sidecar?.spec?.connectorRef} artifactType={sidecar?.type as ArtifactType} /> } tooltipProps={{ isDark: true }} alwaysShowTooltip={showConnectorStep(sidecar?.type as ArtifactType)} > {getSidecarArtifactRepository(sidecar?.type as ArtifactType)} </Text> {getMultiTypeFromValue(sidecar?.spec?.connectorRef) === MultiTypeInputType.FIXED && ( <Icon name="full-circle" size={8} color={sideCarConnectionColor} /> )} </div> <div className={css.locationField}> <Text width={340} lineClamp={1} style={{ color: Color.GREY_500 }}> <span className={css.noWrap}>{sidecar?.spec.imagePath ?? sidecar?.spec.artifactPath}</span> </Text> </div> {overrideSetIdentifier?.length === 0 && !isReadonly && ( <span> <Layout.Horizontal> <Button icon="Edit" minimal iconProps={{ size: 18 }} onClick={() => { editArtifact(ModalViewFor.SIDECAR, sidecar?.type as ArtifactType, index) }} /> <Button iconProps={{ size: 18 }} icon="main-trash" minimal onClick={() => removeSidecar(index)} /> </Layout.Horizontal> </span> )} </section> ) })} </section> )} </Layout.Vertical> </Layout.Vertical> <Layout.Vertical spacing={'medium'} flex={{ alignItems: 'flex-start' }}> {!primaryArtifact && overrideSetIdentifier?.length === 0 && !isReadonly && ( <Button className={css.addArtifact} id="add-artifact" size={ButtonSize.SMALL} variation={ButtonVariation.LINK} onClick={() => addNewArtifact(ModalViewFor.PRIMARY)} text={getString('pipelineSteps.serviceTab.artifactList.addPrimary')} /> )} {!overrideSetIdentifier?.length && !isReadonly && ( <Button className={css.addArtifact} id="add-artifact" size={ButtonSize.SMALL} variation={ButtonVariation.LINK} onClick={() => addNewArtifact(ModalViewFor.SIDECAR)} text={getString('pipelineSteps.serviceTab.artifactList.addSidecar')} /> )} </Layout.Vertical> </Layout.Vertical> ) } export default ArtifactListView |