diff --git a/locales/data.json b/locales/data.json index 9f86a7dc9..5f1148a80 100644 --- a/locales/data.json +++ b/locales/data.json @@ -9609,6 +9609,12 @@ "value": "Infrastructure" } ], + "lastProcessed": [ + { + "type": 0, + "value": "Last processed" + } + ], "learnMore": [ { "type": 0, diff --git a/locales/translations.json b/locales/translations.json index cd565d8dd..55dfefb72 100644 --- a/locales/translations.json +++ b/locales/translations.json @@ -334,6 +334,7 @@ "inactiveSourcesTitle": "A problem was detected with {value}", "inactiveSourcesTitleMultiplier": "A problem was detected with the following sources", "infrastructure": "Infrastructure", + "lastProcessed": "Last processed", "learnMore": "Learn more", "limits": "Limits", "loadingStateDesc": "Searching for your sources. Do not refresh the browser", diff --git a/src/api/costModels.ts b/src/api/costModels.ts index 2e83fb057..2a0c3a178 100644 --- a/src/api/costModels.ts +++ b/src/api/costModels.ts @@ -5,6 +5,7 @@ import type { Rate, RateRequest } from './rates'; export interface CostModelProvider { name: string; + last_processed?: string; uuid: string; } diff --git a/src/components/featureFlags/featureFlags.tsx b/src/components/featureFlags/featureFlags.tsx index 40abc0cd6..d005deb5f 100644 --- a/src/components/featureFlags/featureFlags.tsx +++ b/src/components/featureFlags/featureFlags.tsx @@ -1,3 +1,4 @@ +import { useChrome } from '@redhat-cloud-services/frontend-components/useChrome'; import { useUnleashClient, useUnleashContext } from '@unleash/proxy-client-react'; import { useLayoutEffect, useRef } from 'react'; import { useDispatch } from 'react-redux'; @@ -21,14 +22,12 @@ const useFeatureFlags = () => { const updateContext = useUnleashContext(); const client = useUnleashClient(); const dispatch = useDispatch(); + const { auth } = useChrome(); const fetchUser = callback => { - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - insights.chrome.auth.getUser().then(user => { - callback(user.identity.account_number); - }); - } + auth.getUser().then(user => { + callback((user as any).identity.account_number); + }); }; const isMounted = useRef(false); diff --git a/src/locales/messages.ts b/src/locales/messages.ts index 04c4e9df1..f5e4197b3 100644 --- a/src/locales/messages.ts +++ b/src/locales/messages.ts @@ -2174,6 +2174,11 @@ export default defineMessages({ description: 'Infrastructure', id: 'infrastructure', }, + lastProcessed: { + defaultMessage: 'Last processed', + description: 'Last processed', + id: 'lastProcessed', + }, learnMore: { defaultMessage: 'Learn more', description: 'Learn more', diff --git a/src/routes/settings/costModels/costModel/sourcesTable.tsx b/src/routes/settings/costModels/costModel/sourcesTable.tsx index a1eca12fe..6292de580 100644 --- a/src/routes/settings/costModels/costModel/sourcesTable.tsx +++ b/src/routes/settings/costModels/costModel/sourcesTable.tsx @@ -25,7 +25,7 @@ interface SourcesTableStateProps { type SourcesTableProps = SourcesTableOwnProps & SourcesTableStateProps & WrappedComponentProps; const SourcesTable: React.FC = ({ canWrite, costModels, intl, showDeleteDialog }) => { - const rows: (IRow | string[])[] = costModels.length > 0 ? costModels[0].sources.map(source => [source.name]) : []; + const rows: (IRow | string[])[] = costModels.length > 0 ? costModels[0].sources : []; return ( = ({ canWrite, costModels, intl, {intl.formatMessage(messages.names, { count: 1 })} + {intl.formatMessage(messages.lastProcessed)} - {rows.map((r: any, rowIndex) => ( + {rows.map((row: any, rowIndex) => ( - {r} + {row.name} + + {intl.formatDate(row.last_processed, { + day: 'numeric', + hour: 'numeric', + hour12: false, + minute: 'numeric', + month: 'short', + timeZone: 'UTC', + timeZoneName: 'short', + year: 'numeric', + })} +