Skip to content

Commit d3a680b

Browse files
committed
Fix filters
1 parent a1349cb commit d3a680b

File tree

11 files changed

+86
-142
lines changed

11 files changed

+86
-142
lines changed

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
"type": "chrome",
99
"request": "launch",
1010
"name": "Open Admin in Chrome",
11-
"url": "http://localhost:3000/admin/",
11+
"url": "http://localhost:3001/admin/",
1212
"webRoot": "${workspaceFolder}"
1313
},
1414
{
1515
"type": "chrome",
1616
"request": "launch",
1717
"name": "Open Agentic in Chrome",
18-
"url": "http://localhost:3000/agentic/",
18+
"url": "http://localhost:3001/agentic/",
1919
"webRoot": "${workspaceFolder}"
2020
}
2121
]

src/components/Admin/common/RepositorySidebarOverlay/RepositorySidebar/Analytics/index.tsx

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import { useEffect } from "react";
2-
import { useAdminDispatch } from "../../../../../../containers/Admin/hooks";
3-
import { setScope } from "../../../../../../redux/slices/repositorySlice";
42
import { useStore } from "../../../../../../store/useStore";
53
import { useInsightsData } from "../../../../../Insights/hooks/useInsightsData";
64
import * as s from "./styles";
75
import type { AnalyticsProps } from "./types";
86

