All files / modules/20-rbac/components/TrialHomePageTemplate TrialInProgressTemplate.tsx

100% Statements 20/20
100% Branches 4/4
100% Functions 2/2
100% Lines 19/19

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              4x 4x 4x 4x 4x 4x 4x 4x 4x 4x                                 4x 5x 5x 5x                                                           4x         5x 5x 5x           5x                                            
/*
 * 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 { Button, Container, Heading, Layout, Text } from '@wings-software/uicore'
import { Color } from '@harness/design-system'
import { useStrings } from 'framework/strings'
import { useModuleInfo } from '@common/hooks/useModuleInfo'
import { useTelemetry } from '@common/hooks/useTelemetry'
import { Category, PageNames } from '@common/constants/TrackingConstants'
import RbacButton from '@rbac/components/Button/Button'
import { FeatureIdentifier } from 'framework/featureStore/FeatureIdentifier'
import css from './TrialInProgressTemplate.module.scss'
 
interface TrialInProgressTemplateProps {
  title: string
  bgImageUrl: string
  isTrialInProgress?: boolean
  trialInProgressProps: TrialInProgressProps
}
 
interface TrialInProgressProps {
  description: string
  startBtn: {
    description: string
    onClick: () => void
  }
}
 
const TrialInProgressComponent: React.FC<TrialInProgressProps> = trialInProgressProps => {
  const { description, startBtn } = trialInProgressProps
  const { getString } = useStrings()
  return (
    <Layout.Vertical spacing="small">
      <Text className={css.description} padding={{ bottom: 'xxlarge' }} width={500}>
        {description}
      </Text>
      <Layout.Horizontal spacing="small">
        {startBtn.description === getString('createProject') ? (
          <RbacButton
            featuresProps={{
              featuresRequest: {
                featureNames: [FeatureIdentifier.MULTIPLE_PROJECTS]
              }
            }}
            width={200}
            height={45}
            intent="primary"
            text={startBtn.description}
            onClick={startBtn.onClick}
          />
        ) : (
          <Button width={200} height={45} intent="primary" text={startBtn.description} onClick={startBtn.onClick} />
        )}
        <Text font={{ size: 'medium' }} color={Color.BLACK} padding={'small'}>
          {getString('orSelectExisting')}
        </Text>
      </Layout.Horizontal>
    </Layout.Vertical>
  )
}
 
export const TrialInProgressTemplate: React.FC<TrialInProgressTemplateProps> = ({
  title,
  bgImageUrl,
  trialInProgressProps
}) => {
  const { getString } = useStrings()
  const { module } = useModuleInfo()
  useTelemetry({
    pageName: PageNames.TrialInProgress,
    category: Category.SIGNUP,
    properties: { module: module || '' }
  })
 
  return (
    <Container style={{ background: `transparent url(${bgImageUrl}) no-repeat` }} className={css.container}>
      <Layout.Vertical spacing="medium">
        <Layout.Horizontal spacing="small">
          <Heading font={{ weight: 'bold', size: 'large' }} color={Color.BLACK_100}>
            {title}
          </Heading>
          <Text
            padding={'xsmall'}
            border={{ radius: 3 }}
            color={Color.WHITE}
            background={Color.ORANGE_500}
            font={{ align: 'center' }}
          >
            {getString('common.trialInProgress')}
          </Text>
        </Layout.Horizontal>
        <TrialInProgressComponent {...trialInProgressProps} />
      </Layout.Vertical>
    </Container>
  )
}