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,18 +14,18 @@
* limitations under the License.
*/
import {
ApiProvider,
ApiRegistry,
configApiRef,
ConfigReader,
googleAuthApiRef,
} from '@backstage/core';
import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
import { fireEvent } from '@testing-library/react';
import React from 'react';
import { AuthProviders } from './AuthProviders';
import {
ApiProvider,
ApiRegistry,
ConfigReader,
} from '@backstage/core-app-api';
import { configApiRef, googleAuthApiRef } from '@backstage/core-plugin-api';
const mockSignInHandler = jest.fn().mockReturnValue('');
const mockGoogleAuth = {
sessionState$: () => ({
@@ -16,10 +16,12 @@
import React from 'react';
import { List } from '@material-ui/core';
import { configApiRef, InfoCard, useApi } from '@backstage/core';
import { EmptyProviders } from './EmptyProviders';
import { DefaultProviderSettings } from './DefaultProviderSettings';
import { configApiRef, useApi } from '@backstage/core-plugin-api';
import { InfoCard } from '@backstage/core-components';
type Props = {
providerSettings?: JSX.Element;
};
@@ -13,6 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Star from '@material-ui/icons/Star';
import React from 'react';
import { ProviderSettingsItem } from './ProviderSettingsItem';
import {
auth0AuthApiRef,
githubAuthApiRef,
@@ -21,10 +24,7 @@ import {
oauth2ApiRef,
oktaAuthApiRef,
microsoftAuthApiRef,
} from '@backstage/core';
import Star from '@material-ui/icons/Star';
import React from 'react';
import { ProviderSettingsItem } from './ProviderSettingsItem';
} from '@backstage/core-plugin-api';
type Props = {
configuredProviders: string[];
@@ -15,8 +15,8 @@
*/
import React from 'react';
import { CodeSnippet, EmptyState } from '@backstage/core';
import { Button, Typography } from '@material-ui/core';
import { CodeSnippet, EmptyState } from '@backstage/core-components';
const EXAMPLE = `auth:
providers:
@@ -14,13 +14,6 @@
* limitations under the License.
*/
import React, { useEffect, useState } from 'react';
import {
ApiRef,
SessionApi,
useApi,
IconComponent,
SessionState,
} from '@backstage/core';
import {
Button,
ListItem,
@@ -29,6 +22,13 @@ import {
ListItemText,
Tooltip,
} from '@material-ui/core';
import {
ApiRef,
SessionApi,
useApi,
IconComponent,
SessionState,
} from '@backstage/core-plugin-api';
type Props = {
title: string;
@@ -15,8 +15,8 @@
*/
import React from 'react';
import { CodeSnippet, EmptyState } from '@backstage/core';
import { Button, Typography } from '@material-ui/core';
import { CodeSnippet, EmptyState } from '@backstage/core-components';
const EXAMPLE = `import { createPlugin } from '@backstage/core';
@@ -15,16 +15,17 @@
*/
import React, { useCallback, useState } from 'react';
import {
featureFlagsApiRef,
FeatureFlagState,
InfoCard,
useApi,
} from '@backstage/core';
import { List } from '@material-ui/core';
import { EmptyFlags } from './EmptyFlags';
import { FlagItem } from './FeatureFlagsItem';
import {
featureFlagsApiRef,
FeatureFlagState,
useApi,
} from '@backstage/core-plugin-api';
import { InfoCard } from '@backstage/core-components';
export const FeatureFlags = () => {
const featureFlagsApi = useApi(featureFlagsApiRef);
const featureFlags = featureFlagsApi.getRegisteredFlags();
@@ -22,7 +22,7 @@ import {
Switch,
Tooltip,
} from '@material-ui/core';
import { FeatureFlag } from '@backstage/core';
import { FeatureFlag } from '@backstage/core-plugin-api';
type Props = {
flag: FeatureFlag;
@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { InfoCard } from '@backstage/core';
import { Grid, List } from '@material-ui/core';
import React from 'react';
import { PinButton } from './PinButton';
import { Profile } from './Profile';
import { ThemeToggle } from './ThemeToggle';
import { InfoCard } from '@backstage/core-components';
export const General = () => {
return (
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import { SidebarPinStateContext } from '@backstage/core';
import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
import { fireEvent } from '@testing-library/react';
import React from 'react';
import { PinButton } from './PinButton';
import { SidebarPinStateContext } from '@backstage/core-components';
describe('<PinButton />', () => {
it('toggles the pin sidebar button', async () => {
@@ -22,7 +22,7 @@ import {
Switch,
Tooltip,
} from '@material-ui/core';
import { SidebarPinStateContext } from '@backstage/core';
import { SidebarPinStateContext } from '@backstage/core-components';
export const PinButton = () => {
const { isPinned, toggleSidebarPinState } = useContext(
@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { InfoCard } from '@backstage/core';
import { Grid, Typography } from '@material-ui/core';
import React from 'react';
import { SignInAvatar } from './SignInAvatar';
import { UserSettingsMenu } from './UserSettingsMenu';
import { useUserProfile } from '../useUserProfileInfo';
import { InfoCard } from '@backstage/core-components';
export const Profile = () => {
const { profile, displayName } = useUserProfile();
@@ -18,7 +18,7 @@ import React from 'react';
import { BackstageTheme } from '@backstage/theme';
import { makeStyles, Avatar } from '@material-ui/core';
import { useUserProfile } from '../useUserProfileInfo';
import { sidebarConfig } from '@backstage/core';
import { sidebarConfig } from '@backstage/core-components';
const useStyles = makeStyles<BackstageTheme, { size: number }>(theme => ({
avatar: {
@@ -14,18 +14,17 @@
* limitations under the License.
*/
import {
ApiProvider,
ApiRegistry,
appThemeApiRef,
AppThemeSelector,
} from '@backstage/core';
import { AppTheme } from '@backstage/core-plugin-api';
import { AppTheme, appThemeApiRef } from '@backstage/core-plugin-api';
import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
import { lightTheme } from '@backstage/theme';
import { fireEvent } from '@testing-library/react';
import React from 'react';
import { ThemeToggle } from './ThemeToggle';
import {
ApiProvider,
ApiRegistry,
AppThemeSelector,
} from '@backstage/core-app-api';
const mockTheme: AppTheme = {
id: 'light-theme',
@@ -17,7 +17,6 @@
import React, { cloneElement } from 'react';
import { useObservable } from 'react-use';
import AutoIcon from '@material-ui/icons/BrightnessAuto';
import { appThemeApiRef, useApi } from '@backstage/core';
import ToggleButton from '@material-ui/lab/ToggleButton';
import ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';
import {
@@ -27,6 +26,7 @@ import {
Tooltip,
makeStyles,
} from '@material-ui/core';
import { appThemeApiRef, useApi } from '@backstage/core-plugin-api';
type ThemeIconProps = {
id: string;
@@ -15,10 +15,10 @@
*/
import React from 'react';
import { identityApiRef, useApi } from '@backstage/core';
import { IconButton, ListItemIcon, Menu, MenuItem } from '@material-ui/core';
import SignOutIcon from '@material-ui/icons/MeetingRoom';
import MoreVertIcon from '@material-ui/icons/MoreVert';
import { identityApiRef, useApi } from '@backstage/core-plugin-api';
export const UserSettingsMenu = () => {
const identityApi = useApi(identityApiRef);
@@ -15,9 +15,9 @@
*/
import React from 'react';
import { SidebarItem } from '@backstage/core';
import SettingsIcon from '@material-ui/icons/Settings';
import { settingsRouteRef } from '../plugin';
import { SidebarItem } from '@backstage/core-components';
export const Settings = () => {
return (
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import { Header, Page, TabbedLayout } from '@backstage/core';
import React from 'react';
import { AuthProviders } from './AuthProviders';
import { FeatureFlags } from './FeatureFlags';
import { General } from './General';
import { Header, Page, TabbedLayout } from '@backstage/core-components';
type Props = {
providerSettings?: JSX.Element;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { useApi, identityApiRef } from '@backstage/core';
import { useApi, identityApiRef } from '@backstage/core-plugin-api';
export const useUserProfile = () => {
const identityApi = useApi(identityApiRef);
+1 -1
View File
@@ -18,7 +18,7 @@ import {
createPlugin,
createRoutableExtension,
createRouteRef,
} from '@backstage/core';
} from '@backstage/core-plugin-api';
export const settingsRouteRef = createRouteRef({
path: '/settings',