From edb0599444404d248c8ebff29b67df68b933da07 Mon Sep 17 00:00:00 2001 From: olehp Date: Mon, 4 Mar 2024 13:31:46 +0200 Subject: [PATCH 1/7] Fix empty state --- src/components/Assets/index.tsx | 5 +- src/components/Insights/index.tsx | 50 ++++++++++++------- .../Navigation/EnvironmentBar/types.ts | 2 +- src/components/Navigation/types.ts | 2 +- src/components/common/App/index.tsx | 7 +++ src/components/common/App/types.ts | 2 +- 6 files changed, 47 insertions(+), 21 deletions(-) diff --git a/src/components/Assets/index.tsx b/src/components/Assets/index.tsx index 8d22a2973..630d8b1a8 100644 --- a/src/components/Assets/index.tsx +++ b/src/components/Assets/index.tsx @@ -122,7 +122,10 @@ export const Assets = () => { ); } - if (!selectedFilters && !selectedServices) { + if ( + !config.environments?.length || + (!selectedFilters && !selectedServices) + ) { return ; } diff --git a/src/components/Insights/index.tsx b/src/components/Insights/index.tsx index 9c139af13..733f7cd92 100644 --- a/src/components/Insights/index.tsx +++ b/src/components/Insights/index.tsx @@ -155,6 +155,34 @@ const renderInsightTicket = ( return null; }; +const NoDataYet = () => { + const handleTroubleshootingLinkClick = () => { + sendTrackingEvent(globalTrackingEvents.TROUBLESHOOTING_LINK_CLICKED, { + origin: "insights" + }); + + sendMessage(globalActions.OPEN_TROUBLESHOOTING_GUIDE); + }; + + return ( + + + Trigger actions that call this application to learn more about its + runtime behavior + + + Not seeing your application data? + + + } + /> + ); +}; + const sendMessage = (action: string, data?: object) => { return window.sendMessageToDigma({ action, @@ -282,6 +310,10 @@ export const Insights = (props: InsightsProps) => { return } />; } + if (!config.environments?.length) { + return ; + } + switch (data?.insightsStatus) { case InsightsStatus.STARTUP: return ( @@ -321,23 +353,7 @@ export const Insights = (props: InsightsProps) => { /> ); case InsightsStatus.NO_SPANS_DATA: - return ( - - - Trigger actions that call this application to learn more about - its runtime behavior - - - Not seeing your application data? - - - } - /> - ); + return ; case InsightsStatus.NO_OBSERVABILITY: return ( void; isDisabled?: boolean; diff --git a/src/components/Navigation/types.ts b/src/components/Navigation/types.ts index 85f909bcf..48e981eea 100644 --- a/src/components/Navigation/types.ts +++ b/src/components/Navigation/types.ts @@ -16,7 +16,7 @@ export interface OpenDocumentationPayload { } export interface OpenDashboardPayload { - environment?: Environment; + environment?: Environment | null; } export interface ChangeScopePayload { diff --git a/src/components/common/App/index.tsx b/src/components/common/App/index.tsx index c3adc0d2a..982236640 100644 --- a/src/components/common/App/index.tsx +++ b/src/components/common/App/index.tsx @@ -195,6 +195,13 @@ export const App = (props: AppProps) => { ...config, environments: data.environments as Environment[] })); + + if (!data.environments.length) { + setConfig((config) => ({ + ...config, + environment: null + })); + } } }; diff --git a/src/components/common/App/types.ts b/src/components/common/App/types.ts index 8f2e3f9c4..39264dbcd 100644 --- a/src/components/common/App/types.ts +++ b/src/components/common/App/types.ts @@ -82,7 +82,7 @@ export interface ConfigContextData { isDockerComposeInstalled: boolean; userEmail: string; userRegistrationEmail: string; - environment: Environment | undefined; + environment?: Environment | null; backendInfo: BackendInfo | undefined; environments: Environment[] | undefined; scope: Scope | undefined; From 34628cb04556115cea0f411ad8fb13054a422562 Mon Sep 17 00:00:00 2001 From: olehp Date: Mon, 4 Mar 2024 15:19:00 +0200 Subject: [PATCH 2/7] fix navigation --- .../Navigation/ScopeNavigation/index.tsx | 44 ++++++++++++------- src/components/Navigation/index.tsx | 7 ++- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/components/Navigation/ScopeNavigation/index.tsx b/src/components/Navigation/ScopeNavigation/index.tsx index 689fd719f..b38ab5998 100644 --- a/src/components/Navigation/ScopeNavigation/index.tsx +++ b/src/components/Navigation/ScopeNavigation/index.tsx @@ -2,34 +2,46 @@ import { useContext, useEffect, useState } from "react"; import { actions } from "../../../actions"; import { dispatcher } from "../../../dispatcher"; import { usePrevious } from "../../../hooks/usePrevious"; -import { HistoryManager, HistoryStep } from "../../../utils/HistoryManager"; +import { HistoryManager } from "../../../utils/HistoryManager"; import { ConfigContext } from "../../common/App/ConfigContext"; import { Scope } from "../../common/App/types"; -import { ChangeEnvironmentPayload, ChangeViewPayload } from "../types"; +import { + ChangeEnvironmentPayload, + ChangeScopePayload, + ChangeViewPayload +} from "../types"; import { actions as globalActions } from "./../actions"; import { HistoryNavigationPanel } from "./HistoryNavigationPanel"; import { ScopeNavigationProps } from "./types"; -const sendMessage = (historyStep: HistoryStep) => { - if (historyStep.scope) { - window.sendMessageToDigma({ - action: globalActions.CHANGE_SCOPE, - payload: { - ...historyStep.scope - } - }); - } +const sendMessage = (scope: Scope | null) => { + window.sendMessageToDigma({ + action: globalActions.CHANGE_SCOPE, + payload: { + span: scope?.span || null + } + }); }; export const ScopeNavigation = (props: ScopeNavigationProps) => { const [historyManager, setHistoryManager] = useState( new HistoryManager() ); - const { environment } = useContext(ConfigContext); + const { environment, environments } = useContext(ConfigContext); const previousTabId = usePrevious(props.currentTabId); const previousEnvironment = usePrevious(environment); const previousSate = usePrevious(historyManager.getCurrent()); + useEffect(() => { + if ( + !environment || + !environments?.find((x) => x.originalName == environment?.originalName) + ) { + sendMessage(null); + setHistoryManager(new HistoryManager()); + } + }, [environment, environments]); + useEffect(() => { const currentStep = historyManager.getCurrent(); if ( @@ -100,15 +112,15 @@ export const ScopeNavigation = (props: ScopeNavigationProps) => { const handleBackClick = () => { const currentStep = historyManager.back(); - if (currentStep) { - sendMessage(currentStep); + if (currentStep && currentStep.scope) { + sendMessage(currentStep.scope); } }; const handleNexClick = () => { const currentStep = historyManager.forward(); - if (currentStep) { - sendMessage(currentStep); + if (currentStep && currentStep.scope) { + sendMessage(currentStep.scope); } }; diff --git a/src/components/Navigation/index.tsx b/src/components/Navigation/index.tsx index 216835548..29707e798 100644 --- a/src/components/Navigation/index.tsx +++ b/src/components/Navigation/index.tsx @@ -169,9 +169,12 @@ export const Navigation = () => { if ( config.environments && config.environments.length > 0 && - !config.environment + (!config.environment || + !config.environments.find( + (x) => x.originalName == config.environment?.originalName + )) ) { - setSelectedEnvironment(config.environments[0]); + handleEnvironmentChange(config.environments[0]); } if (config.environments && config.environments.length === 0) { From 3abe4cf4310571e04f200de2cf608c99a3df8a0c Mon Sep 17 00:00:00 2001 From: olehp Date: Mon, 4 Mar 2024 15:30:35 +0200 Subject: [PATCH 3/7] clean-up --- src/components/Navigation/index.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/Navigation/index.tsx b/src/components/Navigation/index.tsx index 29707e798..9fe91a79a 100644 --- a/src/components/Navigation/index.tsx +++ b/src/components/Navigation/index.tsx @@ -182,10 +182,6 @@ export const Navigation = () => { } }, [config.environments, config.environment]); - useEffect(() => { - setSelectedEnvironment(config.environment); - }, [config.environment]); - useEffect(() => { setIsAutoFixing(false); setIsAnnotationAdding(false); From 11acebe74d3d3ff6258a3230321ffb206af049e5 Mon Sep 17 00:00:00 2001 From: Kyrylo Shmidt <119138536+kshmidt-digma@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:33:01 +0100 Subject: [PATCH 4/7] Update src/components/Navigation/ScopeNavigation/index.tsx --- src/components/Navigation/ScopeNavigation/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Navigation/ScopeNavigation/index.tsx b/src/components/Navigation/ScopeNavigation/index.tsx index b38ab5998..dca0bc5f6 100644 --- a/src/components/Navigation/ScopeNavigation/index.tsx +++ b/src/components/Navigation/ScopeNavigation/index.tsx @@ -14,7 +14,7 @@ import { actions as globalActions } from "./../actions"; import { HistoryNavigationPanel } from "./HistoryNavigationPanel"; import { ScopeNavigationProps } from "./types"; -const sendMessage = (scope: Scope | null) => { +const changeScope = (scope: Scope | null) => { window.sendMessageToDigma({ action: globalActions.CHANGE_SCOPE, payload: { From 870705fc37740aee04f93064dbe36cefa207aa54 Mon Sep 17 00:00:00 2001 From: Kyrylo Shmidt <119138536+kshmidt-digma@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:33:09 +0100 Subject: [PATCH 5/7] Update src/components/Navigation/ScopeNavigation/index.tsx --- src/components/Navigation/ScopeNavigation/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Navigation/ScopeNavigation/index.tsx b/src/components/Navigation/ScopeNavigation/index.tsx index dca0bc5f6..12b6a5699 100644 --- a/src/components/Navigation/ScopeNavigation/index.tsx +++ b/src/components/Navigation/ScopeNavigation/index.tsx @@ -37,7 +37,7 @@ export const ScopeNavigation = (props: ScopeNavigationProps) => { !environment || !environments?.find((x) => x.originalName == environment?.originalName) ) { - sendMessage(null); + сhangeScope(null); setHistoryManager(new HistoryManager()); } }, [environment, environments]); From fe79c54d3deb42fd7e7664aaa6c87fc3db1aa835 Mon Sep 17 00:00:00 2001 From: Kyrylo Shmidt <119138536+kshmidt-digma@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:33:15 +0100 Subject: [PATCH 6/7] Update src/components/Navigation/ScopeNavigation/index.tsx --- src/components/Navigation/ScopeNavigation/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Navigation/ScopeNavigation/index.tsx b/src/components/Navigation/ScopeNavigation/index.tsx index 12b6a5699..bfee29e12 100644 --- a/src/components/Navigation/ScopeNavigation/index.tsx +++ b/src/components/Navigation/ScopeNavigation/index.tsx @@ -113,7 +113,7 @@ export const ScopeNavigation = (props: ScopeNavigationProps) => { const handleBackClick = () => { const currentStep = historyManager.back(); if (currentStep && currentStep.scope) { - sendMessage(currentStep.scope); + changeScope(currentStep.scope); } }; From b236398c082159eff29b012f995ef3b283fc7e73 Mon Sep 17 00:00:00 2001 From: Kyrylo Shmidt <119138536+kshmidt-digma@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:38:06 +0100 Subject: [PATCH 7/7] Update src/components/Navigation/ScopeNavigation/index.tsx --- src/components/Navigation/ScopeNavigation/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Navigation/ScopeNavigation/index.tsx b/src/components/Navigation/ScopeNavigation/index.tsx index bfee29e12..4f9c9d2e9 100644 --- a/src/components/Navigation/ScopeNavigation/index.tsx +++ b/src/components/Navigation/ScopeNavigation/index.tsx @@ -120,7 +120,7 @@ export const ScopeNavigation = (props: ScopeNavigationProps) => { const handleNexClick = () => { const currentStep = historyManager.forward(); if (currentStep && currentStep.scope) { - sendMessage(currentStep.scope); + changeScope(currentStep.scope); } };