From c9b8a30e31de6c55e5545851e9d665a121efaed6 Mon Sep 17 00:00:00 2001 From: olehp Date: Mon, 11 Mar 2024 17:31:35 +0200 Subject: [PATCH 1/2] Hide Dismissal view option --- src/components/Insights/InsightsCatalog/index.tsx | 6 +++--- src/components/Insights/InsightsCatalog/types.ts | 1 + .../Insights/common/InsightCard/index.tsx | 14 +++++++++++--- src/components/Insights/index.tsx | 1 + src/components/Insights/typeGuards.ts | 5 +++++ src/components/Insights/types.ts | 1 + 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/components/Insights/InsightsCatalog/index.tsx b/src/components/Insights/InsightsCatalog/index.tsx index c54fcd780..0b73e4982 100644 --- a/src/components/Insights/InsightsCatalog/index.tsx +++ b/src/components/Insights/InsightsCatalog/index.tsx @@ -52,9 +52,9 @@ export const InsightsCatalog = (props: InsightsCatalogProps) => { const previousMode = usePrevious(mode); const theme = useTheme(); - const isViewModeButtonVisible = getFeatureFlagValue( - config, - FeatureFlag.IS_INSIGHT_DISMISSAL_ENABLED + const isViewModeButtonVisible = Boolean( + getFeatureFlagValue(config, FeatureFlag.IS_INSIGHT_DISMISSAL_ENABLED) && + props.dismissedCount ); const refreshData = useCallback( diff --git a/src/components/Insights/InsightsCatalog/types.ts b/src/components/Insights/InsightsCatalog/types.ts index 383f2f62d..87ba0cbfe 100644 --- a/src/components/Insights/InsightsCatalog/types.ts +++ b/src/components/Insights/InsightsCatalog/types.ts @@ -3,6 +3,7 @@ import { GenericCodeObjectInsight, InsightsQuery } from "../types"; export interface InsightsCatalogProps { insights: GenericCodeObjectInsight[]; totalCount: number; + dismissedCount?: number; onJiraTicketCreate: ( insight: GenericCodeObjectInsight, spanCodeObjectId?: string diff --git a/src/components/Insights/common/InsightCard/index.tsx b/src/components/Insights/common/InsightCard/index.tsx index f0bb65233..4aa66f8c7 100644 --- a/src/components/Insights/common/InsightCard/index.tsx +++ b/src/components/Insights/common/InsightCard/index.tsx @@ -12,7 +12,10 @@ import { BaseButtonProps } from "../../../common/v3/Button/types"; import { JiraButton } from "../../../common/v3/JiraButton"; import { Link } from "../../../common/v3/Link"; import { Tooltip } from "../../../common/v3/Tooltip"; -import { isSpanInsight } from "../../typeGuards"; +import { + isInsightHeaderNavigationEnabled, + isSpanInsight +} from "../../typeGuards"; import { InsightHeader } from "./InsightHeader"; import * as s from "./styles"; import { InsightCardProps } from "./types"; @@ -66,7 +69,10 @@ export const InsightCard = (props: InsightCardProps) => { }; const handleSpanLinkClick = () => { - if (isSpanInsight(props.insight) && props.insight.spanInfo) { + if ( + isInsightHeaderNavigationEnabled(props.insight) && + props.insight.spanInfo + ) { props.onGoToSpan(props.insight.spanInfo.spanCodeObjectId); } }; @@ -264,7 +270,9 @@ export const InsightCard = (props: InsightCardProps) => { header={ { }} onRefresh={refresh} defaultQuery={DEFAULT_QUERY} + dismissedCount={data.dismissedCount} /> ); }; diff --git a/src/components/Insights/typeGuards.ts b/src/components/Insights/typeGuards.ts index 7b9e3eb1c..e79b99b5c 100644 --- a/src/components/Insights/typeGuards.ts +++ b/src/components/Insights/typeGuards.ts @@ -176,3 +176,8 @@ export const isSpanQueryOptimizationInsight = ( insight: CodeObjectInsight ): insight is QueryOptimizationInsight => insight.type === InsightType.SpanQueryOptimization; + +export const isInsightHeaderNavigationEnabled = ( + insight: CodeObjectInsight +): insight is SpanInsight => + isSpanInsight(insight) || isEndpointHighNumberOfQueriesInsight(insight); diff --git a/src/components/Insights/types.ts b/src/components/Insights/types.ts index f93304d4a..244ef84a2 100644 --- a/src/components/Insights/types.ts +++ b/src/components/Insights/types.ts @@ -72,6 +72,7 @@ export interface InsightsData { totalCount: number; insightsStatus: InsightsStatus; // ?? default viewMode: ViewMode; // Insights + dismissedCount?: number; // methods: Method[]; // empty // assetId?: string; // remove From e8eadee03166216f78f062720b6f3f6b7868c30a Mon Sep 17 00:00:00 2001 From: olehp Date: Mon, 11 Mar 2024 18:20:02 +0200 Subject: [PATCH 2/2] refactored check --- src/components/Insights/common/InsightCard/index.tsx | 9 +++------ src/components/Insights/typeGuards.ts | 5 ----- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/components/Insights/common/InsightCard/index.tsx b/src/components/Insights/common/InsightCard/index.tsx index 4aa66f8c7..b3aef582d 100644 --- a/src/components/Insights/common/InsightCard/index.tsx +++ b/src/components/Insights/common/InsightCard/index.tsx @@ -12,10 +12,7 @@ import { BaseButtonProps } from "../../../common/v3/Button/types"; import { JiraButton } from "../../../common/v3/JiraButton"; import { Link } from "../../../common/v3/Link"; import { Tooltip } from "../../../common/v3/Tooltip"; -import { - isInsightHeaderNavigationEnabled, - isSpanInsight -} from "../../typeGuards"; +import { isEndpointInsight, isSpanInsight } from "../../typeGuards"; import { InsightHeader } from "./InsightHeader"; import * as s from "./styles"; import { InsightCardProps } from "./types"; @@ -70,7 +67,7 @@ export const InsightCard = (props: InsightCardProps) => { const handleSpanLinkClick = () => { if ( - isInsightHeaderNavigationEnabled(props.insight) && + (isSpanInsight(props.insight) || isEndpointInsight(props.insight)) && props.insight.spanInfo ) { props.onGoToSpan(props.insight.spanInfo.spanCodeObjectId); @@ -270,7 +267,7 @@ export const InsightCard = (props: InsightCardProps) => { header={ insight.type === InsightType.SpanQueryOptimization; - -export const isInsightHeaderNavigationEnabled = ( - insight: CodeObjectInsight -): insight is SpanInsight => - isSpanInsight(insight) || isEndpointHighNumberOfQueriesInsight(insight);