From 23aefd36bb524dffff99ba1d284093e8ae925e85 Mon Sep 17 00:00:00 2001 From: oleksandrh Date: Thu, 18 Jan 2024 14:43:47 +0200 Subject: [PATCH 1/2] Added logic to hide ticket link input based on BE version --- src/components/Insights/JiraTicket/index.tsx | 65 ++++++++++++-------- src/featureFlags.ts | 3 +- src/types.ts | 3 +- 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/components/Insights/JiraTicket/index.tsx b/src/components/Insights/JiraTicket/index.tsx index 448cfaf47..2b62898c7 100644 --- a/src/components/Insights/JiraTicket/index.tsx +++ b/src/components/Insights/JiraTicket/index.tsx @@ -1,12 +1,15 @@ import copy from "copy-to-clipboard"; -import { useEffect, useRef, useState } from "react"; +import { useContext, useEffect, useRef, useState } from "react"; import { useTheme } from "styled-components"; import { DefaultTheme } from "styled-components/dist/types"; import { dispatcher } from "../../../dispatcher"; +import { getFeatureFlagValue } from "../../../featureFlags"; import { isString } from "../../../typeGuards/isString"; +import { FeatureFlag } from "../../../types"; import { downloadFile } from "../../../utils/downloadFile"; import { isValidHttpUrl } from "../../../utils/isValidUrl"; import { sendTrackingEvent } from "../../../utils/sendTrackingEvent"; +import { ConfigContext } from "../../common/App/ConfigContext"; import { Button } from "../../common/Button"; import { CircleLoader } from "../../common/CircleLoader"; import { CircleLoaderColors } from "../../common/CircleLoader/types"; @@ -55,6 +58,12 @@ export const JiraTicket = (props: JiraTicketProps) => { const [errorMessage, setErrorMessage] = useState(); const descriptionContentRef = useRef(null); const theme = useTheme(); + const config = useContext(ConfigContext); + + const isLinkUnlinkInputVisible = getFeatureFlagValue( + config, + FeatureFlag.IS_LINK_UNLINK_INPUT_VISIBLE + ); const handleCloseButtonClick = () => { props.onClose(); @@ -242,32 +251,34 @@ export const JiraTicket = (props: JiraTicketProps) => { errorMessage={downloadErrorMessage} /> )} - - Unlink - - ) : ( - - ) - } - /> + {isLinkUnlinkInputVisible && ( + + Unlink + + ) : ( + + ) + } + /> + )} ); }; diff --git a/src/featureFlags.ts b/src/featureFlags.ts index 370777605..900caf2b3 100644 --- a/src/featureFlags.ts +++ b/src/featureFlags.ts @@ -6,7 +6,8 @@ const featureFlagMinBackendVersions: Record = { [FeatureFlag.IS_DASHBOARD_CLIENT_SPANS_OVERALL_IMPACT_ENABLED]: "v0.2.172-alpha.8", [FeatureFlag.IS_ASSETS_SERVICE_FILTER_VISIBLE]: "v0.2.174", - [FeatureFlag.IS_ASSETS_OVERALL_IMPACT_HIDDEN]: "v0.2.181-alpha.1" + [FeatureFlag.IS_ASSETS_OVERALL_IMPACT_HIDDEN]: "v0.2.181-alpha.1", + [FeatureFlag.IS_LINK_UNLINK_INPUT_VISIBLE]: "v0.2.200" }; export const getFeatureFlagValue = ( diff --git a/src/types.ts b/src/types.ts index 114230a21..c6604fecb 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,7 +3,8 @@ import { Duration } from "./globals"; export enum FeatureFlag { IS_DASHBOARD_CLIENT_SPANS_OVERALL_IMPACT_ENABLED, IS_ASSETS_SERVICE_FILTER_VISIBLE, - IS_ASSETS_OVERALL_IMPACT_HIDDEN + IS_ASSETS_OVERALL_IMPACT_HIDDEN, + IS_LINK_UNLINK_INPUT_VISIBLE } export enum InsightType { From a2b806724b2310e302e678a94dbbd203ae1b13a3 Mon Sep 17 00:00:00 2001 From: oleksandrh Date: Thu, 18 Jan 2024 14:50:08 +0200 Subject: [PATCH 2/2] changed flag name --- src/components/Insights/JiraTicket/index.tsx | 2 +- src/featureFlags.ts | 2 +- src/types.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Insights/JiraTicket/index.tsx b/src/components/Insights/JiraTicket/index.tsx index 2b62898c7..a9b244f6d 100644 --- a/src/components/Insights/JiraTicket/index.tsx +++ b/src/components/Insights/JiraTicket/index.tsx @@ -62,7 +62,7 @@ export const JiraTicket = (props: JiraTicketProps) => { const isLinkUnlinkInputVisible = getFeatureFlagValue( config, - FeatureFlag.IS_LINK_UNLINK_INPUT_VISIBLE + FeatureFlag.IS_TICKET_LINK_UNLINK_INPUT_ENABLED ); const handleCloseButtonClick = () => { diff --git a/src/featureFlags.ts b/src/featureFlags.ts index 900caf2b3..e1ed0fbfa 100644 --- a/src/featureFlags.ts +++ b/src/featureFlags.ts @@ -7,7 +7,7 @@ const featureFlagMinBackendVersions: Record = { "v0.2.172-alpha.8", [FeatureFlag.IS_ASSETS_SERVICE_FILTER_VISIBLE]: "v0.2.174", [FeatureFlag.IS_ASSETS_OVERALL_IMPACT_HIDDEN]: "v0.2.181-alpha.1", - [FeatureFlag.IS_LINK_UNLINK_INPUT_VISIBLE]: "v0.2.200" + [FeatureFlag.IS_TICKET_LINK_UNLINK_INPUT_ENABLED]: "v0.2.200" }; export const getFeatureFlagValue = ( diff --git a/src/types.ts b/src/types.ts index c6604fecb..5807c044e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,7 +4,7 @@ export enum FeatureFlag { IS_DASHBOARD_CLIENT_SPANS_OVERALL_IMPACT_ENABLED, IS_ASSETS_SERVICE_FILTER_VISIBLE, IS_ASSETS_OVERALL_IMPACT_HIDDEN, - IS_LINK_UNLINK_INPUT_VISIBLE + IS_TICKET_LINK_UNLINK_INPUT_ENABLED } export enum InsightType {