diff --git a/src/api/ros/recommendations.ts b/src/api/ros/recommendations.ts index d7be9ce42..cd7a61e26 100644 --- a/src/api/ros/recommendations.ts +++ b/src/api/ros/recommendations.ts @@ -8,6 +8,12 @@ export interface RecommendationValue { format?: string; } +export interface Notification { + code?: number; + message?: string; + type?: string; +} + export interface RecommendationItem { // confidence_level?: number; config: { @@ -33,12 +39,9 @@ export interface RecommendationItem { duration_in_hours?: string; monitoring_start_time?: string; monitoring_end_time?: string; - notifications?: [ - { - type?: string; - message?: string; - }, - ]; + notifications?: { + [key: string]: Notification; + }; } export interface RecommendationItems { diff --git a/src/components/drawers/optimzations/optimizationsContent.tsx b/src/components/drawers/optimzations/optimizationsContent.tsx index 80e801c78..8f2b4d45d 100644 --- a/src/components/drawers/optimzations/optimizationsContent.tsx +++ b/src/components/drawers/optimzations/optimizationsContent.tsx @@ -26,7 +26,7 @@ import { createMapStateToProps, FetchStatus } from 'store/common'; import { rosActions, rosSelectors } from 'store/ros'; import { getTimeFromNow } from 'utils/dates'; import { formatOptimization } from 'utils/format'; -import { hasRecommendation, hasRecommendationValues } from 'utils/recomendations'; +import { getNotifications, hasRecommendation, hasRecommendationValues } from 'utils/recomendations'; import type { RouterComponentProps } from 'utils/router'; import { withRouter } from 'utils/router'; @@ -101,11 +101,12 @@ class OptimizationsContentBase extends React.Component { + if (!hasNotification(term)) { + return undefined; + } + return Object.keys(term.notifications).map(key => term.notifications[key]); +}; export const hasNotification = (term: RecommendationItem) => { if (!(term && term.notifications)) { return false; } - return term.notifications.length > 0; + const keys = Object.keys(term.notifications); + return keys.length > 0; }; export const hasRecommendation = (term: RecommendationItem) => {