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
20 changes: 19 additions & 1 deletion src/components/Admin/common/RepositorySidebarOverlay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ export const RepositorySidebarOverlay = ({
const insightIdToOpenSuggestion = useAdminSelector(
(state) => state.repository.issues.insightIdToOpenSuggestion
);
const { resetInsights, resetAssets, resetGlobalErrors } = useStore.getState();
const {
resetInsights,
resetAssets,
resetGlobalErrors,
setSelectedServices,
clearInsightsFilters
} = useStore.getState();
const dispatch = useAdminDispatch();
const [history, setHistory] = useState(
() => new History<RepositorySidebarHistoryState>([])
Expand Down Expand Up @@ -212,6 +218,18 @@ export const RepositorySidebarOverlay = ({
dispatch
]);

// Set selected services on query change
useEffect(() => {
setSelectedServices(sidebarQuery?.query?.services ?? []);
}, [sidebarQuery?.query?.services, setSelectedServices]);

// Clear insights filters on sidebar close
useEffect(() => {
if (!isSidebarOpen) {
clearInsightsFilters();
}
}, [isSidebarOpen, clearInsightsFilters]);

const handleSidebarTransitionStart = () => {
setIsSidebarTransitioning(true);
};
Expand Down
14 changes: 12 additions & 2 deletions src/components/Insights/hooks/useInsightsData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback, useEffect, useMemo } from "react";
import { getFeatureFlagValue } from "../../../featureFlags";
import { platform } from "../../../platform";
import {
useGetInsightsQuery,
useGetIssuesQuery,
Expand Down Expand Up @@ -50,7 +51,12 @@ export const useInsightsData = () => {
const spanCodeObjectId = scope?.span?.spanCodeObjectId ?? null;

const filteredServices = useMemo(
() => (spanCodeObjectId ? [] : selectedServices ?? []),
() =>
spanCodeObjectId
? platform === "Web"
? selectedServices ?? []
: []
: selectedServices ?? [],
[selectedServices, spanCodeObjectId]
);
const filteredInsightTypes = spanCodeObjectId
Expand Down Expand Up @@ -150,7 +156,11 @@ export const useInsightsData = () => {
showDismissed,
scopedSpanCodeObjectId: spanCodeObjectId ?? undefined,
insightTypes: filteredInsightTypes,
services: spanCodeObjectId ? [] : filteredServices,
services: spanCodeObjectId
? platform === "Web"
? filteredServices
: []
: filteredServices,
...(isCriticalityLevelsFilterEnabled
? { criticalityFilter: filteredCriticalityLevels }
: {}),
Expand Down
8 changes: 7 additions & 1 deletion src/components/Insights/hooks/useInsightsStats.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback, useMemo } from "react";
import { getFeatureFlagValue } from "../../../featureFlags";
import { platform } from "../../../platform";
import { useGetInsightsStatsQuery } from "../../../redux/services/digma";
import { useConfigSelector } from "../../../store/config/useConfigSelector";
import { useInsightsSelector } from "../../../store/insights/useInsightsSelector";
Expand Down Expand Up @@ -37,7 +38,12 @@ export const useInsightsStats = ({
? filteredInsightTypesInSpanScope
: filteredInsightTypesInGlobalScope;
const filteredServices = useMemo(
() => (spanCodeObjectId ? [] : services ?? []),
() =>
spanCodeObjectId
? platform === "Web"
? services ?? []
: []
: services ?? [],
[services, spanCodeObjectId]
);

Expand Down
Loading