All files / modules/85-cv/pages/monitored-service/views DetailsToolbar.tsx

100% Statements 14/14
83.33% Branches 15/18
100% Functions 1/1
100% Lines 14/14

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              9x 9x 9x 9x 9x 9x 9x       9x 2x   2x   2x 1x                 1x                                       9x  
/*
 * 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 moment from 'moment'
import { Classes } from '@blueprintjs/core'
import { Layout, Container, Text } from '@wings-software/uicore'
import { FontVariation, Color } from '@harness/design-system'
import { useStrings } from 'framework/strings'
import { EnvironmentToolTipDisplay } from '@cv/components/HarnessServiceAndEnvironment/components/EnvironmentToolTipDisplay'
import type { ToolbarProps } from '../MonitoredServicePage.types'
import type { ExtendedMonitoredServiceDTO } from '../components/Configurations/Configurations.utils'
 
const DetailsToolbar: React.FC<ToolbarProps> = ({ loading, monitoredService, lastModifiedAt }) => {
  const { getString } = useStrings()
 
  const envRefList = (monitoredService as ExtendedMonitoredServiceDTO)?.environmentRefList
 
  if (loading) {
    return (
      <Layout.Vertical spacing="xsmall">
        <Container height={15} width={220} className={Classes.SKELETON} />
        <Container height={15} width={220} className={Classes.SKELETON} />
        <Container height={15} width={220} className={Classes.SKELETON} />
      </Layout.Vertical>
    )
  }
 
  return (
    <Layout.Vertical spacing="xsmall">
      <Text color={Color.BLACK} font={{ variation: FontVariation.SMALL_SEMI }}>
        {`${getString('lastUpdated')}: ${moment(lastModifiedAt).format('lll')}`}
      </Text>
      <EnvironmentToolTipDisplay
        type={monitoredService?.type}
        color={Color.BLACK}
        font={{ variation: FontVariation.SMALL_SEMI }}
        envRefList={envRefList}
        environmentRef={monitoredService?.environmentRef}
        shouldAddEnvPrefix={true}
      />
      <Text color={Color.BLACK} font={{ variation: FontVariation.SMALL_SEMI }}>
        {`${getString('typeLabel')}: ${monitoredService?.type}`}
      </Text>
    </Layout.Vertical>
  )
}
 
export default DetailsToolbar