Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/Assets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ export const Assets = () => {
);
}

if (!selectedFilters && !selectedServices) {
if (
!config.environments?.length ||
(!selectedFilters && !selectedServices)
) {
return <NoDataMessage type={"noDataYet"} />;
}

Expand Down
50 changes: 33 additions & 17 deletions src/components/Insights/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<EmptyState
icon={CardsIcon}
title={"No data yet"}
content={
<>
<s.EmptyStateDescription>
Trigger actions that call this application to learn more about its
runtime behavior
</s.EmptyStateDescription>
<s.TroubleshootingLink onClick={handleTroubleshootingLinkClick}>
Not seeing your application data?
</s.TroubleshootingLink>
</>
}
/>
);
};

const sendMessage = (action: string, data?: object) => {
return window.sendMessageToDigma({
action,
Expand Down Expand Up @@ -282,6 +310,10 @@ export const Insights = (props: InsightsProps) => {
return <EmptyState content={<CircleLoader size={32} />} />;
}

if (!config.environments?.length) {
return <NoDataYet />;
}

switch (data?.insightsStatus) {
case InsightsStatus.STARTUP:
return (
Expand Down Expand Up @@ -321,23 +353,7 @@ export const Insights = (props: InsightsProps) => {
/>
);
case InsightsStatus.NO_SPANS_DATA:
return (
<EmptyState
icon={CardsIcon}
title={"No data yet"}
content={
<>
<s.EmptyStateDescription>
Trigger actions that call this application to learn more about
its runtime behavior
</s.EmptyStateDescription>
<s.TroubleshootingLink onClick={handleTroubleshootingLinkClick}>
Not seeing your application data?
</s.TroubleshootingLink>
</>
}
/>
);
return <NoDataYet />;
case InsightsStatus.NO_OBSERVABILITY:
return (
<EmptyState
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navigation/EnvironmentBar/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Environment } from "../../common/App/types";

export interface EnvironmentBarProps {
selectedEnvironment?: Environment;
selectedEnvironment?: Environment | null;
isMenuOpen?: boolean;
onClick: () => void;
isDisabled?: boolean;
Expand Down
44 changes: 28 additions & 16 deletions src/components/Navigation/ScopeNavigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 changeScope = (scope: Scope | null) => {
window.sendMessageToDigma<ChangeScopePayload>({
action: globalActions.CHANGE_SCOPE,
payload: {
span: scope?.span || null
}
});
};

export const ScopeNavigation = (props: ScopeNavigationProps) => {
const [historyManager, setHistoryManager] = useState<HistoryManager>(
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)
) {
сhangeScope(null);
setHistoryManager(new HistoryManager());
}
}, [environment, environments]);

useEffect(() => {
const currentStep = historyManager.getCurrent();
if (
Expand Down Expand Up @@ -100,15 +112,15 @@ export const ScopeNavigation = (props: ScopeNavigationProps) => {

const handleBackClick = () => {
const currentStep = historyManager.back();
if (currentStep) {
sendMessage(currentStep);
if (currentStep && currentStep.scope) {
changeScope(currentStep.scope);
}
};

const handleNexClick = () => {
const currentStep = historyManager.forward();
if (currentStep) {
sendMessage(currentStep);
if (currentStep && currentStep.scope) {
changeScope(currentStep.scope);
}
};

Expand Down
11 changes: 5 additions & 6 deletions src/components/Navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,19 @@ 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) {
setSelectedEnvironment(undefined);
}
}, [config.environments, config.environment]);

useEffect(() => {
setSelectedEnvironment(config.environment);
}, [config.environment]);

useEffect(() => {
setIsAutoFixing(false);
setIsAnnotationAdding(false);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface OpenDocumentationPayload {
}

export interface OpenDashboardPayload {
environment?: Environment;
environment?: Environment | null;
}

export interface ChangeScopePayload {
Expand Down
7 changes: 7 additions & 0 deletions src/components/common/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ export const App = (props: AppProps) => {
...config,
environments: data.environments as Environment[]
}));

if (!data.environments.length) {
setConfig((config) => ({
...config,
environment: null
}));
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/common/App/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down