Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/prod-beta' into prod-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
dlabrecq committed Dec 3, 2021
2 parents 192941a + d9f3cf6 commit c1c1da6
Show file tree
Hide file tree
Showing 50 changed files with 820 additions and 264 deletions.
363 changes: 311 additions & 52 deletions locales/data.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion locales/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"Back": "Back",
"BreakdownBackToDetails": "{groupBy, select, account {Back to {value} account details} cluster {Back to {value} cluster details} gcp_project {Back to {value} GCP project details} instance_type {Back to {value} instance type details} node {Back to {value} node details} org_unit_id {Back to {value} organizational unit details} project {Back to {value} project details} region {Back to {value} region details} resource_location {Back to {value} region details} service {Back to {value} service details} service_name {Back to {value} service details} subscription_guid {Back to {value} account details} tag {Back to {value} tag details} other {}}",
"BreakdownBackToDetailsAriaLabel": "Back to details",
"BreakdownBackToTitles": "{value, select, aws {Amazon Web Services} azure {Microsoft Azure} gcp {Google Cloud Platform} ibm {IBM Cloud - Top 5 Costliest} ocp {OpenShift} other {}}",
"BreakdownCostBreakdownAriaLabel": "A description of markup, raw cost and usage cost",
"BreakdownCostBreakdownTitle": "Cost breakdown",
"BreakdownCostChartAriaDesc": "Breakdown of markup, raw, and usage costs",
Expand Down Expand Up @@ -233,7 +234,7 @@
"ExportAll": "All",
"ExportDownload": "Generate and download",
"ExportError": "Something went wrong, please try fewer selections",
"ExportFileName": "{groupBy, select, account {{resolution, select, daily {{provider}-accounts-daily-{date}} monthly {{provider}-accounts-monthly-{date}} other {}}} cluster {{resolution, select, daily {{provider}-clusters-daily-{date}} monthly {{provider}-clusters-monthly-{date}} other {}}} gcp_project {{resolution, select, daily {{provider}-gcp-projects-daily-{date}} monthly {{provider}-gcp-projects-monthly-{date}} other {}}} instance_type {{resolution, select, daily {{provider}-instances-daily-{date}} monthly {{provider}-instances-monthly-{date}} other {}}} node {{resolution, select, daily {{provider}-node-daily-{date}} monthly {{provider}-node-monthly-{date}} other {}}} org_unit_id {{resolution, select, daily {{provider}-org_units-daily-{date}} monthly {{provider}-org_units-monthly-{date}} other {}}} project {{resolution, select, daily {{provider}-projects-daily-{date}} monthly {{provider}-projects-monthly-{date}} other {}}} region {{resolution, select, daily {{provider}-regions-daily-{date}} monthly {{provider}-regions-monthly-{date}} other {}}} resource_location {{resolution, select, daily {{provider}-regions-daily-{date}} monthly {{provider}-regions-monthly-{date}} other {}}} service {{resolution, select, daily {{provider}-services-daily-{date}} monthly {{provider}-services-monthly-{date}} other {}}} service_name {{resolution, select, daily {{provider}-services-daily-{date}} monthly {{provider}-services-monthly-{date}} other {}}} subscription_guid {{resolution, select, daily {{provider}-accounts-daily-{date}} monthly {{provider}-accounts-monthly-{date}} other {}}} tag {{resolution, select, daily {{provider}-tags-daily-{date}} monthly {{provider}-tags-monthly-{date}} other {}}} other {}}",
"ExportFileName": "{groupBy, select, account {{resolution, select, daily {{provider}_accounts_daily_{startDate}_{endDate}} monthly {{provider}_accounts_monthly_{startDate}_{endDate}} other {}}} cluster {{resolution, select, daily {{provider}_clusters_daily_{startDate}_{endDate}} monthly {{provider}_clusters_monthly_{startDate}_{endDate}} other {}}} gcp_project {{resolution, select, daily {{provider}_gcp-projects_daily_{startDate}_{endDate}} monthly {{provider}_gcp-projects_monthly_{startDate}_{endDate}} other {}}} instance_type {{resolution, select, daily {{provider}_instances_daily_{startDate}_{endDate}} monthly {{provider}_instances_monthly_{startDate}_{endDate}} other {}}} node {{resolution, select, daily {{provider}_node_daily_{startDate}_{endDate}} monthly {{provider}_node_monthly_{startDate}_{endDate}} other {}}} org_unit_id {{resolution, select, daily {{provider}_orgs_daily_{startDate}_{endDate}} monthly {{provider}_orgs_monthly_{startDate}_{endDate}} other {}}} project {{resolution, select, daily {{provider}_projects_daily_{startDate}_{endDate}} monthly {{provider}_projects_monthly_{startDate}_{endDate}} other {}}} region {{resolution, select, daily {{provider}_regions_daily_{startDate}_{endDate}} monthly {{provider}_regions_monthly_{startDate}_{endDate}} other {}}} resource_location {{resolution, select, daily {{provider}_regions_daily_{startDate}_{endDate}} monthly {{provider}_regions_monthly_{startDate}_{endDate}} other {}}} service {{resolution, select, daily {{provider}_services_daily_{startDate}_{endDate}} monthly {{provider}_services_monthly_{startDate}_{endDate}} other {}}} service_name {{resolution, select, daily {{provider}_services_daily_{startDate}_{endDate}} monthly {{provider}_services_monthly_{startDate}_{endDate}} other {}}} subscription_guid {{resolution, select, daily {{provider}_accounts_daily_{startDate}_{endDate}} monthly {{provider}_accounts_monthly_{startDate}_{endDate}} other {}}} tag {{resolution, select, daily {{provider}_tags_daily_{startDate}_{endDate}} monthly {{provider}_tags_monthly_{startDate}_{endDate}} other {}}} other {}}",
"ExportHeading": "{groupBy, select, account {Aggregates of the following accounts will be exported to a .csv file.} cluster {Aggregates of the following clusters will be exported to a .csv file.} gcp_project {Aggregates of the following GCP projects will be exported to a .csv file.} instance_type {Aggregates of the following instance types will be exported to a .csv file.} node {Aggregates of the following nodes will be exported to a .csv file.} org_unit_id {Aggregates of the following organizational units will be exported to a .csv file.} project {Aggregates of the following projects will be exported to a .csv file.} region {Aggregates of the following regions will be exported to a .csv file.} resource_location {Aggregates of the regions will be exported to a .csv file.} service {Aggregates of the following services will be exported to a .csv file.} service_name {Aggregates of the following services will be exported to a .csv file.} subscription_guid {Aggregates of the following accounts will be exported to a .csv file.} tag {Aggregates of the following tags will be exported to a .csv file.} other {}}",
"ExportResolution": "{value, select, daily {Daily} monthly {Monthly} other {}}",
"ExportSelected": "{groupBy, select, account {Selected accounts} cluster {Selected clusters} gcp_project {Selected GCP projects} instance_type {Selected instance types} node {Selected nodes} org_unit_id {Selected organizational units} project {Selected projects} region {Selected regions} resource_location {Selected regions} service {Selected services} service_name {Selected services} subscription_guid {Selected accounts} tag {Selected tags} other {}}",
Expand Down
7 changes: 6 additions & 1 deletion src/api/costType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ export interface CostTypeData {
name?: string;
}

