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 | 21x 21x 21x 4x 7x 6x 1x 1x 1x 4x 4x 21x 9x 9x 4x 4x 4x 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 { Connectors } from '@connectors/constants' import type { MonitoredServiceRef } from '@cv/pages/monitored-service/components/Configurations/components/Service/Service.types' import type { ChangeSourceDTO, HealthSource } from 'services/cv' import { GCOProduct } from '../connectors/GCOMetricsHealthSource/GCOMetricsHealthSource.utils' import type { RowData, SourceDataInterface, UpdatedHealthSource } from './HealthSourceDrawerContent.types' export function addProductFieldToStackdriverMetrics(healthSources?: UpdatedHealthSource[]): void { for (const healthSource of healthSources || []) { if (healthSource?.type !== 'Stackdriver') { continue } ;(healthSource.spec as any).feature = GCOProduct.CLOUD_METRICS ;(healthSource.spec as any).product = { label: GCOProduct.CLOUD_METRICS, value: GCOProduct.CLOUD_METRICS } return } } function getSourceType(sourceType?: HealthSource['type']): string | undefined { switch (sourceType) { case 'CustomHealthLog': case 'CustomHealthMetric': return Connectors.CUSTOM_HEALTH default: return sourceType } } export const createHealthSourceDrawerFormData = ({ isEdit, monitoredServiceRef, serviceRef, environmentRef, tableData, rowData, changeSources, existingMetricDetails }: { isEdit: boolean monitoredServiceRef: MonitoredServiceRef serviceRef: string environmentRef: string tableData: Array<RowData> rowData?: RowData | null changeSources: ChangeSourceDTO[] existingMetricDetails: HealthSource | null }): SourceDataInterface => { let sourceData: SourceDataInterface = { isEdit, healthSourceList: tableData, serviceRef, environmentRef, monitoredServiceRef, changeSources, existingMetricDetails } // when user is adding healthsource in create mode // we will have rowData but isEdit is false if (isEdit || rowData) { Iif (!rowData) return sourceData addProductFieldToStackdriverMetrics(sourceData.healthSourceList) sourceData = { ...sourceData, isEdit: !!rowData, healthSourceName: rowData?.name, healthSourceIdentifier: rowData?.identifier, sourceType: getSourceType(rowData?.type), connectorRef: rowData?.spec?.connectorRef, existingMetricDetails } } return sourceData } |