Skip to content

Commit 97dfaf7

Browse files
committed
Remove obsolete code
1 parent e616a05 commit 97dfaf7

File tree

7 files changed

+38
-181
lines changed

7 files changed

+38
-181
lines changed

src/components/Insights/InsightTicketRenderer/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import { SpanScalingByRootCauseInsightTicket } from "./insightTickets/SpanScalin
3737
import { SpanScalingInsightTicket } from "./insightTickets/SpanScalingInsightTicket";
3838
import type { InsightTicketRendererProps } from "./types";
3939

40-
// TODO: move to common
4140
export const InsightTicketRenderer = ({
4241
data,
4342
onClose,

src/components/Insights/InsightsCatalog/InsightsPage/InsightCardRenderer/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ import { SpanScalingInsightCard } from "./insightCards/SpanScalingInsightCard";
6161
import { SpanUsagesInsightCard } from "./insightCards/SpanUsagesInsightCard";
6262
import type { InsightCardRendererProps } from "./types";
6363

64-
// TODO: move to common
6564
export const InsightCardRenderer = ({
6665
insight,
6766
onJiraTicketCreate,

src/components/Insights/InsightsContent/index.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { useState, type KeyboardEvent } from "react";
1+
import { useEffect, useState, type KeyboardEvent } from "react";
22
import { actions as globalActions } from "../../../actions";
3+
import { usePrevious } from "../../../hooks/usePrevious";
34
import { useConfigSelector } from "../../../store/config/useConfigSelector";
45
import type { InsightsData } from "../../../store/insights/insightsSlice";
56
import { useInsightsSelector } from "../../../store/insights/useInsightsSelector";
@@ -18,19 +19,22 @@ export const InsightsContent = ({
1819
data,
1920
isLoading,
2021
onRefresh,
21-
isRegistrationEnabled,
2222
className,
2323
onOpenSuggestion,
2424
isJiraTicketHintEnabled,
2525
onJiraTicketPopupOpen,
2626
onJiraTicketPopupClose,
2727
infoToOpenJiraTicket
2828
}: InsightsContentProps) => {
29-
const { backendInfo, environments } = useConfigSelector();
30-
const { insightViewType } = useInsightsSelector();
31-
29+
const { backendInfo, userRegistrationEmail, environments } =
30+
useConfigSelector();
31+
const previousUserRegistrationEmail = usePrevious(userRegistrationEmail);
3232
const [isRegistrationInProgress, setIsRegistrationInProgress] =
3333
useState(false);
34+
const isRegistrationEnabled = false;
35+
const isRegistrationRequired =
36+
isRegistrationEnabled && !userRegistrationEmail;
37+
const { insightViewType } = useInsightsSelector();
3438

3539
const handleJiraTicketPopupClose = () => {
3640
onJiraTicketPopupClose?.();
@@ -58,6 +62,19 @@ export const InsightsContent = ({
5862
}
5963
};
6064

65+
useEffect(() => {
66+
if (
67+
previousUserRegistrationEmail !== userRegistrationEmail &&
68+
isRegistrationInProgress
69+
) {
70+
setIsRegistrationInProgress(false);
71+
}
72+
}, [
73+
userRegistrationEmail,
74+
isRegistrationInProgress,
75+
previousUserRegistrationEmail
76+
]);
77+
6178
const renderContent = (
6279
data: InsightsData | null,
6380
isLoading: boolean
@@ -112,7 +129,7 @@ export const InsightsContent = ({
112129
{infoToOpenJiraTicket && (
113130
<s.Overlay onKeyDown={handleOverlayKeyDown} tabIndex={-1}>
114131
<s.PopupContainer>
115-
{isRegistrationEnabled ? (
132+
{isRegistrationRequired ? (
116133
<RegistrationDialog
117134
onSubmit={handleRegistrationSubmit}
118135
onClose={handleRegistrationDialogClose}

src/components/Insights/InsightsContent/styles.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,6 @@ export const Container = styled.div`
88
position: relative;
99
`;
1010

11-
// export const Description = styled.div`
12-
// display: flex;
13-
// gap: 8px;
14-
// font-size: 14px;
15-
// color: ${({ theme }) => {
16-
// switch (theme.mode) {
17-
// case "light":
18-
// return "#828797";
19-
// case "dark":
20-
// case "dark-jetbrains":
21-
// return "#b4b8bf";
22-
// }
23-
// }};
24-
// `;
25-
26-
// export const Link = styled(CommonLink)`
27-
// text-decoration: none;
28-
// color: ${({ theme }) => {
29-
// switch (theme.mode) {
30-
// case "light":
31-
// return "#7891d0";
32-
// case "dark":
33-
// case "dark-jetbrains":
34-
// return "#92affa";
35-
// }
36-
// }};
37-
// `;
38-
3911
export const Overlay = styled.div`
4012
position: fixed;
4113
inset: 0;

src/components/Insights/InsightsContent/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import type { GenericCodeObjectInsight } from "../types";
55
export interface InsightsContentProps {
66
onScopeChange: (payload: ChangeScopePayload) => void;
77
onGoToTab: (tabId: string) => void;
8-
isRegistrationInProgress?: boolean;
9-
isRegistrationEnabled?: boolean;
108
isLoading: boolean;
119
data: InsightsData | null;
1210
onRefresh: () => void;

src/components/Insights/index.tsx

Lines changed: 14 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
1-
import type { KeyboardEvent } from "react";
21
import { useCallback, useEffect, useState } from "react";
3-
import { actions as globalActions } from "../../actions";
42
import { usePersistence } from "../../hooks/usePersistence";
5-
import { usePrevious } from "../../hooks/usePrevious";
6-
import { useConfigSelector } from "../../store/config/useConfigSelector";
7-
import { useInsightsSelector } from "../../store/insights/useInsightsSelector";
83
import { useStore } from "../../store/useStore";
94
import { isUndefined } from "../../typeGuards/isUndefined";
105
import { changeScope } from "../../utils/actions/changeScope";
11-
import { RegistrationDialog } from "../common/RegistrationDialog";
12-
import type { RegistrationFormValues } from "../common/RegistrationDialog/types";
136
import { useHistory } from "../Main/useHistory";
14-
import { EmptyState } from "./EmptyState";
157
import { useInsightsData } from "./hooks/useInsightsData";
16-
import { InsightsCatalog } from "./InsightsCatalog";
17-
import { InsightTicketRenderer } from "./InsightTicketRenderer";
18-
import * as s from "./styles";
8+
import { InsightsContent } from "./InsightsContent";
199
import type {
2010
GenericCodeObjectInsight,
2111
InsightTicketInfo,
@@ -30,16 +20,7 @@ export const Insights = ({ insightViewType }: InsightsProps) => {
3020
const { data, isLoading, refresh } = useInsightsData();
3121
const [infoToOpenJiraTicket, setInfoToOpenJiraTicket] =
3222
useState<InsightTicketInfo<GenericCodeObjectInsight>>();
33-
const { backendInfo, userRegistrationEmail, environments } =
34-
useConfigSelector();
35-
const previousUserRegistrationEmail = usePrevious(userRegistrationEmail);
36-
const [isRegistrationInProgress, setIsRegistrationInProgress] =
37-
useState(false);
38-
const isRegistrationEnabled = false;
39-
const isRegistrationRequired =
40-
isRegistrationEnabled && !userRegistrationEmail;
4123
const { setInsightViewType, resetInsights: reset } = useStore.getState();
42-
const { insightViewType: storedInsightViewType } = useInsightsSelector();
4324
const { goTo } = useHistory();
4425
const [isInsightJiraTicketHintShown, setIsInsightJiraTicketHintShown] =
4526
usePersistence<isInsightJiraTicketHintShownPayload>(
@@ -61,19 +42,6 @@ export const Insights = ({ insightViewType }: InsightsProps) => {
6142
setInsightViewType(insightViewType);
6243
}, [insightViewType, setInsightViewType]);
6344

64-
useEffect(() => {
65-
if (
66-
previousUserRegistrationEmail !== userRegistrationEmail &&
67-
isRegistrationInProgress
68-
) {
69-
setIsRegistrationInProgress(false);
70-
}
71-
}, [
72-
userRegistrationEmail,
73-
isRegistrationInProgress,
74-
previousUserRegistrationEmail
75-
]);
76-
7745
const handleJiraTicketPopupOpen = useCallback(
7846
(insight: GenericCodeObjectInsight, spanCodeObjectId?: string) => {
7947
setInfoToOpenJiraTicket({ insight, spanCodeObjectId });
@@ -86,91 +54,21 @@ export const Insights = ({ insightViewType }: InsightsProps) => {
8654
setInfoToOpenJiraTicket(undefined);
8755
};
8856

89-
const handleRegistrationSubmit = (formData: RegistrationFormValues) => {
90-
window.sendMessageToDigma({
91-
action: globalActions.PERSONALIZE_REGISTER,
92-
payload: {
93-
...formData,
94-
scope: "insights view jira ticket info"
95-
}
96-
});
97-
98-
setIsRegistrationInProgress(true);
99-
};
100-
101-
const handleRegistrationDialogClose = () => {
102-
setInfoToOpenJiraTicket(undefined);
103-
};
104-
105-
const handleOverlayKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
106-
if (e.key === "Escape") {
107-
setInfoToOpenJiraTicket(undefined);
108-
}
109-
};
110-
111-
const renderContent = (): JSX.Element => {
112-
const isInitialLoading =
113-
(!data && isLoading) || !backendInfo || !storedInsightViewType;
114-
115-
const handleGoToTab = (tabId: string) => {
116-
goTo(`/${tabId}`);
117-
};
118-
119-
if (isInitialLoading) {
120-
return <EmptyState preset={"loading"} />;
121-
}
122-
123-
if (!environments?.length) {
124-
return <EmptyState preset={"noDataYet"} />;
125-
}
126-
127-
// switch (data?.insightsStatus) {
128-
// case InsightsStatus.STARTUP:
129-
// return <EmptyState preset={"nothingToShow"} />;
130-
// case InsightsStatus.NO_INSIGHTS:
131-
// return <EmptyState preset={"noInsights"} />;
132-
// case InsightsStatus.INSIGHT_PENDING:
133-
// return <EmptyState preset={"processing"} />;
134-
// case InsightsStatus.NO_SPANS_DATA:
135-
// return <EmptyState preset={"noDataYet"} />;
136-
// case InsightsStatus.NO_OBSERVABILITY:
137-
// return <EmptyState preset={"noObservability"} />;
138-
// case InsightsStatus.DEFAULT:
139-
// default:
140-
return (
141-
<InsightsCatalog
142-
onJiraTicketCreate={handleJiraTicketPopupOpen}
143-
onRefresh={refresh}
144-
onGoToTab={handleGoToTab}
145-
onScopeChange={changeScope}
146-
isJiraTicketHintEnabled={isJiraTicketHintEnabled}
147-
/>
148-
);
149-
// }
57+
const handleGoToTab = (tabId: string) => {
58+
goTo(`/${tabId}`);
15059
};
15160

15261
return (
153-
<s.Container>
154-
{renderContent()}
155-
{infoToOpenJiraTicket && (
156-
<s.Overlay onKeyDown={handleOverlayKeyDown} tabIndex={-1}>
157-
<s.PopupContainer>
158-
{isRegistrationRequired ? (
159-
<RegistrationDialog
160-
onSubmit={handleRegistrationSubmit}
161-
onClose={handleRegistrationDialogClose}
162-
isRegistrationInProgress={isRegistrationInProgress}
163-
/>
164-
) : (
165-
<InsightTicketRenderer
166-
data={infoToOpenJiraTicket}
167-
onClose={handleJiraTicketPopupClose}
168-
backendInfo={backendInfo}
169-
/>
170-
)}
171-
</s.PopupContainer>
172-
</s.Overlay>
173-
)}
174-
</s.Container>
62+
<InsightsContent
63+
onScopeChange={changeScope}
64+
onGoToTab={handleGoToTab}
65+
isLoading={isLoading}
66+
data={data}
67+
onRefresh={refresh}
68+
isJiraTicketHintEnabled={isJiraTicketHintEnabled}
69+
onJiraTicketPopupOpen={handleJiraTicketPopupOpen}
70+
onJiraTicketPopupClose={handleJiraTicketPopupClose}
71+
infoToOpenJiraTicket={infoToOpenJiraTicket}
72+
/>
17573
);
17674
};

src/components/Insights/styles.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
import styled from "styled-components";
2-
import { LAYERS } from "../common/App/styles";
32
import { Link as CommonLink } from "../common/Link";
43

5-
export const Container = styled.div`
6-
display: flex;
7-
flex-direction: column;
8-
height: 100%;
9-
position: relative;
10-
`;
11-
4+
/** @deprecated */
125
export const Description = styled.div`
136
display: flex;
147
gap: 8px;
@@ -36,22 +29,3 @@ export const Link = styled(CommonLink)`
3629
}
3730
}};
3831
`;
39-
40-
export const Overlay = styled.div`
41-
position: fixed;
42-
inset: 0;
43-
margin: auto;
44-
background: rgb(18 18 21 / 70%);
45-
z-index: ${LAYERS.OVERLAY};
46-
overflow: auto;
47-
`;
48-
49-
export const PopupContainer = styled.div`
50-
display: flex;
51-
align-items: center;
52-
justify-content: center;
53-
min-height: 100%;
54-
padding: 16px 4%;
55-
overflow: hidden;
56-
box-sizing: border-box;
57-
`;

0 commit comments

Comments
 (0)