From d20428775c7b3800dbf846afcd6154747465379e Mon Sep 17 00:00:00 2001 From: Ryan Vazquez Date: Wed, 28 Oct 2020 10:51:05 -0400 Subject: [PATCH] migrate loading utils --- .../src/components/CostInsightsPage/selector.tsx | 2 +- .../src/components/CostInsightsTabs/selector.ts | 3 ++- plugins/cost-insights/src/hooks/useGroups.tsx | 5 ++--- .../cost-insights/src/hooks/useLastCompleteBillingDate.tsx | 3 ++- plugins/cost-insights/src/hooks/useLoading.tsx | 6 +++--- plugins/cost-insights/src/utils/mockData.ts | 6 ++++-- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/plugins/cost-insights/src/components/CostInsightsPage/selector.tsx b/plugins/cost-insights/src/components/CostInsightsPage/selector.tsx index a73c0ff975..664c90726a 100644 --- a/plugins/cost-insights/src/components/CostInsightsPage/selector.tsx +++ b/plugins/cost-insights/src/components/CostInsightsPage/selector.tsx @@ -18,7 +18,7 @@ import { getResetState, DefaultLoadingAction, getResetStateWithoutInitial, -} from '../../types'; +} from '../../utils/loading'; type CostInsightsPageLoadingProps = { loadingActions: Array; diff --git a/plugins/cost-insights/src/components/CostInsightsTabs/selector.ts b/plugins/cost-insights/src/components/CostInsightsTabs/selector.ts index 3aa53cce21..35100338ac 100644 --- a/plugins/cost-insights/src/components/CostInsightsTabs/selector.ts +++ b/plugins/cost-insights/src/components/CostInsightsTabs/selector.ts @@ -16,7 +16,8 @@ import { MapFiltersToProps } from '../../hooks/useFilters'; import { MapLoadingToProps } from '../../hooks/useLoading'; -import { Group, PageFilters, getResetStateWithoutInitial } from '../../types'; +import { Group, PageFilters } from '../../types'; +import { getResetStateWithoutInitial } from '../../utils/loading'; type CostInsightsTabsFilterProps = PageFilters & { setGroup: (group: Group) => void; diff --git a/plugins/cost-insights/src/hooks/useGroups.tsx b/plugins/cost-insights/src/hooks/useGroups.tsx index f7adc84a57..50444f2915 100644 --- a/plugins/cost-insights/src/hooks/useGroups.tsx +++ b/plugins/cost-insights/src/hooks/useGroups.tsx @@ -24,9 +24,8 @@ import { Alert } from '@material-ui/lab'; import { useApi, identityApiRef } from '@backstage/core'; import { costInsightsApiRef } from '../api'; import { MapLoadingToProps, useLoading } from './useLoading'; -import { DefaultLoadingAction, Group, Maybe } from '../types'; - -console.log(DefaultLoadingAction) +import { Group, Maybe } from '../types'; +import { DefaultLoadingAction } from '../utils/loading'; type GroupsProviderLoadingProps = { dispatchLoadingGroups: (isLoading: boolean) => void; diff --git a/plugins/cost-insights/src/hooks/useLastCompleteBillingDate.tsx b/plugins/cost-insights/src/hooks/useLastCompleteBillingDate.tsx index 33d037267d..d2ee43980f 100644 --- a/plugins/cost-insights/src/hooks/useLastCompleteBillingDate.tsx +++ b/plugins/cost-insights/src/hooks/useLastCompleteBillingDate.tsx @@ -25,7 +25,8 @@ import { Alert } from '@material-ui/lab'; import { useApi } from '@backstage/core'; import { costInsightsApiRef } from '../api'; import { MapLoadingToProps, useLoading } from './useLoading'; -import { DefaultLoadingAction, Maybe } from '../types'; +import { DefaultLoadingAction } from '../utils/loading'; +import { Maybe } from '../types'; type BillingDateProviderLoadingProps = { dispatchLoadingBillingDate: (isLoading: boolean) => void; diff --git a/plugins/cost-insights/src/hooks/useLoading.tsx b/plugins/cost-insights/src/hooks/useLoading.tsx index 31402ba0d1..261f1e4077 100644 --- a/plugins/cost-insights/src/hooks/useLoading.tsx +++ b/plugins/cost-insights/src/hooks/useLoading.tsx @@ -26,12 +26,12 @@ import React, { useState, } from 'react'; import { Backdrop, CircularProgress } from '@material-ui/core'; +import { Loading } from '../types'; import { DefaultLoadingAction, getDefaultState, getLoadingActions, - Loading, -} from '../types'; +} from '../utils/loading'; import { useBackdropStyles as useStyles } from '../utils/styles'; import { useConfig } from './useConfig'; @@ -68,7 +68,7 @@ export const LoadingProvider = ({ children }: PropsWithChildren<{}>) => { // Initial page loading is handled by progress bar setBackdropVisible( !state[DefaultLoadingAction.CostInsightsInitial] && - Object.values(state).some(l => l), + Object.values(state).some(l => l), ); } displayLoadingBackdrop(); diff --git a/plugins/cost-insights/src/utils/mockData.ts b/plugins/cost-insights/src/utils/mockData.ts index 11c70eee25..c070f07e29 100644 --- a/plugins/cost-insights/src/utils/mockData.ts +++ b/plugins/cost-insights/src/utils/mockData.ts @@ -15,11 +15,9 @@ */ import { - DefaultLoadingAction, Duration, Entity, findAlways, - getDefaultState as getDefaultLoadingState, Product, ProductCost, ProductFilters, @@ -27,6 +25,10 @@ import { UnlabeledDataflowAlertProject, UnlabeledDataflowData, } from '../types'; +import { + DefaultLoadingAction, + getDefaultState as getDefaultLoadingState, +} from '../utils/loading'; import { Config } from '@backstage/config'; import { ConfigApi } from '@backstage/core';