Skip to content

Commit

Permalink
Merge pull request #437 from bartoval/remove_exposure_for_remote_process
Browse files Browse the repository at this point in the history
refactor(General): ♻️ Remove exposed status for remote processes
  • Loading branch information
bartoval authored Aug 8, 2024
2 parents 4080300 + 206ada2 commit f1c556e
Show file tree
Hide file tree
Showing 26 changed files with 209 additions and 180 deletions.
4 changes: 4 additions & 0 deletions mocks/data/SERVICE_FLOW_PAIRS.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"identity": "fp-6z7k6:1827",
"startTime": 1674159205860550,
"endTime": 0,
"duration": 4000,
"protocol": "http2",
"sourceSiteId": "site-1",
"sourceSiteName": "site 1",
Expand Down Expand Up @@ -55,6 +56,7 @@
"identity": "fp-6z7k6:2284",
"startTime": 1674202674218241,
"endTime": 1674202674222329,
"duration": 0,
"protocol": "http2",
"sourceSiteId": "site-1",
"sourceSiteName": "site 1",
Expand Down Expand Up @@ -105,6 +107,7 @@
"identity": "fp-6z7k6:2304",
"startTime": 1674202675458245,
"endTime": 1674202675462225,
"duration": 0,
"protocol": "http2",
"sourceSiteId": "site-1",
"sourceSiteName": "site 1",
Expand Down Expand Up @@ -155,6 +158,7 @@
"identity": "fp-mm1-to-nb:8000",
"startTime": 1674202675458245,
"endTime": 1674202675462225,
"duration": 0,
"protocol": "tcp",
"sourceSiteId": "site-2",
"sourceSiteName": "site 2",
Expand Down
6 changes: 3 additions & 3 deletions mocks/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createServer, Response } from 'miragejs';

