All files / modules/30-delegates/components/CreateDelegate/K8sDelegate/StepSuccessVerification StepSuccessVerifcation.tsx

100% Statements 21/21
72.22% Branches 13/18
100% Functions 4/4
100% Lines 21/21

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              3x   3x   3x 3x 3x 3x     3x   3x         3x 4x 3x 3x   3x 1x 1x     3x                                                                                               1x 1x                         1x       1x               3x  
/*
 * 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, Layout, StepProps, Heading, Text, Container } from '@wings-software/uicore'
 
import { useStrings } from 'framework/strings'
import CopyToClipboard from '@common/components/CopyToClipBoard/CopyToClipBoard'
import { useTelemetry } from '@common/hooks/useTelemetry'
import { Category, DelegateActions } from '@common/constants/TrackingConstants'
 
import type { K8sDelegateWizardData } from '../DelegateSetupStep/DelegateSetupStep'
import StepProcessing from '../../components/StepProcessing/StepProcessing'
 
import css from '../CreateK8sDelegate.module.scss'
 
interface StepSuccessVerifcationProps {
  onClose?: any
}
const StepSuccessVerification: React.FC<StepProps<K8sDelegateWizardData> & StepSuccessVerifcationProps> = props => {
  const { previousStep } = props
  const { getString } = useStrings()
  const { trackEvent } = useTelemetry()
 
  const onClickBack = (): void => {
    Eif (previousStep) {
      previousStep(props?.prevStepData)
    }
  }
  return (
    <>
      <Layout.Horizontal className={css.verificationBody}>
        <Layout.Vertical className={css.panelLeft}>
          <Layout.Horizontal>
            <Heading level={2} className={css.titleYamlVerification}>
              {getString('delegate.successVerification.applyYAMLTitle')}
            </Heading>
          </Layout.Horizontal>
          <Layout.Horizontal className={css.descriptionVerificationWrapper}>
            <Text font="normal" width={408}>
              {getString('delegate.successVerification.description1')}
            </Text>
          </Layout.Horizontal>
          <Layout.Horizontal>
            <Text font={{ weight: 'bold', size: 'normal' }} width={408}>
              {getString('delegate.successVerification.description2')}
            </Text>
          </Layout.Horizontal>
          <Layout.Horizontal spacing="medium" className={css.verificationFieldWrapper}>
            <Container
              intent="primary"
              padding="small"
              font={{
                align: 'center'
              }}
              flex
              className={css.verificationField}
            >
              <Text style={{ marginRight: '24px' }} font="small">
                {getString('delegate.verifyDelegateYamlCmnd')}
              </Text>
              <CopyToClipboard content={getString('delegate.verifyDelegateYamlCmnd').slice(2)} />
            </Container>
          </Layout.Horizontal>
        </Layout.Vertical>
        <Layout.Vertical>
          <hr className={css.verticalLine} />
        </Layout.Vertical>
        <Layout.Vertical>
          <StepProcessing name={props.prevStepData?.name} replicas={props.prevStepData?.replicas} />
        </Layout.Vertical>
      </Layout.Horizontal>
      <Layout.Horizontal padding="xxxlarge">
        <Button
          id="stepReviewScriptBackButton"
          text={getString('back')}
          onClick={() => {
            onClickBack()
            trackEvent(DelegateActions.VerificationBack, {
              category: Category.DELEGATE,
              data: props.prevStepData
            })
          }}
          icon="chevron-left"
          margin={{ right: 'small' }}
        />
        <Button
          text={getString('done')}
          intent="primary"
          padding="small"
          onClick={() => {
            trackEvent(DelegateActions.SaveCreateDelegate, {
              category: Category.DELEGATE,
              data: props.prevStepData
            })
            props?.onClose()
          }}
        />
      </Layout.Horizontal>
    </>
  )
}
 
export default StepSuccessVerification