9-
export const Analytics = ({
10-
query,
11-
onScopeChange,
12-
onGoToTab
13-
}: AnalyticsProps) => {
7+
export const Analytics = ({ onScopeChange, onGoToTab }: AnalyticsProps) => {
148
const { setInsightViewType } = useStore.getState();
15-
const dispatch = useAdminDispatch();
169
const { data, isLoading, refresh } = useInsightsData();
1710

1811
const handleRefresh = () => {
@@ -24,32 +17,6 @@ export const Analytics = ({
2417
setInsightViewType("Analytics");
2518
}, [setInsightViewType]);
2619

27-
// Set the scope on query change
28-
useEffect(() => {
29-
dispatch(
30-
setScope({
31-
span: query?.scopedSpanCodeObjectId
32-
? {
33-
spanCodeObjectId: query.scopedSpanCodeObjectId,
34-
displayName: "",
35-
methodId: null,
36-
serviceName: null,
37-
role: null
38-
}
39-
: null,
40-
code: {
41-
relatedCodeDetailsList: [],
42-
codeDetailsList: []
43-
},
44-
hasErrors: false,
45-
issuesInsightsCount: 0,
46-
analyticsInsightsCount: 0,
47-
unreadInsightsCount: 0,
48-
environmentId: query?.environment
49-
})
50-
);
51-
}, [query, dispatch]);
52-
5320
return (
5421
<s.Content
5522
data={data}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import type { GetIssuesPayload } from "../../../../../../redux/services/types";
21
import type { ChangeScopePayload } from "../../../../../../utils/actions/changeScope";
32

43
export interface AnalyticsProps {
5-
query?: GetIssuesPayload;
64
onScopeChange: (payload: ChangeScopePayload) => void;
75
onGoToTab: (tabId: string) => void;
86
}

src/components/Admin/common/RepositorySidebarOverlay/RepositorySidebar/Assets/index.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import {
1010
SortingOrder,
1111
type AssetType
1212
} from "../../../../../../redux/services/types";
13+
import { useConfigSelector } from "../../../../../../store/config/useConfigSelector";
1314
import type { Sorting } from "../../../../../common/SortingSelector/types";
1415
import * as s from "./styles";
1516
import type { AssetsProps } from "./types";
1617

1718
export const Assets = ({
18-
query,
1919
onScopeChange,
2020
selectedAssetTypeId,
2121
onSelectedAssetTypeIdChange
@@ -24,17 +24,13 @@ export const Assets = ({
2424
criterion: AssetsSortingCriterion.CriticalInsights,
2525
order: SortingOrder.Desc
2626
});
27+
const { selectedServices, scope, environment } = useConfigSelector();
2728

2829
const dispatch = useAdminDispatch();
2930

3031
const { data: about } = useGetAboutQuery();
3132
const { data: environments } = useGetEnvironmentsQuery();
3233

33-
const environment = useMemo(
34-
() => environments?.find((x) => x.id === query?.environment),
35-
[environments, query?.environment]
36-
);
37-
3834
const isImpactHidden = useMemo(
3935
() => !(about?.isCentralize && environment?.type === "Public"),
4036
[about?.isCentralize, environment?.type]
@@ -58,9 +54,9 @@ export const Assets = ({
5854

5955
return (
6056
<s.Content
61-
environmentId={query?.environment}
62-
spanCodeObjectId={query?.scopedSpanCodeObjectId}
63-
services={query?.services}
57+
environmentId={environment?.id}
58+
spanCodeObjectId={scope?.span?.spanCodeObjectId}
59+
services={selectedServices ?? undefined}
6460
sorting={sorting}
6561
setSorting={setSorting}
6662
onScopeChange={onScopeChange}

src/components/Admin/common/RepositorySidebarOverlay/RepositorySidebar/Assets/types.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import type {
2-
AssetType,
3-
GetIssuesPayload
4-
} from "../../../../../../redux/services/types";
1+
import type { AssetType } from "../../../../../../redux/services/types";
52
import type { ChangeScopePayload } from "../../../../../../utils/actions/changeScope";
63

74
export interface AssetsProps {
8-
query?: GetIssuesPayload;
95
onScopeChange: (payload: ChangeScopePayload) => void;
106
selectedAssetTypeId?: AssetType;
117
onSelectedAssetTypeIdChange: (assetTypeId?: AssetType) => void;

src/components/Admin/common/RepositorySidebarOverlay/RepositorySidebar/Errors/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import { useGetAboutQuery } from "../../../../../../redux/services/digma";
2+
import { useConfigSelector } from "../../../../../../store/config/useConfigSelector";
23
import * as s from "./styles";
34
import type { ErrorsProps } from "./types";
45

56
export const Errors = ({
6-
query,
77
onGoToAssets,
88
onScopeChange,
99
selectedErrorId,
1010
onSelectedErrorIdChange
1111
}: ErrorsProps) => {
1212
const { data: about } = useGetAboutQuery();
13+
const { selectedServices, scope, environment } = useConfigSelector();
1314

1415
const handleGoToErrors = () => {
1516
onSelectedErrorIdChange(undefined);
@@ -24,11 +25,11 @@ export const Errors = ({
2425
onGoToAssets={onGoToAssets}
2526
onGoToErrors={handleGoToErrors}
2627
onErrorSelect={handleErrorSelect}
27-
spanCodeObjectId={query?.scopedSpanCodeObjectId}
28-
environmentId={query?.environment}
28+
spanCodeObjectId={scope?.span?.spanCodeObjectId}
29+
environmentId={environment?.id}
2930
errorId={selectedErrorId}
3031
backendInfo={about}
31-
selectedServices={query?.services ?? undefined}
32+
selectedServices={selectedServices ?? undefined}
3233
onScopeChange={onScopeChange}
3334
/>
3435
);

src/components/Admin/common/RepositorySidebarOverlay/RepositorySidebar/Issues/index.tsx

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import {
77
import { setIsInsightJiraTicketHintShown } from "../../../../../../redux/slices/persistSlice";
88
import {
99
setIssuesInsightIdToOpenSuggestion,
10-
setIssuesInsightInfoToOpenTicket,
11-
setScope
10+
setIssuesInsightInfoToOpenTicket
1211
} from "../../../../../../redux/slices/repositorySlice";
1312
import { initialState } from "../../../../../../store/insights/insightsSlice";
1413
import { useStore } from "../../../../../../store/useStore";
@@ -85,32 +84,6 @@ export const Issues = ({
8584
setInsightViewType("Issues");
8685
}, [setInsightViewType]);
8786

88-
// Set the scope on query change
89-
useEffect(() => {
90-
dispatch(
91-
setScope({
92-
span: query?.scopedSpanCodeObjectId
93-
? {
94-
spanCodeObjectId: query.scopedSpanCodeObjectId,
95-
displayName: "",
96-
methodId: null,
97-
serviceName: null,
98-
role: null
99-
}
100-
: null,
101-
code: {
102-
relatedCodeDetailsList: [],
103-
codeDetailsList: []
104-
},
105-
hasErrors: false,
106-
issuesInsightsCount: 0,
107-
analyticsInsightsCount: 0,
108-
unreadInsightsCount: 0,
109-
environmentId: query?.environment
110-
})
111-
);
112-
}, [query, dispatch]);
113-
11487
// Set sorting on query change
11588
useEffect(() => {
11689
setInsightsSorting({

src/components/Admin/common/RepositorySidebarOverlay/index.tsx

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import type {
1919
import {
2020
clear,
2121
setIssuesInsightIdToOpenSuggestion,
22-
setIssuesInsightInfoToOpenTicket
22+
setIssuesInsightInfoToOpenTicket,
23+
setScope
2324
} from "../../../../redux/slices/repositorySlice";
2425
import { useStore } from "../../../../store/useStore";
2526
import { isString } from "../../../../typeGuards/isString";
@@ -76,12 +77,10 @@ export const RepositorySidebarOverlay = ({
7677
resetAssets,
7778
resetGlobalErrors,
7879
setSelectedServices,
79-
clearInsightsFilters,
80-
setInsightsFilteredInsightTypes,
81-
setInsightsFilteredInsightTypesInGlobalScope,
8280
setInsightsFilteredCriticalityLevels,
8381
setInsightsFilteredCriticalityLevelsInGlobalScope,
84-
setInsightsLastDays
82+
setInsightsLastDays,
83+
setGlobalErrorsLastDays
8584
} = useStore.getState();
8685
const dispatch = useAdminDispatch();
8786
const [history, setHistory] = useState(
@@ -223,14 +222,47 @@ export const RepositorySidebarOverlay = ({
223222
dispatch
224223
]);
225224

225+
// Set the scope and environment on sidebar open
226+
useEffect(() => {
227+
if (isSidebarOpen) {
228+
dispatch(
229+
setScope({
230+
span: currentSpanCodeObjectId
231+
? {
232+
spanCodeObjectId: currentSpanCodeObjectId,
233+
displayName: "",
234+
methodId: null,
235+
serviceName: null,
236+
role: null
237+
}
238+
: null,
239+
code: {
240+
relatedCodeDetailsList: [],
241+
codeDetailsList: []
242+
},
243+
hasErrors: false,
244+
issuesInsightsCount: 0,
245+
analyticsInsightsCount: 0,
246+
unreadInsightsCount: 0,
247+
environmentId: sidebarQuery?.query?.environment
248+
})
249+
);
250+
}
251+
}, [
252+
isSidebarOpen,
253+
sidebarQuery?.query?.environment,
254+
currentSpanCodeObjectId,
255+
dispatch
256+
]);
257+
226258
// Set selected services on sidebar open
227259
useEffect(() => {
228260
if (isSidebarOpen) {
229261
setSelectedServices(sidebarQuery?.query?.services ?? []);
230262
}
231263
}, [isSidebarOpen, sidebarQuery?.query?.services, setSelectedServices]);
232264

233-
// Set selected criticality levels on sidebar open
265+
// Set insights criticality levels on sidebar open
234266
useEffect(() => {
235267
if (isSidebarOpen) {
236268
setInsightsFilteredCriticalityLevels(
@@ -251,25 +283,13 @@ export const RepositorySidebarOverlay = ({
251283
useEffect(() => {
252284
if (isSidebarOpen) {
253285
setInsightsLastDays(sidebarQuery?.query?.lastDays ?? null);
254-
}
255-
}, [isSidebarOpen, sidebarQuery?.query?.lastDays, setInsightsLastDays]);
256-
257-
// Clear issues and analytics filters on sidebar close
258-
useEffect(() => {
259-
if (!isSidebarOpen) {
260-
clearInsightsFilters();
261-
setInsightsFilteredInsightTypes([]);
262-
setInsightsFilteredInsightTypesInGlobalScope([]);
263-
setInsightsFilteredCriticalityLevels([]);
264-
setInsightsFilteredCriticalityLevelsInGlobalScope([]);
286+
setGlobalErrorsLastDays(sidebarQuery?.query?.lastDays ?? null);
265287
}
266288
}, [
267289
isSidebarOpen,
268-
clearInsightsFilters,
269-
setInsightsFilteredInsightTypes,
270-
setInsightsFilteredInsightTypesInGlobalScope,
271-
setInsightsFilteredCriticalityLevels,
272-
setInsightsFilteredCriticalityLevelsInGlobalScope
290+
sidebarQuery?.query?.lastDays,
291+
setInsightsLastDays,
292+
setGlobalErrorsLastDays
273293
]);
274294

275295
const handleSidebarTransitionStart = () => {
@@ -411,7 +431,6 @@ export const RepositorySidebarOverlay = ({
411431
case TAB_IDS.ASSETS:
412432
return (
413433
<Assets
414-
query={currentQuery}
415434
onScopeChange={handleScopeChange}
416435
selectedAssetTypeId={
417436
currentTabLocation.path as AssetType | undefined
@@ -423,7 +442,6 @@ export const RepositorySidebarOverlay = ({
423442
return (
424443
<Analytics
425444
onScopeChange={handleScopeChange}
426-
query={currentQuery}
427445
onGoToTab={handleGoToTab}
428446
/>
429447
);

src/components/Dashboard/MetricsReport/index.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { useLayoutEffect } from "react";
1+
import { useEffect, useLayoutEffect, useMemo } from "react";
22
import {
33
useDashboardDispatch,
44
useDashboardSelector
55
} from "../../../containers/Dashboard/hooks";
6-
import { useMount } from "../../../hooks/useMount";
76
import {
87
type EndpointData,
98
type IssueCriticality
@@ -27,6 +26,7 @@ import { ScopeChangeEvent } from "../../../types";
2726
import { changeScope } from "../../../utils/actions/changeScope";
2827
import { IssuesReport } from "../../common/IssuesReport";
2928
import type { TargetScope } from "../../common/IssuesReport/types";
29+
import { sortEnvironments } from "../../common/IssuesReport/utils";
3030
import { DigmaLogoIcon } from "../../common/icons/16px/DigmaLogoIcon";
3131
import { actions } from "../actions";
3232
import * as s from "./styles";
@@ -61,18 +61,36 @@ export const MetricsReport = () => {
6161

6262
const dispatch = useDashboardDispatch();
6363

64+
const sortedEnvironments = useMemo(
65+
() => (environments ? sortEnvironments(environments) : undefined),
66+
[environments]
67+
);
68+
6469
useLayoutEffect(() => {
6570
window.sendMessageToDigma({
6671
action: actions.INITIALIZE
6772
});
6873
}, []);
6974

70-
// TODO: replace with useEffect
71-
useMount(() => {
72-
if (isString(window.dashboardEnvironment)) {
75+
useEffect(() => {
76+
if (
77+
isString(window.dashboardEnvironment) &&
78+
selectedEnvironmentId !== window.dashboardEnvironment
79+
) {
7380
dispatch(setSelectedEnvironmentId(window.dashboardEnvironment));
7481
}
75-
});
82+
}, [dispatch, selectedEnvironmentId]);
83+
84+
useEffect(() => {
85+
if (
86+
sortedEnvironments &&
87+
sortedEnvironments.length > 0 &&
88+
!selectedEnvironmentId &&
89+
!isString(window.dashboardEnvironment)
90+
) {
91+
dispatch(setSelectedEnvironmentId(sortedEnvironments[0].id));
92+
}
93+
}, [sortedEnvironments, selectedEnvironmentId, dispatch]);
7694

7795
const goToEndpointIssues = ({
7896
spanCodeObjectId,

0 commit comments

Comments
 (0)