apply core-imports codemod to all packages and plugins

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-06-17 17:56:24 +02:00
parent 9b9a8f3925
commit d453c05dc3
541 changed files with 1549 additions and 1321 deletions
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import { createApiRef } from '@backstage/core';
import {
Alert,
Cost,
@@ -24,6 +23,7 @@ import {
Maybe,
MetricData,
} from '../types';
import { createApiRef } from '@backstage/core-plugin-api';
export type ProductInsightsOptions = {
/**
@@ -17,9 +17,9 @@
import React, { PropsWithChildren } from 'react';
import { Box, Button, Container, makeStyles } from '@material-ui/core';
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
import { Header, Page } from '@backstage/core';
import { CostInsightsThemeProvider } from '../CostInsightsPage/CostInsightsThemeProvider';
import { ConfigProvider, CurrencyProvider } from '../../hooks';
import { Header, Page } from '@backstage/core-components';
const useStyles = makeStyles(theme => ({
root: {
@@ -16,14 +16,11 @@
import { CostInsightsHeader } from './CostInsightsHeader';
import { renderInTestApp } from '@backstage/test-utils';
import {
ApiProvider,
ApiRegistry,
IdentityApi,
identityApiRef,
} from '@backstage/core';
import React from 'react';
import { ApiProvider, ApiRegistry } from '@backstage/core-app-api';
import { IdentityApi, identityApiRef } from '@backstage/core-plugin-api';
describe('<CostInsightsHeader/>', () => {
const identityApi: Partial<IdentityApi> = {
getProfile: () => ({
@@ -16,9 +16,13 @@
import React from 'react';
import { Typography } from '@material-ui/core';
import { identityApiRef, ProfileInfo, useApi } from '@backstage/core';
import { useCostInsightsStyles } from '../../utils/styles';
import { Group } from '../../types';
import {
identityApiRef,
ProfileInfo,
useApi,
} from '@backstage/core-plugin-api';
function name(profile: ProfileInfo | undefined): string {
return profile?.displayName || 'Mysterious Stranger';
@@ -15,9 +15,9 @@
*/
import React, { PropsWithChildren } from 'react';
import { makeStyles } from '@material-ui/core';
import { Header, Page } from '@backstage/core';
import { Group } from '../../types';
import { CostInsightsTabs } from '../CostInsightsTabs';
import { Header, Page } from '@backstage/core-components';
const useStyles = makeStyles(theme => ({
root: {
@@ -23,7 +23,6 @@ import {
Grid,
Typography,
} from '@material-ui/core';
import { Progress, useApi } from '@backstage/core';
import { default as MaterialAlert } from '@material-ui/lab/Alert';
import { costInsightsApiRef } from '../../api';
import { ActionItems } from '../ActionItems';
@@ -61,6 +60,9 @@ import {
isAlertSnoozed,
} from '../../utils/alerts';
import { Progress } from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';
export const CostInsightsPage = () => {
const classes = useSubtleTypographyStyles();
const client = useApi(costInsightsApiRef);
@@ -15,7 +15,7 @@
*/
import React from 'react';
import { SupportButton } from '@backstage/core';
import { SupportButton } from '@backstage/core-components';
export const CostInsightsSupportButton = () => {
return (
@@ -16,8 +16,8 @@
import React from 'react';
import { Box, Typography } from '@material-ui/core';
import { CodeSnippet, Link } from '@backstage/core';
import { AlertInstructionsLayout } from '../AlertInstructionsLayout';
import { CodeSnippet, Link } from '@backstage/core-components';
export const LabelDataflowInstructionsPage = () => {
return (
@@ -17,7 +17,6 @@
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { Box, Typography } from '@material-ui/core';
import { default as Alert } from '@material-ui/lab/Alert';
import { useApi } from '@backstage/core';
import { costInsightsApiRef } from '../../api';
import { ProductInsightsCardList } from '../ProductInsightsCard/ProductInsightsCardList';
import { Duration, Entity, Maybe, Product } from '../../types';
@@ -34,6 +33,7 @@ import {
useLastCompleteBillingDate,
MapLoadingToProps,
} from '../../hooks';
import { useApi } from '@backstage/core-plugin-api';
type LoadingProps = (isLoading: boolean) => void;
@@ -15,7 +15,6 @@
*/
import React, { useState } from 'react';
import { HeaderTabs } from '@backstage/core';
import { Dialog, IconButton } from '@material-ui/core';
import { default as CloseButton } from '@material-ui/icons/Close';
import { useEntityDialogStyles as useStyles } from '../../utils/styles';
@@ -25,6 +24,7 @@ import {
ProductEntityTableOptions,
} from './ProductEntityTable';
import { findAlways } from '../../utils/assert';
import { HeaderTabs } from '@backstage/core-components';
type ProductEntityDialogProps = {
open: boolean;
@@ -16,12 +16,12 @@
import React from 'react';
import classnames from 'classnames';
import { Table, TableColumn } from '@backstage/core';
import { Typography } from '@material-ui/core';
import { costFormatter, formatChange } from '../../utils/formatters';
import { useEntityDialogStyles as useStyles } from '../../utils/styles';
import { CostGrowthIndicator } from '../CostGrowth';
import { BarChartOptions, ChangeStatistic, Entity } from '../../types';
import { Table, TableColumn } from '@backstage/core-components';
export type ProductEntityTableOptions = Partial<
Pick<BarChartOptions, 'previousName' | 'currentName'>
@@ -22,7 +22,6 @@ import React, {
useState,
} from 'react';
import pluralize from 'pluralize';
import { InfoCard } from '@backstage/core';
import { Typography } from '@material-ui/core';
import { default as Alert } from '@material-ui/lab/Alert';
import { PeriodSelect } from '../PeriodSelect';
@@ -37,6 +36,7 @@ import {
} from '../../hooks';
import { findAnyKey } from '../../utils/assert';
import { ScrollAnchor } from '../../utils/scroll';
import { InfoCard } from '@backstage/core-components';
type LoadingProps = (isLoading: boolean) => void;
@@ -16,9 +16,9 @@
import React from 'react';
import pluralize from 'pluralize';
import { InfoCard } from '@backstage/core';
import { ProjectGrowthAlertChart } from './ProjectGrowthAlertChart';
import { ProjectGrowthData } from '../../types';
import { InfoCard } from '@backstage/core-components';
type ProjectGrowthAlertProps = {
alert: ProjectGrowthData;
@@ -17,7 +17,6 @@
import React from 'react';
import moment from 'moment';
import { Box, Typography } from '@material-ui/core';
import { InfoCard } from '@backstage/core';
import { AlertInstructionsLayout } from '../AlertInstructionsLayout';
import { ProductInsightsChart } from '../ProductInsightsCard';
import {
@@ -29,6 +28,7 @@ import {
ProjectGrowthData,
} from '../../types';
import { ProjectGrowthAlert } from '../../alerts';
import { InfoCard } from '@backstage/core-components';
const today = moment().format(DEFAULT_DATE_FORMAT);
@@ -16,11 +16,11 @@
import React from 'react';
import pluralize from 'pluralize';
import { InfoCard } from '@backstage/core';
import { Box } from '@material-ui/core';
import { BarChart, BarChartLegend } from '../BarChart';
import { UnlabeledDataflowData, ResourceData } from '../../types';
import { useBarChartLayoutStyles as useStyles } from '../../utils/styles';
import { InfoCard } from '@backstage/core-components';
type UnlabeledDataflowAlertProps = {
alert: UnlabeledDataflowData;
@@ -17,7 +17,6 @@
import React from 'react';
import pluralize from 'pluralize';
import { KubernetesMigrationAlertCard } from '../components';
import { Lifecycle } from '@backstage/core';
import { CostInsightsApi } from '../../api';
import {
Alert,
@@ -32,6 +31,7 @@ import {
KubernetesMigrationDismissForm,
KubernetesMigrationDismissFormData,
} from '../forms';
import { Lifecycle } from '@backstage/core-components';
export interface KubernetesMigrationData {
startDate: string;
@@ -16,10 +16,10 @@
import React from 'react';
import { Box } from '@material-ui/core';
import { InfoCard } from '@backstage/core';
import { KubernetesMigrationBarChartLegend } from './KubernetesMigrationBarChartLegend';
import { KubernetesMigrationBarChart } from './KubernetesMigrationBarChart';
import { KubernetesMigrationData } from '../../alerts';
import { InfoCard } from '@backstage/core-components';
type KubernetesMigrationAlertProps = {
data: KubernetesMigrationData;
@@ -21,12 +21,12 @@ import React, {
useEffect,
useState,
} from 'react';
import { configApiRef, useApi } from '@backstage/core';
import { Config as BackstageConfig } from '@backstage/config';
import { Currency, Icon, Metric, Product } from '../types';
import { getIcon } from '../utils/navigation';
import { validateMetrics } from '../utils/config';
import { defaultCurrencies } from '../utils/currency';
import { configApiRef, useApi } from '@backstage/core-plugin-api';
/*
* Config schema 2020-10-15
@@ -21,11 +21,11 @@ import React, {
useState,
} from 'react';
import { Alert } from '@material-ui/lab';
import { useApi, identityApiRef } from '@backstage/core';
import { costInsightsApiRef } from '../api';
import { MapLoadingToProps, useLoading } from './useLoading';
import { Group, Maybe } from '../types';
import { DefaultLoadingAction } from '../utils/loading';
import { useApi, identityApiRef } from '@backstage/core-plugin-api';
type GroupsProviderLoadingProps = {
dispatchLoadingGroups: (isLoading: boolean) => void;
@@ -22,11 +22,11 @@ import React, {
} from 'react';
import * as yup from 'yup';
import { Alert } from '@material-ui/lab';
import { useApi } from '@backstage/core';
import { costInsightsApiRef } from '../api';
import { MapLoadingToProps, useLoading } from './useLoading';
import { DefaultLoadingAction } from '../utils/loading';
import { Maybe } from '../types';
import { useApi } from '@backstage/core-plugin-api';
type BillingDateProviderLoadingProps = {
dispatchLoadingBillingDate: (isLoading: boolean) => void;
+1 -1
View File
@@ -18,7 +18,7 @@ import {
createPlugin,
createRouteRef,
createRoutableExtension,
} from '@backstage/core';
} from '@backstage/core-plugin-api';
export const rootRouteRef = createRouteRef({
path: '/cost-insights',
@@ -15,8 +15,8 @@
*/
import { Config } from '@backstage/config';
import { ConfigApi } from '@backstage/core';
import { MockProductTypes } from './products';
import { ConfigApi } from '@backstage/core-plugin-api';
export const MockProductsConfig: Partial<ConfigApi> = {
keys: () => Object.keys(MockProductTypes),
@@ -16,12 +16,6 @@
import React, { PropsWithChildren } from 'react';
import { costInsightsApiRef, CostInsightsApi } from '../api';
import {
ApiProvider,
ApiRegistry,
IdentityApi,
identityApiRef,
} from '@backstage/core';
import { LoadingContext, LoadingContextProps } from '../hooks/useLoading';
import { GroupsContext, GroupsContextProps } from '../hooks/useGroups';
import { FilterContext, FilterContextProps } from '../hooks/useFilters';
@@ -34,6 +28,9 @@ import {
import { ScrollContext, ScrollContextProps } from '../hooks/useScroll';
import { Group, Duration } from '../types';
import { ApiProvider, ApiRegistry } from '@backstage/core-app-api';
import { IdentityApi, identityApiRef } from '@backstage/core-plugin-api';
type PartialPropsWithChildren<T> = PropsWithChildren<Partial<T>>;
export const MockGroups: Group[] = [{ id: 'tech' }, { id: 'mock-group' }];