diff --git a/src/api/query-hooks/index.ts b/src/api/query-hooks/index.ts index b4da0cd6d..3a12b13b7 100644 --- a/src/api/query-hooks/index.ts +++ b/src/api/query-hooks/index.ts @@ -477,7 +477,9 @@ export function useGetTopologyRelatedInsightsQuery( select: (response) => { return { ...response, - data: response?.data?.flatMap((item) => item.config?.analysis) + data: response?.data?.map((item) => + item.config.analysis.find((a) => a.id === item.analysis_id) + ) }; } } diff --git a/src/api/services/configs.ts b/src/api/services/configs.ts index fdf3c4355..194da1b34 100644 --- a/src/api/services/configs.ts +++ b/src/api/services/configs.ts @@ -413,6 +413,7 @@ export const getTopologyRelatedInsights = async ( return resolve( ConfigDB.get< | { + analysis_id: string; config: { id: string; name: string; @@ -429,12 +430,12 @@ export const getTopologyRelatedInsights = async ( | "sanitizedMessageHTML" | "first_observed" | "message" - >; + >[]; }; }[] | null >( - `/analysis_by_component?component_id=eq.${id}${paginationQueryParams}&select=config:configs(id,name,config_class,type,analysis:config_analysis(id,analyzer,analysis_type,message,severity,analysis,first_observed))`, + `/analysis_by_component?component_id=eq.${id}${paginationQueryParams}&select=analysis_id,config:configs(id,name,config_class,type,analysis:config_analysis(id,analyzer,analysis_type,message,severity,analysis,first_observed))`, { headers: { Prefer: "count=exact" diff --git a/src/components/Insights/Insights.tsx b/src/components/Insights/Insights.tsx index 3fc4e354f..9e8766f90 100644 --- a/src/components/Insights/Insights.tsx +++ b/src/components/Insights/Insights.tsx @@ -116,9 +116,9 @@ export default function InsightsDetails( insights.map((item) => { return { ...item, - sanitizedMessageHTML: sanitizeHTMLContent(item?.message), + sanitizedMessageHTML: sanitizeHTMLContent(item?.message ?? ""), sanitizedMessageTxt: truncateText( - sanitizeHTMLContentToText(item?.message)!, + sanitizeHTMLContentToText(item?.message ?? "")!, 500 ) }; @@ -152,7 +152,7 @@ export default function InsightsDetails( columns={columns} isLoading={isLoading && !isFetching} isFetching={isFetching} - allRows={insightsWithSanitizedMessages} + allRows={insightsWithSanitizedMessages as ConfigTypeInsights[]} loaderView={} totalEntries={totalEntries} fetchNextPage={() => {