Skip to content

Commit e616a05

Browse files
committed
Enable filters for Issues and Assets on Web
1 parent 5dda876 commit e616a05

File tree

29 files changed

+296
-513
lines changed

29 files changed

+296
-513
lines changed
Lines changed: 41 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,62 @@
1-
import {
2-
useGetAboutQuery,
3-
useGetEnvironmentsQuery,
4-
useGetInsightsQuery
5-
} from "../../../../../../redux/services/digma";
6-
import {
7-
InsightsSortingCriterion,
8-
SortingOrder
9-
} from "../../../../../../redux/services/types";
10-
import { useInsightsSelector } from "../../../../../../store/insights/useInsightsSelector";
1+
import { useEffect } from "react";
2+
import { useAdminDispatch } from "../../../../../../containers/Admin/hooks";
3+
import { setScope } from "../../../../../../redux/slices/repositorySlice";
4+
import { useStore } from "../../../../../../store/useStore";
5+
import { useInsightsData } from "../../../../../Insights/hooks/useInsightsData";
116
import * as s from "./styles";
127
import type { AnalyticsProps } from "./types";
138

14-
const PAGE_SIZE = 10;
15-
169
export const Analytics = ({
1710
query,
1811
onScopeChange,
1912
onGoToTab
2013
}: AnalyticsProps) => {
21-
const { page } = useInsightsSelector();
22-
// const [page, setPage] = useState(0);
23-
// const insightsListRef = useRef<HTMLDivElement>(null);
24-
const { data: about } = useGetAboutQuery();
25-
const { data: environments } = useGetEnvironmentsQuery();
26-
// const pageSize = query?.pageSize ?? PAGE_SIZE;
27-
const { data, isFetching, refetch } = useGetInsightsQuery({
28-
data: {
29-
environment: query?.environment,
30-
scopedSpanCodeObjectId: query?.scopedSpanCodeObjectId,
31-
services:
32-
query?.services && query?.services.length > 0
33-
? query?.services.join(",")
34-
: undefined,
35-
sortBy: InsightsSortingCriterion.Criticality,
36-
sortOrder: SortingOrder.Desc,
37-
page,
38-
pageSize: PAGE_SIZE
39-
},
40-
extra: {
41-
insightViewType: "Analytics"
42-
}
43-
});
14+
const { setInsightViewType } = useStore.getState();
15+
const dispatch = useAdminDispatch();
16+
const { data, isLoading, refresh } = useInsightsData();
4417

4518
const handleRefresh = () => {
46-
void refetch();
19+
refresh();
4720
};
4821

49-
// const handleChangePage = (page: number) => {
50-
// sendUserActionTrackingEvent(trackingEvents.ANALYTICS_PAGE_CHANGED);
51-
// setPage(page);
52-
// };
53-
54-
// const handleScopeChange = (payload: ChangeScopePayload) => {
55-
// onScopeChange(payload);
56-
// };
57-
58-
// const totalCount = data?.data.totalCount ?? 0;
59-
// const pageStartItemNumber = page * pageSize + 1;
60-
// const pageEndItemNumber = Math.min(
61-
// pageStartItemNumber + pageSize - 1,
62-
// totalCount
63-
// );
64-
65-
// useEffect(() => {
66-
// setPage(0);
67-
// }, [query]);
68-
69-
// useEffect(() => {
70-
// insightsListRef.current?.scrollTo(0, 0);
71-
// }, [page, query]);
72-
73-
// const renderEmptyState = () => {
74-
// const handleSeeAllAssetsClick = () => {
75-
// sendUserActionTrackingEvent(
76-
// trackingEvents.ANALYTICS_SEE_ALL_ASSETS_BUTTON_CLICKED
77-
// );
78-
// onGoToAssets();
79-
// };
80-
81-
// if (!query?.scopedSpanCodeObjectId) {
82-
// return (
83-
// <InsightsPageEmptyState
84-
// preset={"analyticsSelectAsset"}
85-
// customContent={
86-
// <NewButton
87-
// buttonType={"primary"}
88-
// onClick={handleSeeAllAssetsClick}
89-
// label={"See all assets"}
90-
// />
91-
// }
92-
// />
93-
// );
94-
// }
95-
96-
// return <InsightsPageEmptyState preset={"noDataYet"} />;
97-
// };
98-
99-
// return (
100-
// <s.Container>
101-
// <s.ContentContainer>
102-
// {isFetching ? (
103-
// <EmptyState preset={"loading"} />
104-
// ) : data ? (
105-
// data.data.insights.length > 0 ? (
106-
// <s.InsightsList ref={insightsListRef}>
107-
// {data.data.insights.map((insight) => (
108-
// <InsightCardRenderer
109-
// key={insight.id}
110-
// insight={insight}
111-
// isJiraHintEnabled={false}
112-
// isMarkAsReadButtonEnabled={false}
113-
// viewMode={"full"}
114-
// tooltipBoundaryRef={insightsListRef}
115-
// backendInfo={about ?? null}
116-
// onScopeChange={handleScopeChange}
117-
// />
118-
// ))}
119-
// </s.InsightsList>
120-
// ) : (
121-
// renderEmptyState()
122-
// )
123-
// ) : null}
124-
// </s.ContentContainer>
125-
// <s.Footer>
126-
// {totalCount > 0 && (
127-
// <>
128-
// <Pagination
129-
// itemsCount={totalCount}
130-
// page={page}
131-
// pageSize={pageSize}
132-
// onPageChange={handleChangePage}
133-
// extendedNavigation={true}
134-
// />
135-
// <s.FooterItemsCount>
136-
// Showing{" "}
137-
// <s.FooterPageItemsCount>
138-
// {pageStartItemNumber} - {pageEndItemNumber}
139-
// </s.FooterPageItemsCount>{" "}
140-
// of {totalCount}
141-
// </s.FooterItemsCount>
142-
// </>
143-
// )}
144-
// </s.Footer>
145-
// </s.Container>
146-
// );
22+
// Set the insight view type in zustand store on component mount
23+
useEffect(() => {
24+
setInsightViewType("Analytics");
25+
}, [setInsightViewType]);
26+
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]);
14752

14853
return (
14954
<s.Content
150-
insightViewType={"Analytics"}
151-
data={data?.data ?? null}
152-
isLoading={isFetching}
55+
data={data}
56+
isLoading={isLoading}
15357
onScopeChange={onScopeChange}
15458
onGoToTab={onGoToTab}
155-
backendInfo={about ?? null}
15659
onRefresh={handleRefresh}
157-
environments={environments}
15860
/>
15961
);
16062
};

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export const Assets = ({
7070
onRefresh={handleRefresh}
7171
onAssetTypeSelect={handleAssetTypeSelect}
7272
selectedAssetTypeId={selectedAssetTypeId}
73-
areFiltersEnabled={false}
7473
/>
7574
);
7675
};

0 commit comments

Comments
 (0)