All files / modules/85-cv/hooks/useLogContentHook/views/ExternalAPICall ExternalAPICall.tsx

100% Statements 22/22
83.33% Branches 15/18
100% Functions 4/4
100% Lines 22/22

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              17x 17x 17x 17x 17x 17x 17x 17x   17x                                 18x   18x 4x 1x 1x       18x 1x 1x     18x 1x 1x     18x                                                                   17x  
/*
 * Copyright 2022 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 cx from 'classnames'
import { Layout, SelectOption } from '@harness/uicore'
import LogContentHeader from '../LogContentHeader/LogContentHeader'
import LogContentToolbar from '../LogContentToolbar/LogContentToolbar'
import ExternalAPICallContent from './ExternalAPICallContent'
import { ExecutionAndAPICallLogProps, LogTypes } from '../../useLogContentHook.types'
import css from './ExternalAPICall.module.scss'
 
const ExternalAPICall: React.FC<ExecutionAndAPICallLogProps> = props => {
  const {
    isFullScreen,
    setIsFullScreen,
    verifyStepExecutionId,
    monitoredServiceIdentifier,
    serviceName,
    envName,
    healthSource,
    setHealthSource,
    timeRange,
    setTimeRange,
    errorLogsOnly,
    setErrorLogsOnly,
    setPageNumber,
    resource,
    handleDownloadLogs
  } = props
 
  const handleHealthSource = (_healthSource: SelectOption): void => {
    if (_healthSource.value !== healthSource?.value) {
      setPageNumber(0)
      setHealthSource?.(_healthSource)
    }
  }
 
  const handleTimeRange = (_timeRange: SelectOption): void => {
    setPageNumber(0)
    setTimeRange?.(_timeRange)
  }
 
  const handleDisplayOnlyErrors = (_errorLogsOnly: boolean): void => {
    setPageNumber(0)
    setErrorLogsOnly(_errorLogsOnly)
  }
 
  return (
    <div>
      <LogContentHeader
        logType={LogTypes.ApiCallLog}
        verifyStepExecutionId={verifyStepExecutionId}
        serviceName={serviceName}
        envName={envName}
        healthSource={healthSource}
        handleHealthSource={handleHealthSource}
        monitoredServiceIdentifier={monitoredServiceIdentifier}
        timeRange={timeRange}
        handleTimeRange={handleTimeRange}
        errorLogsOnly={errorLogsOnly}
        handleDisplayOnlyErrors={handleDisplayOnlyErrors}
      />
      <LogContentToolbar
        logType={LogTypes.ApiCallLog}
        data={resource?.content}
        isFullScreen={isFullScreen}
        setIsFullScreen={setIsFullScreen}
        isVerifyStep={Boolean(verifyStepExecutionId)}
        timeRange={timeRange}
        isMonitoredService={Boolean(monitoredServiceIdentifier)}
        handleDownloadLogs={handleDownloadLogs}
      />
      <div className={cx(css.accordionContainer, { [css.fullScreen]: isFullScreen })}>
        <Layout.Vertical height="100%">
          <ExternalAPICallContent {...props} errorLogsOnly={errorLogsOnly} />
        </Layout.Vertical>
      </div>
    </div>
  )
}
 
export default ExternalAPICall