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 269 270 271 | 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 22x 2x 17x 14x 14x 14x 98x 28x 17x 13x 13x 13x 13x 13x 13x 14x 2x 2x 14x 14x 13x 13x 14x 13x 6x 7x 17x | /* * 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 { Text, Icon, IconName, Heading, Card, Layout } from '@wings-software/uicore' import { Color } from '@harness/design-system' import cx from 'classnames' import { useParams } from 'react-router-dom' import { useStrings } from 'framework/strings' import type { Module } from '@common/interfaces/RouteInterfaces' import type { StringsMap } from 'stringTypes' import { useFeatureFlags } from '@common/hooks/useFeatureFlag' import css from './ModuleInfoCards.module.scss' interface InfoCards { [key: string]: Array<ModuleInfoCard> } interface ModuleInfoCardsProps { module: Module selectedInfoCard: ModuleInfoCard | undefined setSelectedInfoCard: (moduleInfoCard: ModuleInfoCard) => void style?: React.CSSProperties className?: string fontColor?: string } type FooterProps = { title: string icons: { name: string enabled: boolean }[] } export interface ModuleInfoCard { icon: IconName iconClassName?: string title: string subtitle?: string description: string route?: () => string isNgRoute?: boolean isNew?: boolean footer?: FooterProps disabled?: boolean } const INFO_CARD_STYLES: { [key: string]: string } = { cd: css.cd } export const getInfoCardsProps = (accountId: string, CDNG_ENABLED = true): InfoCards => { return { cd: [ { icon: 'command-approval', iconClassName: css.commandApproval, title: 'common.purpose.cd.1stGen.title', description: 'common.purpose.cd.1stGen.description', route: () => `${window.location.href.split('/ng/')[0]}/#/account/${accountId}/onboarding`, footer: { title: 'common.purpose.cd.supportedStack', icons: [ { name: 'app-aws-code-deploy', enabled: true }, { name: 'service-aws-lamda', enabled: true }, { name: 'main-service-ami', enabled: true }, { name: 'app-kubernetes', enabled: true }, { name: 'command-winrm', enabled: true }, { name: 'service-pivotal', enabled: true }, { name: 'app-aws-lambda', enabled: true } ] } }, { icon: 'cd-solid', iconClassName: css.cdMain, title: 'common.purpose.cd.newGen.title', description: 'common.purpose.cd.newGen.description', isNgRoute: true, disabled: !CDNG_ENABLED, isNew: true, footer: { title: 'common.purpose.cd.supportedStack', icons: [ { name: 'app-kubernetes', enabled: true }, { name: 'app-aws-code-deploy', enabled: false }, { name: 'service-aws-lamda', enabled: false }, { name: 'main-service-ami', enabled: false }, { name: 'command-winrm', enabled: false }, { name: 'service-pivotal', enabled: false }, { name: 'app-aws-lambda', enabled: false } ] } } ] } } const Footer = ({ footer, fontColor }: { footer: FooterProps; fontColor: string }): React.ReactElement => { const { getString } = useStrings() const { title, icons } = footer return ( <Layout.Vertical padding={{ top: 'large' }}> <Text className={css.footerTitle} color={fontColor}> {getString(title as keyof StringsMap)} </Text> <Layout.Horizontal spacing="small"> {icons.map(icon => icon.enabled ? ( <Text key={icon.name} icon={icon.name as IconName} className={css.enabled} /> ) : ( <Text key={icon.name} icon={icon.name as IconName} tooltip="coming soon" iconProps={{ style: { opacity: '0.5' } }} /> ) )} </Layout.Horizontal> </Layout.Vertical> ) } const getCardKey = ({ key1, key2 }: { key1?: string; key2?: string }): string => `${key1} ${key2}` const ModuleInfoCards: React.FC<ModuleInfoCardsProps> = props => { const { module, selectedInfoCard, setSelectedInfoCard, style } = props const { getString } = useStrings() const { CDNG_ENABLED } = useFeatureFlags() const { accountId } = useParams<{ accountId: string }>() const fontColor = props.fontColor ? props.fontColor : Color.BLACK const getModuleInfoCards = (infoCard: ModuleInfoCard, infoCardStyle: string): React.ReactElement => { const cardKey = getCardKey({ key1: infoCard.title, key2: infoCard.subtitle }) function handleCardClick(): void { Eif (!infoCard.disabled) { setSelectedInfoCard(infoCard) } } const selected = getCardKey({ key1: selectedInfoCard?.title, key2: selectedInfoCard?.subtitle }) === cardKey return ( <Card key={cardKey} disabled={infoCard.disabled} selected={selected} className={cx(css.card, css.infoCard, infoCardStyle, props.className)} onClick={handleCardClick} > <Layout.Horizontal spacing="small" padding={{ bottom: 'large' }}> <Icon className={infoCard.iconClassName} name={infoCard.icon} size={40} /> <div> <Layout.Horizontal spacing="small"> <Text font="xsmall" color={fontColor} className={css.title}> {getString(infoCard.title as keyof StringsMap)} </Text> {infoCard.isNew && ( <Text className={css.new} background={Color.PRIMARY_5} width={48} height={22} color={Color.WHITE} border={{ radius: 0 }} font={{ align: 'center', size: 'small', weight: 'light' }} margin={{ left: 30 }} > {getString('common.new').toUpperCase()} </Text> )} </Layout.Horizontal> {infoCard.subtitle && ( <Text font={{ size: 'medium' }} color={fontColor}> {getString(infoCard.subtitle as keyof StringsMap)} </Text> )} </div> </Layout.Horizontal> <Text font="small" padding={{ bottom: 'small' }} color={fontColor}> {getString(infoCard.description as keyof StringsMap)} </Text> {infoCard.footer && <Footer footer={infoCard.footer} fontColor={fontColor} />} </Card> ) } const infoCardProps = getInfoCardsProps(accountId, CDNG_ENABLED)[module] const infoCardStyle = INFO_CARD_STYLES[module] const infoCards = infoCardProps?.map(cardProps => getModuleInfoCards(cardProps, infoCardStyle)) if (!infoCardProps) { return <></> } return ( <> <Layout.Horizontal flex={{ justifyContent: 'space-between' }}> <Heading color={Color.BLACK} font={{ size: 'medium', weight: 'bold' }} padding={{ top: 'xlarge' }}> {getString('common.purpose.howToProceed')} </Heading> </Layout.Horizontal> <Layout.Horizontal spacing="small" style={{ ...style }}> {infoCards} </Layout.Horizontal> <a className={css.compareVersion} href="https://ngdocs.harness.io/article/1fjmm4by22-harness-first-gen-vs-harness-next-gen" target="_blank" rel="noreferrer" > {getString('common.purpose.compare')} </a> </> ) } export default ModuleInfoCards |