export interface CostType extends PagedResponse<CostTypeData, CostTypeData> {}
export interface CostTypeMeta {
count?: string;
['cost-type']?: string;
}

export interface CostType extends PagedResponse<CostTypeData, CostTypeMeta> {}

export function fetchCostType() {
const insights = (window as any).insights;
Expand Down
2 changes: 1 addition & 1 deletion src/api/queries/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const breakdownGroupByKey = 'breakdown_group_by'; // Used to display a br
export const breakdownTitleKey = 'breakdown_title'; // Used to display a title in the breakdown header
export const orgUnitIdKey = 'org_unit_id'; // Org unit ID for group_by
export const orgUnitNameKey = 'org_unit_name'; // Org unit name for group_by
export const tagKey = 'tag'; // Tag key prefix for group_by
export const tagKey = 'tag'; // Tag key for group_by

export interface Filters {
limit?: number;
Expand Down
12 changes: 0 additions & 12 deletions src/api/reports/awsReports.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import axios from 'axios';
import { Omit } from 'react-redux';
import { isBetaFeature } from 'utils/feature';
import { getCostType } from 'utils/localStorage';

import { Report, ReportData, ReportItem, ReportItemValue, ReportMeta, ReportType, ReportValue } from './report';

Expand Down Expand Up @@ -61,15 +59,5 @@ export const ReportTypePaths: Partial<Record<ReportType, string>> = {

export function runReport(reportType: ReportType, query: string) {
const path = ReportTypePaths[reportType];

// Todo: Show in-progress features in beta environment only
if (isBetaFeature()) {
switch (reportType) {
case ReportType.cost:
case ReportType.database:
case ReportType.network:
return axios.get<AwsReport>(`${path}?cost_type=${getCostType()}&${query}`);
}
}
return axios.get<AwsReport>(`${path}?${query}`);
}
26 changes: 13 additions & 13 deletions src/locales/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1699,19 +1699,19 @@ export default defineMessages({
ExportFileName: {
defaultMessage:
'{groupBy, select, ' +
'account {{resolution, select, daily {{provider}-accounts-daily-{date}} monthly {{provider}-accounts-monthly-{date}} other {}}} ' +
'cluster {{resolution, select, daily {{provider}-clusters-daily-{date}} monthly {{provider}-clusters-monthly-{date}} other {}}} ' +
'gcp_project {{resolution, select, daily {{provider}-gcp-projects-daily-{date}} monthly {{provider}-gcp-projects-monthly-{date}} other {}}} ' +
'instance_type {{resolution, select, daily {{provider}-instances-daily-{date}} monthly {{provider}-instances-monthly-{date}} other {}}} ' +
'node {{resolution, select, daily {{provider}-node-daily-{date}} monthly {{provider}-node-monthly-{date}} other {}}} ' +
'org_unit_id {{resolution, select, daily {{provider}-org_units-daily-{date}} monthly {{provider}-org_units-monthly-{date}} other {}}} ' +
'project {{resolution, select, daily {{provider}-projects-daily-{date}} monthly {{provider}-projects-monthly-{date}} other {}}} ' +
'region {{resolution, select, daily {{provider}-regions-daily-{date}} monthly {{provider}-regions-monthly-{date}} other {}}} ' +
'resource_location {{resolution, select, daily {{provider}-regions-daily-{date}} monthly {{provider}-regions-monthly-{date}} other {}}} ' +
'service {{resolution, select, daily {{provider}-services-daily-{date}} monthly {{provider}-services-monthly-{date}} other {}}} ' +
'service_name {{resolution, select, daily {{provider}-services-daily-{date}} monthly {{provider}-services-monthly-{date}} other {}}} ' +
'subscription_guid {{resolution, select, daily {{provider}-accounts-daily-{date}} monthly {{provider}-accounts-monthly-{date}} other {}}} ' +
'tag {{resolution, select, daily {{provider}-tags-daily-{date}} monthly {{provider}-tags-monthly-{date}} other {}}} ' +
'account {{resolution, select, daily {{provider}_accounts_daily_{startDate}_{endDate}} monthly {{provider}_accounts_monthly_{startDate}_{endDate}} other {}}} ' +
'cluster {{resolution, select, daily {{provider}_clusters_daily_{startDate}_{endDate}} monthly {{provider}_clusters_monthly_{startDate}_{endDate}} other {}}} ' +
'gcp_project {{resolution, select, daily {{provider}_gcp-projects_daily_{startDate}_{endDate}} monthly {{provider}_gcp-projects_monthly_{startDate}_{endDate}} other {}}} ' +
'instance_type {{resolution, select, daily {{provider}_instances_daily_{startDate}_{endDate}} monthly {{provider}_instances_monthly_{startDate}_{endDate}} other {}}} ' +
'node {{resolution, select, daily {{provider}_node_daily_{startDate}_{endDate}} monthly {{provider}_node_monthly_{startDate}_{endDate}} other {}}} ' +
'org_unit_id {{resolution, select, daily {{provider}_orgs_daily_{startDate}_{endDate}} monthly {{provider}_orgs_monthly_{startDate}_{endDate}} other {}}} ' +
'project {{resolution, select, daily {{provider}_projects_daily_{startDate}_{endDate}} monthly {{provider}_projects_monthly_{startDate}_{endDate}} other {}}} ' +
'region {{resolution, select, daily {{provider}_regions_daily_{startDate}_{endDate}} monthly {{provider}_regions_monthly_{startDate}_{endDate}} other {}}} ' +
'resource_location {{resolution, select, daily {{provider}_regions_daily_{startDate}_{endDate}} monthly {{provider}_regions_monthly_{startDate}_{endDate}} other {}}} ' +
'service {{resolution, select, daily {{provider}_services_daily_{startDate}_{endDate}} monthly {{provider}_services_monthly_{startDate}_{endDate}} other {}}} ' +
'service_name {{resolution, select, daily {{provider}_services_daily_{startDate}_{endDate}} monthly {{provider}_services_monthly_{startDate}_{endDate}} other {}}} ' +
'subscription_guid {{resolution, select, daily {{provider}_accounts_daily_{startDate}_{endDate}} monthly {{provider}_accounts_monthly_{startDate}_{endDate}} other {}}} ' +
'tag {{resolution, select, daily {{provider}_tags_daily_{startDate}_{endDate}} monthly {{provider}_tags_monthly_{startDate}_{endDate}} other {}}} ' +
'other {}}',
description: 'Export file name',
id: 'ExportFileName',
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import React from 'react';
import { injectIntl, WrappedComponentProps } from 'react-intl';
import { connect } from 'react-redux';
import { createMapStateToProps, FetchStatus } from 'store/common';
import { costTypeActions, costTypeSelectors } from 'store/costType';
import { CostTypes, getCostType, invalidateCostType, setCostType } from 'utils/localStorage';
import { costTypeSelectors } from 'store/costType';
import { CostTypes, getCostType, setCostType } from 'utils/localStorage';

import { styles } from './costType.styles';

Expand All @@ -19,7 +19,7 @@ interface CostTypeOwnProps {
}

interface CostTypeDispatchProps {
fetchCostType?: typeof costTypeActions.fetchCostType;
// TBD...
}

interface CostTypeStateProps {
Expand All @@ -29,7 +29,6 @@ interface CostTypeStateProps {
}

interface CostTypeState {
currentItem: string;
isSelectOpen: boolean;
}

Expand All @@ -43,31 +42,17 @@ type CostTypeProps = CostTypeOwnProps & CostTypeDispatchProps & CostTypeStatePro

class CostTypeBase extends React.Component<CostTypeProps> {
protected defaultState: CostTypeState = {
currentItem: CostTypes.unblended,
isSelectOpen: false,
};
public state: CostTypeState = { ...this.defaultState };

public componentDidMount() {
const { fetchCostType } = this.props;

fetchCostType();
}

private getCurrentItem = () => {
const { currentItem } = this.state;

const costType = getCostType(); // Get currency units from local storage
return costType ? costType : currentItem;
};

private getSelect = () => {
const { isDisabled } = this.props;
const { isSelectOpen } = this.state;

const currentItem = this.getCurrentItem();
const currentCostType = getCostType(); // Get cost type from local storage
const selectOptions = this.getSelectOptions();
const selection = selectOptions.find((option: CostTypeOption) => option.value === currentItem);
const selection = selectOptions.find((option: CostTypeOption) => option.value === currentCostType);

return (
<Select
Expand Down Expand Up @@ -131,12 +116,10 @@ class CostTypeBase extends React.Component<CostTypeProps> {
private handleSelect = (event, selection: CostTypeOption) => {
const { onSelect } = this.props;

// Set currency units via local storage
setCostType(selection.value);
setCostType(selection.value); // Set cost type in local storage

this.setState(
{
currentItem: selection.value,
isSelectOpen: false,
},
() => {
Expand All @@ -154,9 +137,6 @@ class CostTypeBase extends React.Component<CostTypeProps> {
public render() {
const { intl } = this.props;

// Clear local storage value if current session is not valid
invalidateCostType();

return (
<div style={styles.costSelector}>
<Title headingLevel="h3" size="md" style={styles.costLabel}>
Expand All @@ -181,7 +161,7 @@ const mapStateToProps = createMapStateToProps<CostTypeOwnProps, CostTypeStatePro
});

const mapDispatchToProps: CostTypeDispatchProps = {
fetchCostType: costTypeActions.fetchCostType,
// TBD...
};

const CostTypeConnect = connect(mapStateToProps, mapDispatchToProps)(CostTypeBase);
Expand Down
Loading

0 comments on commit c1c1da6

Please sign in to comment.