Skip to content

Commit

Permalink
Merge pull request #3285 from dlabrecq/subscription_name
Browse files Browse the repository at this point in the history
Add support for Azure's subscription_name
  • Loading branch information
dlabrecq authored Jul 11, 2023
2 parents 5a7dde4 + 0c3c537 commit 26eba2b
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/api/queries/azureQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface AzureGroupBys {

interface AzureOrderBys {
subscription_guid?: string;
subscription_name?: string;
resource_location?: string;
service_name?: string;
cost?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/routes/details/awsDetails/detailsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class DetailsTableBase extends React.Component<DetailsTableProps, DetailsTableSt
groupByOrg,
id: item.id,
router,
title: item.label,
title: label.toString(), // Convert IDs if applicable
type: item.type,
})}
>
Expand Down
6 changes: 4 additions & 2 deletions src/routes/details/azureBreakdown/azureBreakdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { providersQuery, providersSelectors } from 'store/providers';
import { reportActions, reportSelectors } from 'store/reports';
import { getCurrency } from 'utils/localStorage';
import { formatPath } from 'utils/paths';
import { breakdownDescKey } from 'utils/props';
import { breakdownDescKey, breakdownTitleKey } from 'utils/props';
import type { RouterComponentProps } from 'utils/router';
import { withRouter } from 'utils/router';

Expand Down Expand Up @@ -86,6 +86,8 @@ const mapStateToProps = createMapStateToProps<AzureCostOwnProps, BreakdownStateP
providersQueryString
);

const title = queryFromRoute[breakdownTitleKey] ? queryFromRoute[breakdownTitleKey] : groupByValue;

return {
costOverviewComponent: <CostOverview currency={currency} groupBy={groupBy} report={report} />,
currency,
Expand All @@ -107,7 +109,7 @@ const mapStateToProps = createMapStateToProps<AzureCostOwnProps, BreakdownStateP
reportPathsType,
reportQueryString,
tagPathsType: TagPathsType.azure,
title: groupByValue,
title,
};
});

Expand Down
6 changes: 3 additions & 3 deletions src/routes/details/azureDetails/detailsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class DetailsTableBase extends React.Component<DetailsTableProps, DetailsTableSt
name: '',
},
{
orderBy: groupBy,
orderBy: groupBy === 'subscription_guid' ? 'subscription_name' : groupBy,
name: intl.formatMessage(messages.detailsResourceNames, { value: groupBy }),
...(computedItems.length && { isSortable: true }),
},
Expand All @@ -123,7 +123,7 @@ class DetailsTableBase extends React.Component<DetailsTableProps, DetailsTableSt

computedItems.map((item, index) => {
const cost = this.getTotalCost(item, index);
const label = item && item.label !== null ? item.label : '';
const label = item && item.label && item.label !== null ? item.label : '';
const monthOverMonth = this.getMonthOverMonthCost(item, index);
const isDisabled = label === `${noPrefix}${groupBy}` || label === `${noPrefix}${groupByTagKey}`;
const desc = item.id && item.id !== item.label ? <div style={styles.infoDescription}>{item.id}</div> : null;
Expand All @@ -139,7 +139,7 @@ class DetailsTableBase extends React.Component<DetailsTableProps, DetailsTableSt
groupBy,
id: item.id,
router,
title: label.toString(),
title: label.toString(), // Convert IDs if applicable
})}
>
{label}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/details/gcpDetails/detailsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class DetailsTableBase extends React.Component<DetailsTableProps, DetailsTableSt
groupBy,
id: item.id,
router,
title: label.toString(),
title: label.toString(), // Convert IDs if applicable
})}
>
{label}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/details/ibmDetails/detailsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class DetailsTableBase extends React.Component<DetailsTableProps, DetailsTableSt
groupBy,
id: item.id,
router,
title: label.toString(),
title: label.toString(), // Convert IDs if applicable
})}
>
{label}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/details/ociDetails/detailsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class DetailsTableBase extends React.Component<DetailsTableProps, DetailsTableSt
groupBy,
id: item.id,
router,
title: label.toString(),
title: label.toString(), // Convert IDs if applicable
})}
>
{label}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/details/ocpDetails/detailsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class DetailsTableBase extends React.Component<DetailsTableProps, DetailsTableSt
isPlatformCosts,
groupBy,
router,
title: label.toString(),
title: label.toString(), // Convert IDs if applicable
})}
>
{label}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/details/rhelDetails/detailsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class DetailsTableBase extends React.Component<DetailsTableProps, DetailsTableSt
groupBy,
id: item.id,
router,
title: label.toString(),
title: label.toString(), // Convert IDs if applicable
})}
>
{label}
Expand Down
11 changes: 9 additions & 2 deletions src/routes/explorer/explorerTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ class ExplorerTableBase extends React.Component<ExplorerTableProps, ExplorerTabl
: groupBy,
});

let orderBy = groupBy;
if (perspective === PerspectiveType.aws || perspective === PerspectiveType.awsOcp) {
orderBy = groupBy === 'account' ? 'account_alias' : groupBy;
} else if (perspective === PerspectiveType.azure || perspective === PerspectiveType.azureOcp) {
orderBy = groupBy === 'subscription_guid' ? 'subscription_name' : groupBy;
}

// Add first two column headings (i.e., select and name)
const columns =
groupByCostCategory || groupByTagKey || groupByOrg
Expand All @@ -167,7 +174,7 @@ class ExplorerTableBase extends React.Component<ExplorerTableProps, ExplorerTabl
{
date: undefined,
name: intl.formatMessage(messages.groupByValueNames, { groupBy }),
orderBy: groupBy === 'account' && perspective === PerspectiveType.aws ? 'account_alias' : groupBy,
orderBy,
...(computedItems.length && { isSortable: true }),
},
{
Expand Down Expand Up @@ -218,7 +225,7 @@ class ExplorerTableBase extends React.Component<ExplorerTableProps, ExplorerTabl
// Sort by date and fill in missing cells
computedItems.map(rowItem => {
const cells = [];
let desc; // First column description (i.e., show ID if different than label)
let desc; // First column description (i.e., show ID if different from label)
let name; // For first column resource name
let selectItem; // Save for row selection
let isOverheadCosts = false; // True if item has overhead costs
Expand Down
2 changes: 2 additions & 0 deletions src/routes/utils/computedReport/getComputedReportItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ export function getUnsortedComputedReportItems<R extends Report, T extends Repor
label = val.account_alias;
} else if (itemLabelKey === 'cluster' && cluster_alias) {
label = cluster_alias;
} else if (itemLabelKey === 'subscription_guid' && val.subscription_name) {
label = val.subscription_name;
} else if (val[itemLabelKey] instanceof Object) {
label = val[itemLabelKey].value;
} else {
Expand Down

0 comments on commit 26eba2b

Please sign in to comment.