Skip to content

Commit

Permalink
Refactor GanttChart components and update title and description types…
Browse files Browse the repository at this point in the history
… to support React elements
  • Loading branch information
simlarsen committed Apr 16, 2024
1 parent c582330 commit 2eaeec3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
10 changes: 5 additions & 5 deletions CommonUI/src/Components/GanttChart/Row/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import Bar, { GanttChartBar } from '../Bar/Index';
export interface GanttChartRow {
rowInfo: {
id: string;
title: string;
description: string;
title: string | ReactElement;
description: string | ReactElement;
};
childRows: GanttChartRow[];
bars: Array<GanttChartBar>; // usually will have only one bar, this is for future proofing
Expand All @@ -25,11 +25,11 @@ export interface ComponentProps {
const Row: FunctionComponent<ComponentProps> = (
props: ComponentProps
): ReactElement => {


type GetRowFunction = (data: { row: GanttChartRow }) => ReactElement;

const getRow: GetRowFunction = (data: { row: GanttChartRow }): ReactElement => {
const getRow: GetRowFunction = (data: {
row: GanttChartRow;
}): ReactElement => {
const { row } = data;

return (
Expand Down
4 changes: 2 additions & 2 deletions CommonUI/src/Components/GanttChart/Row/RowLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { FunctionComponent, ReactElement } from 'react';

export interface ComponentProps {
title: string;
description: string;
title: string | ReactElement;
description: string | ReactElement;
}

const RowLabel: FunctionComponent<ComponentProps> = (
Expand Down
5 changes: 3 additions & 2 deletions CommonUI/src/Components/GanttChart/Rows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ export interface ComponentProps {
const Rows: FunctionComponent<ComponentProps> = (
props: ComponentProps
): ReactElement => {

type GetRowFunction = (data: { row: GanttChartRow }) => ReactElement;

const getRow: GetRowFunction = (data: { row: GanttChartRow }): ReactElement => {
const getRow: GetRowFunction = (data: {
row: GanttChartRow;
}): ReactElement => {
const { row } = data;

return (
Expand Down
18 changes: 16 additions & 2 deletions Dashboard/src/Pages/Telemetry/Services/View/Traces/View/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { GanttChartBar } from 'CommonUI/src/Components/GanttChart/Bar/Index';
import { GanttChartRow } from 'CommonUI/src/Components/GanttChart/Row/Index';
import { PromiseVoidFunction } from 'Common/Types/FunctionTypes';
import { getRefreshButton } from 'CommonUI/src/Components/Card/CardButtons/Refresh';
import TelemetryServiceElement from '../../../../../../Components/TelemetryService/TelemetryServiceElement';

type BarTooltipFunctionProps = {
span: Span;
Expand Down Expand Up @@ -291,10 +292,23 @@ const TraceView: FunctionComponent<PageComponentProps> = (
return [];
}

const telemetryService: TelemetryService | undefined =
telemetryServices.find((service: TelemetryService) => {
return (
service._id?.toString() === rootSpan.serviceId?.toString()
);
});

const rootRow: GanttChartRow = {
rowInfo: {
title: rootSpan.name!,
description: '',
title: <div>{rootSpan.name!}</div>,
description: telemetryService ? (
<TelemetryServiceElement
telemetryService={telemetryService}
/>
) : (
<></>
),
id: ObjectID.generate().toString(),
},
bars: [
Expand Down

0 comments on commit 2eaeec3

Please sign in to comment.