From 8d0609fab80bb6198166d65ccd63756f9600e050 Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Tue, 4 Apr 2023 12:43:22 -0400 Subject: [PATCH 1/2] Revert previous API change to call insights.chrome.auth.getUser --- src/api/accountSettings.ts | 10 +---- src/api/costModels.ts | 45 +++---------------- src/api/export/awsExport.ts | 18 +++----- src/api/export/awsOcpExport.ts | 18 +++----- src/api/export/azureExport.ts | 18 +++----- src/api/export/azureOcpExport.ts | 18 +++----- src/api/export/gcpExport.ts | 18 +++----- src/api/export/gcpOcpExport.ts | 18 +++----- src/api/export/ibmExport.ts | 18 +++----- src/api/export/ociExport.ts | 18 +++----- src/api/export/ocpCloudExport.ts | 18 +++----- src/api/export/ocpExport.ts | 18 +++----- src/api/export/rhelExport.ts | 18 +++----- src/api/forecasts/awsForecast.ts | 9 +--- src/api/forecasts/awsOcpForecast.ts | 9 +--- src/api/forecasts/azureForecast.ts | 9 +--- src/api/forecasts/azureOcpForecast.ts | 9 +--- src/api/forecasts/gcpForecast.ts | 9 +--- src/api/forecasts/gcpOcpForecast.ts | 9 +--- src/api/forecasts/ibmForecast.ts | 9 +--- src/api/forecasts/ociForecast.ts | 9 +--- src/api/forecasts/ocpCloudForecast.ts | 9 +--- src/api/forecasts/ocpForecast.ts | 9 +--- src/api/forecasts/rhelForecast.ts | 9 +--- src/api/metrics.ts | 9 +--- src/api/orgs/awsOrgs.ts | 9 +--- src/api/providers.ts | 9 +--- src/api/rates.ts | 9 +--- src/api/rbac.ts | 16 +++---- src/api/reports/awsOcpReports.ts | 9 +--- src/api/reports/awsReports.ts | 9 +--- src/api/reports/azureOcpReports.ts | 9 +--- src/api/reports/azureReports.ts | 9 +--- src/api/reports/gcpOcpReports.ts | 9 +--- src/api/reports/gcpReports.ts | 9 +--- src/api/reports/ibmReports.ts | 9 +--- src/api/reports/ociReports.ts | 9 +--- src/api/reports/ocpCloudReports.ts | 9 +--- src/api/reports/ocpReports.ts | 9 +--- src/api/reports/rhelReports.ts | 9 +--- src/api/resources/awsOcpResource.ts | 9 +--- src/api/resources/awsResource.ts | 9 +--- src/api/resources/azureOcpResource.ts | 9 +--- src/api/resources/azureResource.ts | 9 +--- src/api/resources/gcpOcpResource.ts | 9 +--- src/api/resources/gcpResource.ts | 9 +--- src/api/resources/ibmResource.ts | 9 +--- src/api/resources/ociResource.ts | 9 +--- src/api/resources/ocpResource.ts | 9 +--- src/api/resources/rhelResource.ts | 9 +--- src/api/ros/recommendations.ts | 9 +--- src/api/tags/awsOcpTags.ts | 9 +--- src/api/tags/awsTags.ts | 9 +--- src/api/tags/azureOcpTags.ts | 9 +--- src/api/tags/azureTags.ts | 9 +--- src/api/tags/gcpOcpTags.ts | 9 +--- src/api/tags/gcpTags.ts | 9 +--- src/api/tags/ibmTags.ts | 9 +--- src/api/tags/ociTags.ts | 9 +--- src/api/tags/ocpCloudTags.ts | 9 +--- src/api/tags/ocpTags.ts | 9 +--- src/api/tags/rhelTags.ts | 9 +--- src/api/userAccess.ts | 11 +---- .../accountSettings/accountSettingsActions.ts | 3 +- src/store/providers/providersActions.ts | 3 +- src/store/sourceSettings/actions.ts | 3 +- src/store/userAccess/userAccessActions.ts | 3 +- 67 files changed, 127 insertions(+), 597 deletions(-) diff --git a/src/api/accountSettings.ts b/src/api/accountSettings.ts index 44845036c..965f950ff 100644 --- a/src/api/accountSettings.ts +++ b/src/api/accountSettings.ts @@ -1,7 +1,6 @@ import axios from 'axios'; import type { PagedLinks, PagedMetaData } from './api'; -import type { AwsOcpTag } from './tags/awsOcpTags'; export interface AccountSettingsData { cost_type?: string; @@ -15,12 +14,5 @@ export interface AccountSettings { } export function fetchAccountSettings() { - const fetch = () => axios.get(`account-settings/`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`account-settings/`); } diff --git a/src/api/costModels.ts b/src/api/costModels.ts index 7610ce75d..870ca960e 100644 --- a/src/api/costModels.ts +++ b/src/api/costModels.ts @@ -40,56 +40,21 @@ export interface CostModelRequest { export type CostModels = PagedResponse; export function fetchCostModels(query = '') { - const fetch = () => axios.get(`cost-models/${query && '?'}${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`cost-models/${query && '?'}${query}`); } export function fetchCostModel(uuid: string) { - const fetch = () => axios.get(`cost-models/${uuid}/`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`cost-models/${uuid}/`); } export function addCostModel(request: CostModelRequest) { - const fetch = () => axios.post(`cost-models/`, request); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.post(`cost-models/`, request); } export function updateCostModel(uuid: string, request: CostModelRequest) { - const fetch = () => axios.put(`cost-models/${uuid}/`, request); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.put(`cost-models/${uuid}/`, request); } export function deleteCostModel(uuid: string) { - const fetch = () => axios.delete(`cost-models/${uuid}/`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.delete(`cost-models/${uuid}/`); } diff --git a/src/api/export/awsExport.ts b/src/api/export/awsExport.ts index 697069547..e6be010f5 100644 --- a/src/api/export/awsExport.ts +++ b/src/api/export/awsExport.ts @@ -4,17 +4,9 @@ import axios from 'axios'; export function runExport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => - axios.get(`${path}?${query}`, { - headers: { - Accept: 'text/csv', - }, - }); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`, { + headers: { + Accept: 'text/csv', + }, + }); } diff --git a/src/api/export/awsOcpExport.ts b/src/api/export/awsOcpExport.ts index f704a2d63..d9477d722 100644 --- a/src/api/export/awsOcpExport.ts +++ b/src/api/export/awsOcpExport.ts @@ -4,17 +4,9 @@ import axios from 'axios'; export function runExport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => - axios.get(`${path}?${query}`, { - headers: { - Accept: 'text/csv', - }, - }); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`, { + headers: { + Accept: 'text/csv', + }, + }); } diff --git a/src/api/export/azureExport.ts b/src/api/export/azureExport.ts index e9b67320e..db7f29443 100644 --- a/src/api/export/azureExport.ts +++ b/src/api/export/azureExport.ts @@ -4,17 +4,9 @@ import axios from 'axios'; export function runExport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => - axios.get(`${path}?${query}`, { - headers: { - Accept: 'text/csv', - }, - }); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`, { + headers: { + Accept: 'text/csv', + }, + }); } diff --git a/src/api/export/azureOcpExport.ts b/src/api/export/azureOcpExport.ts index 5a36ba35e..6c71025ba 100644 --- a/src/api/export/azureOcpExport.ts +++ b/src/api/export/azureOcpExport.ts @@ -4,17 +4,9 @@ import axios from 'axios'; export function runExport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => - axios.get(`${path}?${query}`, { - headers: { - Accept: 'text/csv', - }, - }); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`, { + headers: { + Accept: 'text/csv', + }, + }); } diff --git a/src/api/export/gcpExport.ts b/src/api/export/gcpExport.ts index 1b8d1a68f..681905dc5 100644 --- a/src/api/export/gcpExport.ts +++ b/src/api/export/gcpExport.ts @@ -4,17 +4,9 @@ import axios from 'axios'; export function runExport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => - axios.get(`${path}?${query}`, { - headers: { - Accept: 'text/csv', - }, - }); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`, { + headers: { + Accept: 'text/csv', + }, + }); } diff --git a/src/api/export/gcpOcpExport.ts b/src/api/export/gcpOcpExport.ts index 931d94ab7..afeaf9179 100644 --- a/src/api/export/gcpOcpExport.ts +++ b/src/api/export/gcpOcpExport.ts @@ -4,17 +4,9 @@ import axios from 'axios'; export function runExport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => - axios.get(`${path}?${query}`, { - headers: { - Accept: 'text/csv', - }, - }); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`, { + headers: { + Accept: 'text/csv', + }, + }); } diff --git a/src/api/export/ibmExport.ts b/src/api/export/ibmExport.ts index a888f2843..3b2fd25c7 100644 --- a/src/api/export/ibmExport.ts +++ b/src/api/export/ibmExport.ts @@ -4,17 +4,9 @@ import axios from 'axios'; export function runExport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => - axios.get(`${path}?${query}`, { - headers: { - Accept: 'text/csv', - }, - }); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`, { + headers: { + Accept: 'text/csv', + }, + }); } diff --git a/src/api/export/ociExport.ts b/src/api/export/ociExport.ts index c8fe7d6ee..807d447ae 100644 --- a/src/api/export/ociExport.ts +++ b/src/api/export/ociExport.ts @@ -4,17 +4,9 @@ import axios from 'axios'; export function runExport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => - axios.get(`${path}?${query}`, { - headers: { - Accept: 'text/csv', - }, - }); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`, { + headers: { + Accept: 'text/csv', + }, + }); } diff --git a/src/api/export/ocpCloudExport.ts b/src/api/export/ocpCloudExport.ts index f0b431aab..35b5b193d 100644 --- a/src/api/export/ocpCloudExport.ts +++ b/src/api/export/ocpCloudExport.ts @@ -4,17 +4,9 @@ import axios from 'axios'; export function runExport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => - axios.get(`${path}?${query}`, { - headers: { - Accept: 'text/csv', - }, - }); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`, { + headers: { + Accept: 'text/csv', + }, + }); } diff --git a/src/api/export/ocpExport.ts b/src/api/export/ocpExport.ts index aeb49675d..8037d8d1d 100644 --- a/src/api/export/ocpExport.ts +++ b/src/api/export/ocpExport.ts @@ -4,17 +4,9 @@ import axios from 'axios'; export function runExport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => - axios.get(`${path}?${query}`, { - headers: { - Accept: 'text/csv', - }, - }); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`, { + headers: { + Accept: 'text/csv', + }, + }); } diff --git a/src/api/export/rhelExport.ts b/src/api/export/rhelExport.ts index aeb49675d..8037d8d1d 100644 --- a/src/api/export/rhelExport.ts +++ b/src/api/export/rhelExport.ts @@ -4,17 +4,9 @@ import axios from 'axios'; export function runExport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => - axios.get(`${path}?${query}`, { - headers: { - Accept: 'text/csv', - }, - }); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`, { + headers: { + Accept: 'text/csv', + }, + }); } diff --git a/src/api/forecasts/awsForecast.ts b/src/api/forecasts/awsForecast.ts index 189b0d96a..6c0a5b2a5 100644 --- a/src/api/forecasts/awsForecast.ts +++ b/src/api/forecasts/awsForecast.ts @@ -9,12 +9,5 @@ export const ForecastTypePaths: Partial> = { export function runForecast(forecastType: ForecastType, query: string) { const path = ForecastTypePaths[forecastType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/forecasts/awsOcpForecast.ts b/src/api/forecasts/awsOcpForecast.ts index 4cd3a0731..0c85cdac6 100644 --- a/src/api/forecasts/awsOcpForecast.ts +++ b/src/api/forecasts/awsOcpForecast.ts @@ -9,12 +9,5 @@ export const ForecastTypePaths: Partial> = { export function runForecast(forecastType: ForecastType, query: string) { const path = ForecastTypePaths[forecastType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/forecasts/azureForecast.ts b/src/api/forecasts/azureForecast.ts index 00467ae87..a4493d6eb 100644 --- a/src/api/forecasts/azureForecast.ts +++ b/src/api/forecasts/azureForecast.ts @@ -9,12 +9,5 @@ export const ForecastTypePaths: Partial> = { export function runForecast(forecastType: ForecastType, query: string) { const path = ForecastTypePaths[forecastType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/forecasts/azureOcpForecast.ts b/src/api/forecasts/azureOcpForecast.ts index a090a268c..8887594de 100644 --- a/src/api/forecasts/azureOcpForecast.ts +++ b/src/api/forecasts/azureOcpForecast.ts @@ -9,12 +9,5 @@ export const ForecastTypePaths: Partial> = { export function runForecast(forecastType: ForecastType, query: string) { const path = ForecastTypePaths[forecastType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/forecasts/gcpForecast.ts b/src/api/forecasts/gcpForecast.ts index fe22a3bd1..9eb6900d1 100644 --- a/src/api/forecasts/gcpForecast.ts +++ b/src/api/forecasts/gcpForecast.ts @@ -9,12 +9,5 @@ export const ForecastTypePaths: Partial> = { export function runForecast(forecastType: ForecastType, query: string) { const path = ForecastTypePaths[forecastType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/forecasts/gcpOcpForecast.ts b/src/api/forecasts/gcpOcpForecast.ts index 169d04035..1670d7517 100644 --- a/src/api/forecasts/gcpOcpForecast.ts +++ b/src/api/forecasts/gcpOcpForecast.ts @@ -9,12 +9,5 @@ export const ForecastTypePaths: Partial> = { export function runForecast(forecastType: ForecastType, query: string) { const path = ForecastTypePaths[forecastType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/forecasts/ibmForecast.ts b/src/api/forecasts/ibmForecast.ts index 4aed9a3d4..cfaf92f49 100644 --- a/src/api/forecasts/ibmForecast.ts +++ b/src/api/forecasts/ibmForecast.ts @@ -9,12 +9,5 @@ export const ForecastTypePaths: Partial> = { export function runForecast(forecastType: ForecastType, query: string) { const path = ForecastTypePaths[forecastType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/forecasts/ociForecast.ts b/src/api/forecasts/ociForecast.ts index 98f41acdf..1c1c235e5 100644 --- a/src/api/forecasts/ociForecast.ts +++ b/src/api/forecasts/ociForecast.ts @@ -9,12 +9,5 @@ export const ForecastTypePaths: Partial> = { export function runForecast(forecastType: ForecastType, query: string) { const path = ForecastTypePaths[forecastType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/forecasts/ocpCloudForecast.ts b/src/api/forecasts/ocpCloudForecast.ts index 78a1df138..09fa519de 100644 --- a/src/api/forecasts/ocpCloudForecast.ts +++ b/src/api/forecasts/ocpCloudForecast.ts @@ -9,12 +9,5 @@ export const ForecastTypePaths: Partial> = { export function runForecast(forecastType: ForecastType, query: string) { const path = ForecastTypePaths[forecastType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/forecasts/ocpForecast.ts b/src/api/forecasts/ocpForecast.ts index 5469f91a5..57bbf1fd4 100644 --- a/src/api/forecasts/ocpForecast.ts +++ b/src/api/forecasts/ocpForecast.ts @@ -11,12 +11,5 @@ export const ForecastTypePaths: Partial> = { export function runForecast(forecastType: ForecastType, query: string) { const path = ForecastTypePaths[forecastType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/forecasts/rhelForecast.ts b/src/api/forecasts/rhelForecast.ts index 5469f91a5..57bbf1fd4 100644 --- a/src/api/forecasts/rhelForecast.ts +++ b/src/api/forecasts/rhelForecast.ts @@ -11,12 +11,5 @@ export const ForecastTypePaths: Partial> = { export function runForecast(forecastType: ForecastType, query: string) { const path = ForecastTypePaths[forecastType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/metrics.ts b/src/api/metrics.ts index e3ed108fb..c56e8af0b 100644 --- a/src/api/metrics.ts +++ b/src/api/metrics.ts @@ -20,12 +20,5 @@ export type Metrics = PagedResponse; export function fetchRateMetrics(source_type = '') { const query = source_type ? `&source_type=${source_type}` : ''; - const fetch = () => axios.get(`metrics/?limit=20${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`metrics/?limit=20${query}`); } diff --git a/src/api/orgs/awsOrgs.ts b/src/api/orgs/awsOrgs.ts index 9456aaf0f..ab871d9c4 100644 --- a/src/api/orgs/awsOrgs.ts +++ b/src/api/orgs/awsOrgs.ts @@ -11,12 +11,5 @@ export const OrgTypePaths: Partial> = { export function runOrg(orgType: OrgType, query: string) { const path = OrgTypePaths[orgType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/providers.ts b/src/api/providers.ts index f3062968f..c3fd10a3a 100644 --- a/src/api/providers.ts +++ b/src/api/providers.ts @@ -70,12 +70,5 @@ export const enum ProviderType { export function fetchProviders(query: string) { const queryString = query ? `?${query}` : ''; - const fetch = () => axios.get(`sources/${queryString}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`sources/${queryString}`); } diff --git a/src/api/rates.ts b/src/api/rates.ts index 832409dbb..6458ef7ce 100644 --- a/src/api/rates.ts +++ b/src/api/rates.ts @@ -47,12 +47,5 @@ export type Rates = PagedResponse; export function fetchRate(uuid = null) { const query = uuid ? `?source_uuid=${uuid}` : ''; - const fetch = () => axios.get(`cost-models/${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`cost-models/${query}`); } diff --git a/src/api/rbac.ts b/src/api/rbac.ts index 4486a4cd3..5645dca40 100644 --- a/src/api/rbac.ts +++ b/src/api/rbac.ts @@ -6,16 +6,16 @@ export interface RBAC { } export async function getRBAC(): Promise { - const _insights = (window as any).insights; + const insights = (window as any).insights; if ( - _insights && - _insights.chrome && - _insights.chrome.auth && - _insights.chrome.auth.getUser && - _insights.chrome.getUserPermissions + insights && + insights.chrome && + insights.chrome.auth && + insights.chrome.auth.getUser && + insights.chrome.getUserPermissions ) { - const user = await _insights.chrome.auth.getUser(); - const permissions = await _insights.chrome.getUserPermissions(); + const user = await insights.chrome.auth.getUser(); + const permissions = await insights.chrome.getUserPermissions(); return { isOrgAdmin: user.identity.user.is_org_admin, permissions, diff --git a/src/api/reports/awsOcpReports.ts b/src/api/reports/awsOcpReports.ts index 73d93a09f..dec91de52 100644 --- a/src/api/reports/awsOcpReports.ts +++ b/src/api/reports/awsOcpReports.ts @@ -52,12 +52,5 @@ export const ReportTypePaths: Partial> = { export function runReport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/reports/awsReports.ts b/src/api/reports/awsReports.ts index 05001c738..70a02aeef 100644 --- a/src/api/reports/awsReports.ts +++ b/src/api/reports/awsReports.ts @@ -53,12 +53,5 @@ export const ReportTypePaths: Partial> = { export function runReport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/reports/azureOcpReports.ts b/src/api/reports/azureOcpReports.ts index a87f2045f..5fe18ce67 100644 --- a/src/api/reports/azureOcpReports.ts +++ b/src/api/reports/azureOcpReports.ts @@ -51,12 +51,5 @@ export const ReportTypePaths: Partial> = { export function runReport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/reports/azureReports.ts b/src/api/reports/azureReports.ts index 887094ec0..0c11910fd 100644 --- a/src/api/reports/azureReports.ts +++ b/src/api/reports/azureReports.ts @@ -52,12 +52,5 @@ export const ReportTypePaths: Partial> = { export function runReport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/reports/gcpOcpReports.ts b/src/api/reports/gcpOcpReports.ts index 9f4b2644f..0672cf4d3 100644 --- a/src/api/reports/gcpOcpReports.ts +++ b/src/api/reports/gcpOcpReports.ts @@ -57,12 +57,5 @@ export const ReportTypePaths: Partial> = { export function runReport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/reports/gcpReports.ts b/src/api/reports/gcpReports.ts index 9be0fe899..dafe6fb71 100644 --- a/src/api/reports/gcpReports.ts +++ b/src/api/reports/gcpReports.ts @@ -58,12 +58,5 @@ export const ReportTypePaths: Partial> = { export function runReport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/reports/ibmReports.ts b/src/api/reports/ibmReports.ts index 483ee9688..65784773a 100644 --- a/src/api/reports/ibmReports.ts +++ b/src/api/reports/ibmReports.ts @@ -58,12 +58,5 @@ export const ReportTypePaths: Partial> = { export function runReport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/reports/ociReports.ts b/src/api/reports/ociReports.ts index cac5067a8..cae71bde8 100644 --- a/src/api/reports/ociReports.ts +++ b/src/api/reports/ociReports.ts @@ -52,12 +52,5 @@ export const ReportTypePaths: Partial> = { export function runReport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/reports/ocpCloudReports.ts b/src/api/reports/ocpCloudReports.ts index c4004b540..2670cdf94 100644 --- a/src/api/reports/ocpCloudReports.ts +++ b/src/api/reports/ocpCloudReports.ts @@ -81,12 +81,5 @@ export const ReportTypePaths: Partial> = { export function runReport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/reports/ocpReports.ts b/src/api/reports/ocpReports.ts index f055e40dc..deb0e38ab 100644 --- a/src/api/reports/ocpReports.ts +++ b/src/api/reports/ocpReports.ts @@ -57,12 +57,5 @@ export const ReportTypePaths: Partial> = { export function runReport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/reports/rhelReports.ts b/src/api/reports/rhelReports.ts index fdaebd632..509b082d2 100644 --- a/src/api/reports/rhelReports.ts +++ b/src/api/reports/rhelReports.ts @@ -57,12 +57,5 @@ export const ReportTypePaths: Partial> = { export function runReport(reportType: ReportType, query: string) { const path = ReportTypePaths[reportType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/resources/awsOcpResource.ts b/src/api/resources/awsOcpResource.ts index 62b77a7aa..b98a061ba 100644 --- a/src/api/resources/awsOcpResource.ts +++ b/src/api/resources/awsOcpResource.ts @@ -11,12 +11,5 @@ export const ResourceTypePaths: Partial> = { export function runResource(resourceType: ResourceType, query: string) { const path = ResourceTypePaths[resourceType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/resources/awsResource.ts b/src/api/resources/awsResource.ts index 62b77a7aa..b98a061ba 100644 --- a/src/api/resources/awsResource.ts +++ b/src/api/resources/awsResource.ts @@ -11,12 +11,5 @@ export const ResourceTypePaths: Partial> = { export function runResource(resourceType: ResourceType, query: string) { const path = ResourceTypePaths[resourceType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/resources/azureOcpResource.ts b/src/api/resources/azureOcpResource.ts index 96199cab7..75181e862 100644 --- a/src/api/resources/azureOcpResource.ts +++ b/src/api/resources/azureOcpResource.ts @@ -11,12 +11,5 @@ export const ResourceTypePaths: Partial> = { export function runResource(resourceType: ResourceType, query: string) { const path = ResourceTypePaths[resourceType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/resources/azureResource.ts b/src/api/resources/azureResource.ts index 96199cab7..75181e862 100644 --- a/src/api/resources/azureResource.ts +++ b/src/api/resources/azureResource.ts @@ -11,12 +11,5 @@ export const ResourceTypePaths: Partial> = { export function runResource(resourceType: ResourceType, query: string) { const path = ResourceTypePaths[resourceType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/resources/gcpOcpResource.ts b/src/api/resources/gcpOcpResource.ts index 864fe755f..05e082ac5 100644 --- a/src/api/resources/gcpOcpResource.ts +++ b/src/api/resources/gcpOcpResource.ts @@ -12,12 +12,5 @@ export const ResourceTypePaths: Partial> = { export function runResource(resourceType: ResourceType, query: string) { const path = ResourceTypePaths[resourceType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/resources/gcpResource.ts b/src/api/resources/gcpResource.ts index 864fe755f..05e082ac5 100644 --- a/src/api/resources/gcpResource.ts +++ b/src/api/resources/gcpResource.ts @@ -12,12 +12,5 @@ export const ResourceTypePaths: Partial> = { export function runResource(resourceType: ResourceType, query: string) { const path = ResourceTypePaths[resourceType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/resources/ibmResource.ts b/src/api/resources/ibmResource.ts index 033cd9bd7..887a98a00 100644 --- a/src/api/resources/ibmResource.ts +++ b/src/api/resources/ibmResource.ts @@ -12,12 +12,5 @@ export const ResourceTypePaths: Partial> = { export function runResource(resourceType: ResourceType, query: string) { const path = ResourceTypePaths[resourceType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/resources/ociResource.ts b/src/api/resources/ociResource.ts index 950c12472..5a024ad03 100644 --- a/src/api/resources/ociResource.ts +++ b/src/api/resources/ociResource.ts @@ -11,12 +11,5 @@ export const ResourceTypePaths: Partial> = { export function runResource(resourceType: ResourceType, query: string) { const path = ResourceTypePaths[resourceType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/resources/ocpResource.ts b/src/api/resources/ocpResource.ts index e767df57d..923a4d791 100644 --- a/src/api/resources/ocpResource.ts +++ b/src/api/resources/ocpResource.ts @@ -11,12 +11,5 @@ export const ResourceTypePaths: Partial> = { export function runResource(resourceType: ResourceType, query: string) { const path = ResourceTypePaths[resourceType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/resources/rhelResource.ts b/src/api/resources/rhelResource.ts index e767df57d..923a4d791 100644 --- a/src/api/resources/rhelResource.ts +++ b/src/api/resources/rhelResource.ts @@ -11,12 +11,5 @@ export const ResourceTypePaths: Partial> = { export function runResource(resourceType: ResourceType, query: string) { const path = ResourceTypePaths[resourceType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/ros/recommendations.ts b/src/api/ros/recommendations.ts index d9fbd37de..063d6dd76 100644 --- a/src/api/ros/recommendations.ts +++ b/src/api/ros/recommendations.ts @@ -67,12 +67,5 @@ export function runRosReport(reportType: RosType, query: string) { // This fetches a recommendations list export function runRosReports(reportType: RosType, query: string) { const path = RosTypePaths[reportType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/tags/awsOcpTags.ts b/src/api/tags/awsOcpTags.ts index 84ec9db61..230517403 100644 --- a/src/api/tags/awsOcpTags.ts +++ b/src/api/tags/awsOcpTags.ts @@ -11,12 +11,5 @@ export const TagTypePaths: Partial> = { export function runTag(tagType: TagType, query: string) { const path = TagTypePaths[tagType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/tags/awsTags.ts b/src/api/tags/awsTags.ts index acd745398..1a08a94ac 100644 --- a/src/api/tags/awsTags.ts +++ b/src/api/tags/awsTags.ts @@ -11,12 +11,5 @@ export const TagTypePaths: Partial> = { export function runTag(tagType: TagType, query: string) { const path = TagTypePaths[tagType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/tags/azureOcpTags.ts b/src/api/tags/azureOcpTags.ts index 72e40841a..ad612d300 100644 --- a/src/api/tags/azureOcpTags.ts +++ b/src/api/tags/azureOcpTags.ts @@ -11,12 +11,5 @@ export const TagTypePaths: Partial> = { export function runTag(tagType: TagType, query: string) { const path = TagTypePaths[tagType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/tags/azureTags.ts b/src/api/tags/azureTags.ts index f9627b011..e340daa90 100644 --- a/src/api/tags/azureTags.ts +++ b/src/api/tags/azureTags.ts @@ -11,12 +11,5 @@ export const TagTypePaths: Partial> = { export function runTag(tagType: TagType, query: string) { const path = TagTypePaths[tagType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/tags/gcpOcpTags.ts b/src/api/tags/gcpOcpTags.ts index 345ecfc77..6d6d747e1 100644 --- a/src/api/tags/gcpOcpTags.ts +++ b/src/api/tags/gcpOcpTags.ts @@ -11,12 +11,5 @@ export const TagTypePaths: Partial> = { export function runTag(tagType: TagType, query: string) { const path = TagTypePaths[tagType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/tags/gcpTags.ts b/src/api/tags/gcpTags.ts index 13e1e7677..a91499bec 100644 --- a/src/api/tags/gcpTags.ts +++ b/src/api/tags/gcpTags.ts @@ -11,12 +11,5 @@ export const TagTypePaths: Partial> = { export function runTag(tagType: TagType, query: string) { const path = TagTypePaths[tagType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/tags/ibmTags.ts b/src/api/tags/ibmTags.ts index cba60cbe0..acfb520b9 100644 --- a/src/api/tags/ibmTags.ts +++ b/src/api/tags/ibmTags.ts @@ -11,12 +11,5 @@ export const TagTypePaths: Partial> = { export function runTag(tagType: TagType, query: string) { const path = TagTypePaths[tagType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/tags/ociTags.ts b/src/api/tags/ociTags.ts index 5fd14adda..a9d9fe903 100644 --- a/src/api/tags/ociTags.ts +++ b/src/api/tags/ociTags.ts @@ -11,12 +11,5 @@ export const TagTypePaths: Partial> = { export function runTag(tagType: TagType, query: string) { const path = TagTypePaths[tagType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/tags/ocpCloudTags.ts b/src/api/tags/ocpCloudTags.ts index b6c6f8884..f3772233e 100644 --- a/src/api/tags/ocpCloudTags.ts +++ b/src/api/tags/ocpCloudTags.ts @@ -11,12 +11,5 @@ export const TagTypePaths: Partial> = { export function runTag(tagType: TagType, query: string) { const path = TagTypePaths[tagType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/tags/ocpTags.ts b/src/api/tags/ocpTags.ts index 86dd7fcd7..3a0e32854 100644 --- a/src/api/tags/ocpTags.ts +++ b/src/api/tags/ocpTags.ts @@ -11,12 +11,5 @@ export const TagTypePaths: Partial> = { export function runTag(tagType: TagType, query: string) { const path = TagTypePaths[tagType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/tags/rhelTags.ts b/src/api/tags/rhelTags.ts index e5d593349..bfebe075a 100644 --- a/src/api/tags/rhelTags.ts +++ b/src/api/tags/rhelTags.ts @@ -11,12 +11,5 @@ export const TagTypePaths: Partial> = { export function runTag(tagType: TagType, query: string) { const path = TagTypePaths[tagType]; - const fetch = () => axios.get(`${path}?${query}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`${path}?${query}`); } diff --git a/src/api/userAccess.ts b/src/api/userAccess.ts index 3a781ee65..e61f9ad43 100644 --- a/src/api/userAccess.ts +++ b/src/api/userAccess.ts @@ -25,18 +25,11 @@ export const enum UserAccessType { oci = 'oci', ocp = 'ocp', rhel = 'ocp', // Todo: update to use RHEL when APIs are available - ros = 'ocp', // Todo: update to use ROS when APIs are available + ros = 'ocp', } // If the user-access API is called without a query parameter, all types are returned in the response export function fetchUserAccess(query: string) { const queryString = query ? `?${query}` : ''; - const fetch = () => axios.get(`user-access/${queryString}`); - - const insights = (window as any).insights; - if (insights && insights.chrome && insights.chrome.auth && insights.chrome.auth.getUser) { - return insights.chrome.auth.getUser().then(() => fetch()); - } else { - return fetch(); - } + return axios.get(`user-access/${queryString}`); } diff --git a/src/store/accountSettings/accountSettingsActions.ts b/src/store/accountSettings/accountSettingsActions.ts index 5afe6fc9f..8ddb66b8e 100644 --- a/src/store/accountSettings/accountSettingsActions.ts +++ b/src/store/accountSettings/accountSettingsActions.ts @@ -1,6 +1,7 @@ import type { AccountSettings } from 'api/accountSettings'; import { fetchAccountSettings as apiGetAccountSettings } from 'api/accountSettings'; import type { AxiosError } from 'axios'; +import type { ThunkAction } from 'store/common'; import { createAction } from 'typesafe-actions'; import { getFetchId } from './accountSettingsCommon'; @@ -19,7 +20,7 @@ export const fetchAccountSettingsFailure = createAction('accountSettings/fetch/f AccountSettingsActionMeta >(); -export function fetchAccountSettings() { +export function fetchAccountSettings(): ThunkAction { return dispatch => { const meta: AccountSettingsActionMeta = { fetchId: getFetchId(), diff --git a/src/store/providers/providersActions.ts b/src/store/providers/providersActions.ts index 775db0e6e..a7a2c5fba 100644 --- a/src/store/providers/providersActions.ts +++ b/src/store/providers/providersActions.ts @@ -2,6 +2,7 @@ import type { Providers } from 'api/providers'; import type { ProviderType } from 'api/providers'; import { fetchProviders as apiGetProviders } from 'api/providers'; import type { AxiosError } from 'axios'; +import type { ThunkAction } from 'store/common'; import { createAction } from 'typesafe-actions'; import { getFetchId } from './providersCommon'; @@ -14,7 +15,7 @@ export const fetchProvidersRequest = createAction('providers/fetch/request')(); export const fetchProvidersFailure = createAction('providers/fetch/failure')(); -export function fetchProviders(reportType: ProviderType, reportQueryString: string) { +export function fetchProviders(reportType: ProviderType, reportQueryString: string): ThunkAction { return dispatch => { const meta: ProvidersActionMeta = { fetchId: getFetchId(reportType, reportQueryString), diff --git a/src/store/sourceSettings/actions.ts b/src/store/sourceSettings/actions.ts index 7d5efe7ab..be714d929 100644 --- a/src/store/sourceSettings/actions.ts +++ b/src/store/sourceSettings/actions.ts @@ -3,6 +3,7 @@ import { fetchProviders as apiGetSources } from 'api/providers'; import type { AxiosResponse } from 'axios'; import type { AxiosError } from 'axios'; import type { Dispatch } from 'redux'; +import type { ThunkAction } from 'store/common'; import { createAction, createAsyncAction } from 'typesafe-actions'; interface FilterQuery { @@ -22,7 +23,7 @@ export const { AxiosError >(); -export const fetchSources = (sourcesQueryString: string = '') => { +export const fetchSources = (sourcesQueryString: string = ''): ThunkAction => { return (dispatch: Dispatch) => { dispatch(fetchSourcesRequest()); diff --git a/src/store/userAccess/userAccessActions.ts b/src/store/userAccess/userAccessActions.ts index 1389369f7..a274b89bd 100644 --- a/src/store/userAccess/userAccessActions.ts +++ b/src/store/userAccess/userAccessActions.ts @@ -2,6 +2,7 @@ import type { UserAccess } from 'api/userAccess'; import type { UserAccessType } from 'api/userAccess'; import { fetchUserAccess as apiGetUserAccess } from 'api/userAccess'; import type { AxiosError } from 'axios'; +import type { ThunkAction } from 'store/common'; import { createAction } from 'typesafe-actions'; import { getFetchId } from './userAccessCommon'; @@ -14,7 +15,7 @@ export const fetchUserAccessRequest = createAction('userAccess/fetch/request')(); export const fetchUserAccessFailure = createAction('userAccess/fetch/failure')(); -export function fetchUserAccess(userAccessType: UserAccessType, userAccessQueryString: string) { +export function fetchUserAccess(userAccessType: UserAccessType, userAccessQueryString: string): ThunkAction { return dispatch => { const meta: UserAccessActionMeta = { fetchId: getFetchId(userAccessType, userAccessQueryString), From 567743d6a8e5389741760b693fb5541554af719c Mon Sep 17 00:00:00 2001 From: Dan Labrecque Date: Tue, 4 Apr 2023 12:54:07 -0400 Subject: [PATCH 2/2] Update max bar width --- .../components/charts/costExplorerChart/costExplorerChart.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/views/components/charts/costExplorerChart/costExplorerChart.tsx b/src/routes/views/components/charts/costExplorerChart/costExplorerChart.tsx index 766e22fca..54132cdd7 100644 --- a/src/routes/views/components/charts/costExplorerChart/costExplorerChart.tsx +++ b/src/routes/views/components/charts/costExplorerChart/costExplorerChart.tsx @@ -245,7 +245,7 @@ class CostExplorerChartBase extends React.Component { const { hiddenSeries, series, width } = this.state; - const maxWidth = 200; + const maxWidth = 20; let maxValue = -1; if (series) {