import { AvailableProtocols, FlowDirection } from '@API/REST.enum';
import { AvailableProtocols, Direction } from '@API/REST.enum';
import {
ServiceResponse,
ProcessPairsResponse,
Expand Down Expand Up @@ -123,7 +123,7 @@ mockSitePairsForPerf.forEach((_, index) => {
mode: 'interior',
name: '',
linkCost: 1,
direction: FlowDirection.Outgoing,
direction: Direction.Outgoing,
sourceSiteId: site1.identity,
destinationSiteId: site2.identity
},
Expand All @@ -136,7 +136,7 @@ mockSitePairsForPerf.forEach((_, index) => {
mode: 'interior',
name: '',
linkCost: 1,
direction: FlowDirection.Incoming,
direction: Direction.Incoming,
sourceSiteId: site2.identity,
destinationSiteId: site1.identity
}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"commit": "git-cz"
},
"dependencies": {
"@antv/g6": "^5.0.10",
"@antv/g6": "^5.0.13",
"@nivo/sankey": "^0.87.0",
"@patternfly/patternfly": "^5.3.1",
"@patternfly/react-charts": "^7.3.0",
Expand All @@ -46,14 +46,14 @@
"@tanstack/react-query": "^5.51.21",
"axios": "^1.7.3",
"date-fns": "^3.6.0",
"framer-motion": "^11.3.21",
"framer-motion": "^11.3.23",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-error-boundary": "^4.0.13",
"react-router-dom": "^6.26.0"
},
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/cli": "^19.4.0",
"@commitlint/config-conventional": "^19.2.2",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.4.8",
Expand All @@ -68,7 +68,7 @@
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"css-minimizer-webpack-plugin": "^7.0.0",
"cypress": "^13.13.1",
"cypress": "^13.13.2",
"cz-git": "^1.9.4",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
15 changes: 14 additions & 1 deletion src/API/REST.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export enum TcpStatus {
Terminated = 'terminated'
}

export enum FlowDirection {
export enum Direction {
Outgoing = 'outgoing',
Incoming = 'incoming'
}
Expand All @@ -26,3 +26,16 @@ export enum Quantiles {
NinetyFive = 0.95,
NinetyNine = 0.99
}

// Process and Component Exposure
export enum Binding {
Exposed = 'bound',
Unexposed = 'unbound'
}

// Process and Component Roles
export enum Role {
External = 'external',
Internal = 'internal',
Remote = 'remote'
}
10 changes: 5 additions & 5 deletions src/API/REST.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AxiosError, AxiosRequestConfig } from 'axios';

import { AvailableProtocols, FlowDirection, SortDirection } from './REST.enum';
import { AvailableProtocols, Binding, Direction, Role, SortDirection } from './REST.enum';

export type FetchWithOptions = AxiosRequestConfig;
export type FlowDirections = FlowDirection.Outgoing | FlowDirection.Incoming;
export type FlowDirections = Direction.Outgoing | Direction.Incoming;

export interface RemoteFilterOptions extends Record<string, string | string[] | number | SortDirection | undefined> {
filter?: string;
Expand Down Expand Up @@ -61,7 +61,7 @@ export interface SiteResponse extends BaseResponse {

export interface ComponentResponse extends BaseResponse {
name: string;
processGroupRole: 'external' | 'internal' | 'remote';
processGroupRole: Role;
processCount: number;
}

Expand All @@ -74,8 +74,8 @@ export interface ProcessResponse extends BaseResponse {
imageName?: string;
sourceHost: string;
hostName: string;
processBinding: 'bound' | 'unbound';
processRole: 'external' | 'internal' | 'remote';
processBinding: Binding;
processRole: Role;
addresses?: string[];
}

Expand Down
6 changes: 0 additions & 6 deletions src/core/components/DurationCell/DurationCell.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { ReactNode } from 'react';

import { Tooltip } from '@patternfly/react-core';
import { TableText } from '@patternfly/react-table';

import { formatLatency } from '@core/utils/formatLatency';

import { DurationCellProps } from './DurationCell';
export interface SKDurationCellProps<T> {
data: T;
value: ReactNode;
}

/**
* value is expected to be in microseconds
*/
const DurationCell = function <T>({ value }: DurationCellProps<T>) {
const SkDurationCell = function <T>({ value }: SKDurationCellProps<T>) {
if (!value) {
return null;
}
Expand All @@ -22,4 +27,4 @@ const DurationCell = function <T>({ value }: DurationCellProps<T>) {
);
};

export default DurationCell;
export default SkDurationCell;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { timeAgo } from '@core/utils/timeAgo';

import { EndTimeProps } from './EndTime.interfaces';

const EndTimeCell = function <T>({ value }: EndTimeProps<T>) {
const SkEndTimeCell = function <T>({ value }: EndTimeProps<T>) {
if (!value) {
return null;
}
Expand All @@ -24,4 +24,4 @@ const EndTimeCell = function <T>({ value }: EndTimeProps<T>) {
);
};

export default EndTimeCell;
export default SkEndTimeCell;
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { Label } from '@patternfly/react-core';

import { Binding } from '@API/REST.enum';
import { ProcessesLabels } from '@pages/Processes/Processes.enum';

const SkExposureCell = function ({ value }: { value: 'bound' | 'unbound' }) {
if (value === 'bound') {
const SkExposedCell = function ({ value }: { value: Binding }) {
if (!value) {
return '-';
}

if (value === Binding.Exposed) {
return <Label color="blue">{ProcessesLabels.IsExposed}</Label>;
}

return <Label color="gold">{ProcessesLabels.IsNotExposed}</Label>;
};

export default SkExposureCell;
export default SkExposedCell;
3 changes: 2 additions & 1 deletion src/pages/ProcessGroups/views/ProcessGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ const ProcessGroup = function () {
customCells={{
linkCell: CustomProcessCells.linkCell,
linkCellSite: CustomProcessCells.linkCellSite,
TimestampCell: CustomProcessCells.TimestampCell
TimestampCell: CustomProcessCells.TimestampCell,
ExposureCell: CustomProcessCells.ExposureCell
}}
/>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/ProcessGroups/views/ProcessGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useCallback, useState, startTransition } from 'react';
import { useSuspenseQuery } from '@tanstack/react-query';

import { RESTApi } from '@API/REST.api';
import { Role } from '@API/REST.enum';
import { RemoteFilterOptions } from '@API/REST.interfaces';
import { BIG_PAGINATION_SIZE, UPDATE_INTERVAL } from '@config/config';
import { getTestsIds } from '@config/testIds';
Expand All @@ -15,7 +16,7 @@ import { ComponentLabels, QueriesComponent } from '../ProcessGroups.enum';

const initComponentsQueryParams = {
limit: BIG_PAGINATION_SIZE,
processGroupRole: ['remote', 'external'],
processGroupRole: [Role.Remote, Role.External],
endTime: 0
};

Expand Down
8 changes: 4 additions & 4 deletions src/pages/Processes/Processes.constants.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ProcessPairsResponse, FlowPairsResponse, ProcessResponse } from '@API/REST.interfaces';
import EndTimeCell from '@core/components/EndTimeCell';
import HighlightValueCell from '@core/components/HighlightValueCell';
import { HighlightValueCellProps } from '@core/components/HighlightValueCell/HighightValueCell.interfaces';
import LinkCell from '@core/components/LinkCell';
import { LinkCellProps } from '@core/components/LinkCell/LinkCell.interfaces';
import SkExposureCell from '@core/components/SkExposureCell';
import SkEndTimeCell from '@core/components/SkEndTimeCell';
import SkExposedCell from '@core/components/SkExposedCell';
import { SKColumn } from '@core/components/SkTable/SkTable.interfaces';
import { formatByteRate, formatBytes } from '@core/utils/formatBytes';
import { formatLatency } from '@core/utils/formatLatency';
Expand Down Expand Up @@ -58,8 +58,8 @@ export const CustomProcessCells = {
HighlightValueCell({ ...props, format: formatBytes }),
ByteRateFormatCell: (props: HighlightValueCellProps<FlowPairsResponse>) =>
HighlightValueCell({ ...props, format: formatByteRate }),
TimestampCell: (props: LinkCellProps<ProcessResponse>) => EndTimeCell(props),
ExposureCell: SkExposureCell
TimestampCell: (props: LinkCellProps<ProcessResponse>) => SkEndTimeCell(props),
ExposureCell: SkExposedCell
};

export const processesTableColumns: SKColumn<ProcessResponse>[] = [
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Processes/components/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { Link } from 'react-router-dom';

import ResourceIcon from '@core/components/ResourceIcon';
import SkExposureCell from '@core/components/SkExposureCell';
import SkExposedCell from '@core/components/SkExposedCell';
import { timeAgo } from '@core/utils/timeAgo';
import { ComponentRoutesPaths } from '@pages/ProcessGroups/ProcessGroups.enum';
import { ServicesRoutesPaths } from '@pages/Services/Services.enum';
Expand Down Expand Up @@ -106,7 +106,7 @@ const Details: FC<DetailsProps> = function ({ process, title }) {
<DescriptionListGroup>
<DescriptionListTerm>{ProcessesLabels.ExposedTitle}</DescriptionListTerm>
<DescriptionListDescription>
<SkExposureCell value={processBinding} />
<SkExposedCell value={processBinding} />
</DescriptionListDescription>
</DescriptionListGroup>
</GridItem>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Processes/views/Processes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { startTransition, useCallback, useState } from 'react';
import { useSuspenseQuery } from '@tanstack/react-query';

import { RESTApi } from '@API/REST.api';
import { Role } from '@API/REST.enum';
import { RemoteFilterOptions } from '@API/REST.interfaces';
import { BIG_PAGINATION_SIZE, UPDATE_INTERVAL } from '@config/config';
import { getTestsIds } from '@config/testIds';
Expand All @@ -17,7 +18,7 @@ import { ProcessesLabels, QueriesProcesses } from '../Processes.enum';
//TODO: currently we can't query filter for a multivalue and we need to call separate queries, merge and sort them locally
const initProcessesQueryParams = {
limit: BIG_PAGINATION_SIZE,
processRole: ['remote', 'external'],
processRole: [Role.Remote, Role.External],
endTime: 0
};

Expand Down
6 changes: 3 additions & 3 deletions src/pages/Sites/components/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { useSuspenseQueries } from '@tanstack/react-query';
import { Link } from 'react-router-dom';

import { FlowDirection } from '@API/REST.enum';
import { Direction, Role } from '@API/REST.enum';
import EmptyData from '@core/components/EmptyData';
import ResourceIcon from '@core/components/ResourceIcon';
import { ProcessesRoutesPaths } from '@pages/Processes/Processes.enum';
Expand All @@ -29,7 +29,7 @@ import { DetailsProps } from '../Sites.interfaces';
import { queryDetails } from '../Sites.queries';

const processQueryParams = { endTime: 0 };
const linkQueryParams = { direction: FlowDirection.Outgoing };
const linkQueryParams = { direction: Direction.Outgoing };

const Details: FC<DetailsProps> = function ({ site }) {
const { identity: siteId, nameSpace, siteVersion, platform } = site;
Expand All @@ -45,7 +45,7 @@ const Details: FC<DetailsProps> = function ({ site }) {

const { linkSiteIds } = SitesController.bindLinksWithSiteIds([site], links)[0];
const linkedSites = sites.filter(({ identity }) => linkSiteIds.map((id) => id.targetId).includes(identity));
const processResults = processesData.results.filter(({ processRole }) => processRole !== 'internal');
const processResults = processesData.results.filter(({ processRole }) => processRole !== Role.Internal);

return (
<Grid hasGutter sm={12} xl={6} xl2={4}>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Sites/views/Sites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { RESTApi } from '@API/REST.api';
import { SiteResponse } from '@API/REST.interfaces';
import { BIG_PAGINATION_SIZE, UPDATE_INTERVAL } from '@config/config';
import { getTestsIds } from '@config/testIds';
import EndTimeCell from '@core/components/EndTimeCell';
import LinkCell from '@core/components/LinkCell';
import { LinkCellProps } from '@core/components/LinkCell/LinkCell.interfaces';
import SkEndTimeCell from '@core/components/SkEndTimeCell';
import SkTable from '@core/components/SkTable';
import MainContainer from '@layout/MainContainer';
import { TopologyRoutesPaths, TopologyViews } from '@pages/Topology/Topology.enum';
Expand All @@ -33,7 +33,7 @@ const Sites = function () {
rows={sites}
paginationPageSize={BIG_PAGINATION_SIZE}
customCells={{
TimestampCell: (props: LinkCellProps<SiteResponse>) => EndTimeCell(props),
TimestampCell: SkEndTimeCell,
LinkCell: (props: LinkCellProps<SiteResponse>) =>
LinkCell({
...props,
Expand Down
Loading

0 comments on commit f1c556e

Please sign in to comment.