Skip to content

Commit

Permalink
Merge pull request #3350 from dlabrecq/source_type
Browse files Browse the repository at this point in the history
Source type
  • Loading branch information
dlabrecq authored Aug 18, 2023
2 parents c8deea4 + 1ae3ce8 commit 10f8b36
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 14 deletions.
6 changes: 6 additions & 0 deletions locales/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -9609,6 +9609,12 @@
"value": "Infrastructure"
}
],
"lastProcessed": [
{
"type": 0,
"value": "Last processed"
}
],
"learnMore": [
{
"type": 0,
Expand Down
1 change: 1 addition & 0 deletions locales/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/api/costModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Rate, RateRequest } from './rates';

export interface CostModelProvider {
name: string;
last_processed?: string;
uuid: string;
}

Expand Down
11 changes: 5 additions & 6 deletions src/components/featureFlags/featureFlags.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/locales/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
19 changes: 16 additions & 3 deletions src/routes/settings/costModels/costModel/sourcesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface SourcesTableStateProps {
type SourcesTableProps = SourcesTableOwnProps & SourcesTableStateProps & WrappedComponentProps;

const SourcesTable: React.FC<SourcesTableProps> = ({ 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 (
<TableComposable
Expand All @@ -36,13 +36,26 @@ const SourcesTable: React.FC<SourcesTableProps> = ({ canWrite, costModels, intl,
<Thead>
<Tr>
<Th>{intl.formatMessage(messages.names, { count: 1 })}</Th>
<Th>{intl.formatMessage(messages.lastProcessed)}</Th>
<Th></Th>
</Tr>
</Thead>
<Tbody>
{rows.map((r: any, rowIndex) => (
{rows.map((row: any, rowIndex) => (
<Tr key={rowIndex}>
<Td>{r}</Td>
<Td>{row.name}</Td>
<Td>
{intl.formatDate(row.last_processed, {
day: 'numeric',
hour: 'numeric',
hour12: false,
minute: 'numeric',
month: 'short',
timeZone: 'UTC',
timeZoneName: 'short',
year: 'numeric',
})}
</Td>
<Td isActionCell>
<ReadOnlyTooltip key="action" isDisabled={!canWrite}>
<Button
Expand Down
4 changes: 2 additions & 2 deletions src/routes/settings/tagDetails/tagTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class TagTableBase extends React.Component<TagTableProps, TagTableState> {
...(tags.length && { isSortable: true }),
},
{
orderBy: 'provider_type',
orderBy: 'source_type',
name: intl.formatMessage(messages.sourceType),
...(tags.length && { isSortable: true }),
},
Expand All @@ -95,7 +95,7 @@ class TagTableBase extends React.Component<TagTableProps, TagTableState> {
),
},
{
value: intl.formatMessage(messages.sourceTypes, { value: item.provider_type.toLowerCase() }),
value: intl.formatMessage(messages.sourceTypes, { value: item?.source_type?.toLowerCase() }),
},
],
item,
Expand Down
4 changes: 1 addition & 3 deletions src/routes/settings/tagDetails/tagToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ export class TagToolbarBase extends React.Component<TagToolbarProps, TagToolbarS
name: intl.formatMessage(messages.filterByValues, { value: 'name' }),
},
{
ariaLabelKey: 'source_type',
placeholderKey: 'source_type',
key: 'provider_type',
key: 'source_type',
name: intl.formatMessage(messages.filterByValues, { value: 'source_type' }),
selectClassName: 'selectOverride', // A selector from routes/components/dataToolbar/dataToolbar.scss
selectOptions: [
Expand Down

0 comments on commit 10f8b36

Please sign in to comment.