diff --git a/__tests__/pages/Processes/Details.spec.tsx b/__tests__/pages/Processes/Details.spec.tsx index 5bbf2df2..1121381c 100644 --- a/__tests__/pages/Processes/Details.spec.tsx +++ b/__tests__/pages/Processes/Details.spec.tsx @@ -38,7 +38,7 @@ describe('Process component', () => { it('should render the title, description data and processes associated the data loading is complete', async () => { expect(screen.getByText(processResult.parentName)).toHaveTextContent('site 1'); expect(screen.getByText(processResult.groupName)).toHaveTextContent('payment'); - expect(screen.getByText(processResult.hostName)).toHaveTextContent('10.242.0.5'); + expect(screen.getByText(processResult.hostName as string)).toHaveTextContent('10.242.0.5'); expect(screen.getByText(processResult.sourceHost)).toHaveTextContent('172.17.63.163'); }); }); diff --git a/src/config/config.ts b/src/config/config.ts index f754ac0a..b58d08cc 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -26,6 +26,7 @@ export const waitForElementToBeRemovedTimeout = 10000; export const DEFAULT_FONT_VAR = 'var(--pf-v5-global--FontFamily--text)'; +export const EMPTY_VALUE_PLACEHOLDER = '-'; export const IDS_GROUP_SEPARATOR = '~'; export const IDS_MULTIPLE_SELECTION_SEPARATOR = ','; export const PAIR_SEPARATOR = 'processpair-'; diff --git a/src/core/components/SkExposedCell/index.tsx b/src/core/components/SkExposedCell/index.tsx index 616e7fcd..048715b0 100644 --- a/src/core/components/SkExposedCell/index.tsx +++ b/src/core/components/SkExposedCell/index.tsx @@ -4,10 +4,6 @@ import { Binding } from '@API/REST.enum'; import { ProcessesLabels } from '@pages/Processes/Processes.enum'; const SkExposedCell = function ({ value }: { value: Binding }) { - if (!value) { - return '-'; - } - if (value === Binding.Exposed) { return ; } diff --git a/src/core/components/SkFlowPairsTable/FlowPair.tsx b/src/core/components/SkFlowPairsTable/FlowPair.tsx index 9670f082..04ee58b1 100644 --- a/src/core/components/SkFlowPairsTable/FlowPair.tsx +++ b/src/core/components/SkFlowPairsTable/FlowPair.tsx @@ -24,7 +24,7 @@ import { getTestsIds } from '@config/testIds'; import ResourceIcon from '@core/components/ResourceIcon'; import { formatBytes } from '@core/utils/formatBytes'; import { formatLatency } from '@core/utils/formatLatency'; -import { formatTraceBySites } from '@core/utils/formatTrace'; +import { renderTraceBySites } from '@core/utils/renderTraceBySites'; import { ProcessesRoutesPaths } from '@pages/Processes/Processes.enum'; import { TcpBiflow, FlowPairsResponse, HttpBiflow } from '@sk-types/REST.interfaces'; @@ -54,7 +54,7 @@ const FlowPair: FC = function ({ flowPair }) { {FlowPairLabels.Trace} - {formatTraceBySites(traceSites) || '-'} + {renderTraceBySites(traceSites)} {!!duration && ( <> {FlowPairLabels.Duration} @@ -81,7 +81,7 @@ const FlowPair: FC = function ({ flowPair }) { {protocol} {FlowPairLabels.Trace} - {formatTraceBySites(traceSites)} + {renderTraceBySites(traceSites)} {!!duration && ( <> {FlowPairLabels.Duration} diff --git a/src/core/utils/formatTrace.ts b/src/core/utils/formatTrace.ts deleted file mode 100644 index 735af794..00000000 --- a/src/core/utils/formatTrace.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function formatTraceBySites(traces: string[]) { - return traces.join(' -> '); -} diff --git a/src/core/utils/renderTraceBySites.ts b/src/core/utils/renderTraceBySites.ts new file mode 100644 index 00000000..90c5601a --- /dev/null +++ b/src/core/utils/renderTraceBySites.ts @@ -0,0 +1,9 @@ +import { EMPTY_VALUE_PLACEHOLDER } from '@config/config'; + +export function renderTraceBySites(traces: string[]) { + if (!traces.length) { + return EMPTY_VALUE_PLACEHOLDER; + } + + return traces.join(' -> '); +} diff --git a/src/pages/Processes/components/Details.tsx b/src/pages/Processes/components/Details.tsx index bfe073a4..cc006de0 100644 --- a/src/pages/Processes/components/Details.tsx +++ b/src/pages/Processes/components/Details.tsx @@ -44,6 +44,7 @@ const Details: FC = function ({ process }) { addresses } = process; + return ( @@ -78,7 +79,7 @@ const Details: FC = function ({ process }) { {ProcessesLabels.Host} - {hostName} + {hostName || '-'} @@ -93,8 +94,8 @@ const Details: FC = function ({ process }) { {ProcessesLabels.Image} - - + + diff --git a/src/pages/Services/services/index.ts b/src/pages/Services/services/index.ts index 63bd7b55..38ede392 100644 --- a/src/pages/Services/services/index.ts +++ b/src/pages/Services/services/index.ts @@ -1,4 +1,5 @@ import { VarColors } from '@config/colors'; +import { EMPTY_VALUE_PLACEHOLDER } from '@config/config'; import { PrometheusLabelsV2 } from '@config/prometheus'; import { DEFAULT_SANKEY_CHART_FLOW_VALUE } from '@core/components/SKSanckeyChart/SkSankey.constants'; import { PrometheusMetric } from '@sk-types/Prometheus.interfaces'; @@ -28,7 +29,9 @@ export const ServicesController = { return services.map((service) => ({ ...service, currentFlows: - tcpActiveFlowsMap && tcpActiveFlowsMap[service.name] ? Math.round(tcpActiveFlowsMap[service.name]) : '-' + tcpActiveFlowsMap && tcpActiveFlowsMap[service.name] + ? Math.round(tcpActiveFlowsMap[service.name]) + : EMPTY_VALUE_PLACEHOLDER })); }, diff --git a/src/pages/Sites/components/Details.tsx b/src/pages/Sites/components/Details.tsx index 0eb20a93..50f27f9a 100644 --- a/src/pages/Sites/components/Details.tsx +++ b/src/pages/Sites/components/Details.tsx @@ -17,6 +17,7 @@ import { } from '@patternfly/react-core'; import { Link } from 'react-router-dom'; +import { EMPTY_VALUE_PLACEHOLDER } from '@config/config'; import ResourceIcon from '@core/components/ResourceIcon'; import { SiteResponse } from '@sk-types/REST.interfaces'; @@ -67,7 +68,7 @@ const Details: FC = function ({ site: { identity: id, nameSpace, s )) - : '-'} + : EMPTY_VALUE_PLACEHOLDER} diff --git a/src/types/REST.interfaces.ts b/src/types/REST.interfaces.ts index 590dee6c..fdc35330 100644 --- a/src/types/REST.interfaces.ts +++ b/src/types/REST.interfaces.ts @@ -68,12 +68,12 @@ export interface ProcessResponse extends BaseResponse { parentName: string; groupIdentity: string; groupName: string; - imageName?: string; sourceHost: string; - hostName: string; processBinding: Binding; processRole: Role; - addresses?: string[]; + hostName: string | null; + imageName: string | null; + addresses: string[] | null; } export interface SitePairsResponse extends BaseResponse {