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 | 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 10x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 2x 2x 2x 1x 2x 2x 9x 9x 9x 1x 8x 4x 4x 9x 9x 9x 9x 5x 9x 9x 9x 9x 9x 16x | /* * 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, { useState } from 'react' import { Button, Heading, Container, Layout, IconName, Icon, Text } from '@wings-software/uicore' import { Color } from '@harness/design-system' import { useParams } from 'react-router-dom' import { String, useStrings } from 'framework/strings' import { useQueryParams } from '@common/hooks' import type { StringsMap } from 'stringTypes' import type { Module } from '@common/interfaces/RouteInterfaces' import ModuleInfoCards, { ModuleInfoCard, getInfoCardsProps } from '@common/components/ModuleInfoCards/ModuleInfoCards' import { useFeatureFlags } from '@common/hooks/useFeatureFlag' import { useUpdateAccountDefaultExperienceNG } from 'services/cd-ng' import { Experiences } from '@common/constants/Utils' import { useLicenseStore } from 'framework/LicenseStore/LicenseStoreContext' export interface StartTrialModalContentProps { handleStartTrial?: () => void module: Module } const StartTrialModalContent: React.FC<StartTrialModalContentProps> = props => { const { handleStartTrial, module } = props const { getString } = useStrings() const { CDNG_ENABLED, FREE_PLAN_ENABLED } = useFeatureFlags() const { accountId } = useParams<{ accountId: string }>() const { source } = useQueryParams<{ source?: string }>() const { mutate: updateDefaultExperience } = useUpdateAccountDefaultExperienceNG({ accountIdentifier: accountId }) const moduleInfoCards = getInfoCardsProps(accountId, CDNG_ENABLED)[module] const initialSelectedInfoCard = moduleInfoCards ? moduleInfoCards[0] : undefined const [selectedInfoCard, setSelectedInfoCard] = useState<ModuleInfoCard | undefined>(initialSelectedInfoCard) const { licenseInformation } = useLicenseStore() const getModuleButton = (): React.ReactElement => { const handleOnClick = async (): Promise<void> => { Iif (!selectedInfoCard || selectedInfoCard?.isNgRoute) { handleStartTrial?.() } else Eif (selectedInfoCard?.route) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore if (Object.keys(licenseInformation).length === 0) { await updateDefaultExperience({ defaultExperience: Experiences.CG }) } window.location.href = selectedInfoCard.route?.() return } } const startTrialDescription = FREE_PLAN_ENABLED ? 'common.startFreePlan' : 'common.startTrial' const getButtonText = (): string | undefined => { if (source) { return getString('continue') } if (selectedInfoCard?.route) { return getString('common.launchFirstGen' as keyof StringsMap, { module: module.toUpperCase() }) } return getString(startTrialDescription, { module: module === 'cf' ? 'FF' : module.toUpperCase() }) } return ( <Button width={270} border={{ radius: 4 }} height={2.5} font={{ align: 'center' }} padding={'medium'} intent="primary" text={getButtonText()} onClick={handleOnClick} /> ) } function getContentHeader(): React.ReactElement { const moduleName = module.toLowerCase() const title = getString(`${moduleName}.continuous` as keyof StringsMap) return ( <> <Heading color={Color.BLACK} font={{ size: 'large', weight: 'bold' }} padding={{ top: 'xxlarge' }} margin={{ bottom: 30 }} > {getString('common.purpose.welcome')} </Heading> <Layout.Horizontal spacing="small"> <Icon name={`${moduleName}-main` as IconName} size={25} /> <Text font={{ size: 'medium', weight: 'semi-bold' }} color={Color.BLACK}> {title} </Text> </Layout.Horizontal> </> ) } function getWarningBanner(): React.ReactElement | undefined { Iif (selectedInfoCard?.route) { const warningText = getString('common.ce.visibilityWarning') return ( <Container padding="medium" intent="warning" flex={{ justifyContent: 'start' }} background="yellow100" font={{ align: 'center' }} border={{ color: 'yellow500' }} > <Icon name={`deployment-incomplete-new`} size={25} style={{ marginRight: 10 }} /> <Text color={Color.BLACK}>{warningText}</Text> </Container> ) } } const infoCards = module && ( <ModuleInfoCards module={module} selectedInfoCard={selectedInfoCard} setSelectedInfoCard={setSelectedInfoCard} /> ) const button = getModuleButton() const contentHeader = getContentHeader() const warningBanner = module === 'ce' ? getWarningBanner() : null return ( <Layout.Vertical key={module} spacing="large" padding={{ bottom: 'xxxlarge' }}> {contentHeader} <String style={{ lineHeight: 2, fontSize: 'small' }} stringID={`common.purpose.${module}.description` as keyof StringsMap} useRichText={true} /> {infoCards} {warningBanner} {button} </Layout.Vertical> ) } export default StartTrialModalContent |