All files / modules/85-cv/pages/components/ValidationStatus ValidationStatus.tsx

100% Statements 15/15
92.31% Branches 12/13
100% Functions 1/1
100% Lines 15/15

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              27x 27x 27x 27x   27x 27x   27x 24x 24x   24x   2x           6x           2x                     4x                                           10x      
/*
 * 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, Button, Container } from '@wings-software/uicore'
import { Color } from '@harness/design-system'
import { useStrings } from 'framework/strings'
import type { ValidationStatusProps } from './ValidationStatus.types'
import { StatusOfValidation } from './ValidationStatus.constants'
import css from './ValidationStatus.module.scss'
 
export default function ValidationStatus(props: ValidationStatusProps): JSX.Element {
  const { onClick, onRetry, validationStatus, textToDisplay } = props
  const { getString } = useStrings()
 
  switch (validationStatus) {
    case StatusOfValidation.IN_PROGRESS:
      return (
        <Text icon="steps-spinner" iconProps={{ size: 16 }}>
          {textToDisplay || getString('cv.monitoringSources.appD.verificationsInProgress')}
        </Text>
      )
    case StatusOfValidation.NO_DATA:
      return (
        <Text icon="issue" iconProps={{ size: 16 }} intent="none" className={css.validationButton} onClick={onClick}>
          {textToDisplay || getString('cv.monitoringSources.appD.noData')}
        </Text>
      )
    case StatusOfValidation.SUCCESS:
      return (
        <Text
          icon="tick"
          iconProps={{ size: 16, color: Color.GREEN_500 }}
          className={css.validationButton}
          onClick={onClick}
        >
          {textToDisplay || getString('cv.monitoringSources.appD.validationsPassed')}
        </Text>
      )
    case StatusOfValidation.ERROR:
      return (
        <Layout.Horizontal spacing="small" className={css.errorStatus}>
          <Text
            icon="warning-sign"
            iconProps={{ size: 16, color: Color.RED_500 }}
            intent="danger"
            lineClamp={3}
            className={css.validationButton}
            onClick={onClick}
          >
            {textToDisplay || getString('cv.monitoringSources.appD.validationsFailed')}
          </Text>
          <Button
            icon="refresh"
            iconProps={{ size: 12 }}
            color={Color.BLUE_500}
            text={getString('retry')}
            onClick={onRetry}
          />
        </Layout.Horizontal>
      )
    default:
      return <Container />
  }
}