All files / modules/70-pipeline/pages/pipelines PipelineListUtils.ts

84.21% Statements 16/19
69.23% Branches 18/26
100% Functions 2/2
82.35% Lines 14/17

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                9x         9x 24x   8x   16x                         9x 189x 189x 189x   189x 63x   189x     189x     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 type { IconName } from '@wings-software/uicore'
import { Color } from '@harness/design-system'
import type { PMSPipelineSummaryResponse } from 'services/pipeline-ng'
import type { StringKeys } from 'framework/strings'
import type { ServiceDefinition } from 'services/cd-ng'
 
export const getStatusColor = (data: PMSPipelineSummaryResponse): string => {
  switch (data.executionSummaryInfo?.lastExecutionStatus) {
    case 'Success':
      return Color.GREEN_800
    case 'Failed':
      return Color.RED_800
    case 'Running':
      return Color.BLUE_800
    default:
      return Color.GREEN_800
  }
}
 
interface IconProps {
  icon: IconName
  size: number
}
 
export const getIconsForPipeline = (data: PMSPipelineSummaryResponse): IconProps[] => {
  const icons: IconProps[] = []
  Eif (data.modules?.includes('cd')) {
    icons.push({ icon: 'cd-main', size: 16 })
  }
  if (data.modules?.includes('ci')) {
    icons.push({ icon: 'ci-main', size: 16 })
  }
  Iif (data.modules?.includes('cv')) {
    icons.push({ icon: 'cv-main', size: 16 })
  }
  return icons
}
 
export const deploymentTypeLabel: Record<ServiceDefinition['type'], StringKeys> = {
  Kubernetes: 'kubernetesText',
  NativeHelm: 'pipeline.nativeHelm',
  Ssh: 'SSH',
  WinRm: 'pipeline.serviceDeploymentTypes.winrm'
}