From a5d45f414ca68e011e87320f9e13980b6614eb4b Mon Sep 17 00:00:00 2001 From: Kyrylo Shmidt Date: Thu, 29 Feb 2024 17:18:26 +0100 Subject: [PATCH] Add request breakdown insight --- .../ExcessiveAPICallsInsight/index.tsx | 32 +-- .../InsightHeader/AsyncTag/styles.ts | 4 +- .../PercentileViewModeToggle.stories.tsx | 22 ++ .../PercentileViewModeToggle/index.tsx | 17 ++ .../PercentileViewModeToggle/types.ts | 4 + .../Insights/common/InsightCard/index.tsx | 58 +++-- .../ReferenceLineLabel/index.tsx | 15 +- .../DurationInsight/XAxisTick/index.tsx | 16 +- .../insights/DurationInsight/constants.ts | 2 +- .../common/insights/DurationInsight/index.tsx | 16 +- .../RequestBreakdownInsight.stories.tsx | 217 ++++++++++++++++ .../RequestBreakdownInsight/index.tsx | 240 ++++++++++++++++++ .../RequestBreakdownInsight/styles.ts | 134 ++++++++++ .../insights/RequestBreakdownInsight/types.ts | 16 ++ src/components/common/App/themes/darkTheme.ts | 2 + .../common/App/themes/lightTheme.ts | 2 + src/components/common/v3/Button/styles.ts | 11 +- src/components/common/v3/Toggle/index.tsx | 22 ++ src/components/common/v3/Toggle/styles.ts | 29 +++ src/components/common/v3/Toggle/types.ts | 16 ++ src/styled.d.ts | 14 +- 21 files changed, 811 insertions(+), 78 deletions(-) create mode 100644 src/components/Insights/common/InsightCard/PercentileViewModeToggle/PercentileViewModeToggle.stories.tsx create mode 100644 src/components/Insights/common/InsightCard/PercentileViewModeToggle/index.tsx create mode 100644 src/components/Insights/common/InsightCard/PercentileViewModeToggle/types.ts create mode 100644 src/components/Insights/common/insights/RequestBreakdownInsight/RequestBreakdownInsight.stories.tsx create mode 100644 src/components/Insights/common/insights/RequestBreakdownInsight/index.tsx create mode 100644 src/components/Insights/common/insights/RequestBreakdownInsight/styles.ts create mode 100644 src/components/Insights/common/insights/RequestBreakdownInsight/types.ts create mode 100644 src/components/common/v3/Toggle/index.tsx create mode 100644 src/components/common/v3/Toggle/styles.ts create mode 100644 src/components/common/v3/Toggle/types.ts diff --git a/src/components/Insights/ExcessiveAPICallsInsight/index.tsx b/src/components/Insights/ExcessiveAPICallsInsight/index.tsx index e46a9d90e..a4addf574 100644 --- a/src/components/Insights/ExcessiveAPICallsInsight/index.tsx +++ b/src/components/Insights/ExcessiveAPICallsInsight/index.tsx @@ -62,21 +62,23 @@ export const ExcessiveAPICallsInsight = ( {config.isJaegerEnabled && traceId && ( - - handleTraceButtonClick( - { - name: spanName, - id: traceId - }, - props.insight.type, - spanCodeObjectId - ) - } - > - Trace - + + + handleTraceButtonClick( + { + name: spanName, + id: traceId + }, + props.insight.type, + spanCodeObjectId + ) + } + > + Trace + + )} ); diff --git a/src/components/Insights/common/InsightCard/InsightHeader/AsyncTag/styles.ts b/src/components/Insights/common/InsightCard/InsightHeader/AsyncTag/styles.ts index c557d044a..d5c972b9d 100644 --- a/src/components/Insights/common/InsightCard/InsightHeader/AsyncTag/styles.ts +++ b/src/components/Insights/common/InsightCard/InsightHeader/AsyncTag/styles.ts @@ -1,8 +1,10 @@ import styled from "styled-components"; +import { footnoteRegularTypography } from "../../../../../common/App/typographies"; import { Tag as TagCommon } from "../../../../../common/v3/Tag"; export const AsyncTag = styled(TagCommon)` + ${footnoteRegularTypography} + color: ${({ theme }) => theme.colors.v3.text.primary}; background: ${({ theme }) => theme.colors.v3.surface.brandDark}; - font-size: 12px; `; diff --git a/src/components/Insights/common/InsightCard/PercentileViewModeToggle/PercentileViewModeToggle.stories.tsx b/src/components/Insights/common/InsightCard/PercentileViewModeToggle/PercentileViewModeToggle.stories.tsx new file mode 100644 index 000000000..5ffc91ca4 --- /dev/null +++ b/src/components/Insights/common/InsightCard/PercentileViewModeToggle/PercentileViewModeToggle.stories.tsx @@ -0,0 +1,22 @@ +import { Meta, StoryObj } from "@storybook/react"; +import { PercentileViewModeToggle } from "."; + +// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction +const meta: Meta = { + title: "Insights/common/InsightCard/PercentileViewModeToggle", + component: PercentileViewModeToggle, + parameters: { + // More on how to position stories at: https://storybook.js.org/docs/react/configure/story-layout + layout: "fullscreen" + } +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = { + args: { + viewMode: 0.5 + } +}; diff --git a/src/components/Insights/common/InsightCard/PercentileViewModeToggle/index.tsx b/src/components/Insights/common/InsightCard/PercentileViewModeToggle/index.tsx new file mode 100644 index 000000000..20a22c17b --- /dev/null +++ b/src/components/Insights/common/InsightCard/PercentileViewModeToggle/index.tsx @@ -0,0 +1,17 @@ +import { PERCENTILES } from "../../../../../constants"; +import { Toggle } from "../../../../common/v3/Toggle"; +import { PercentileViewModeToggleProps } from "./types"; + +export const PercentileViewModeToggle = ({ + viewMode, + onChange +}: PercentileViewModeToggleProps) => ( + + options={PERCENTILES.map((percentile) => ({ + value: percentile.percentile, + label: percentile.label + }))} + value={viewMode} + onValueChange={onChange} + /> +); diff --git a/src/components/Insights/common/InsightCard/PercentileViewModeToggle/types.ts b/src/components/Insights/common/InsightCard/PercentileViewModeToggle/types.ts new file mode 100644 index 000000000..5ae5f64d3 --- /dev/null +++ b/src/components/Insights/common/InsightCard/PercentileViewModeToggle/types.ts @@ -0,0 +1,4 @@ +export interface PercentileViewModeToggleProps { + viewMode: number; + onChange: (viewMode: number) => void; +} diff --git a/src/components/Insights/common/InsightCard/index.tsx b/src/components/Insights/common/InsightCard/index.tsx index 1a8033724..28592a6a6 100644 --- a/src/components/Insights/common/InsightCard/index.tsx +++ b/src/components/Insights/common/InsightCard/index.tsx @@ -122,40 +122,50 @@ export const InsightCard = (props: InsightCardProps) => { {/*