Merge pull request #14312 from backstage/freben/circ

get rid of circular imports
This commit is contained in:
Fredrik Adelöw
2022-10-25 10:46:52 +01:00
committed by GitHub
29 changed files with 88 additions and 83 deletions
@@ -14,9 +14,8 @@
* limitations under the License.
*/
import { ANNOTATION_SOURCE_LOCATION } from '.';
import { Entity, stringifyEntityRef } from '../entity';
import { ANNOTATION_LOCATION } from './annotation';
import { ANNOTATION_LOCATION, ANNOTATION_SOURCE_LOCATION } from './annotation';
/**
* Parses a string form location reference.
@@ -16,8 +16,7 @@
import React from 'react';
import { render } from '@testing-library/react';
import { OverflowTooltip } from '.';
import { OverflowTooltip } from './OverflowTooltip';
describe('<OverflowTooltip />', () => {
it('renders without exploding', async () => {
@@ -17,8 +17,8 @@
import { makeStyles } from '@material-ui/core/styles';
import React from 'react';
import { Link } from '../Link';
import { SubvalueCell, Table, TableColumn } from '.';
import { TableFilter } from './Table';
import { SubvalueCell } from './SubvalueCell';
import { Table, TableColumn, TableFilter } from './Table';
export default {
title: 'Data Display/Table',
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import React from 'react';
import { renderInTestApp } from '@backstage/test-utils';
import { HeaderTabs } from '.';
import { makeStyles } from '@material-ui/core/styles';
import Badge from '@material-ui/core/Badge';
import { makeStyles } from '@material-ui/core/styles';
import React from 'react';
import { HeaderTabs } from './HeaderTabs';
const mockTabs = [
{ id: 'overview', label: 'Overview' },
@@ -14,22 +14,13 @@
* limitations under the License.
*/
import { wrapInTestApp } from '@backstage/test-utils';
import Box from '@material-ui/core/Box';
import Chip from '@material-ui/core/Chip';
import Grid from '@material-ui/core/Grid';
import Link from '@material-ui/core/Link';
import Typography from '@material-ui/core/Typography';
import React, { useState } from 'react';
import { wrapInTestApp } from '@backstage/test-utils';
import {
Content,
ContentHeader,
Header,
HeaderLabel,
HeaderTabs,
InfoCard,
Page,
} from '..';
import {
GaugeCard,
StatusOK,
@@ -38,6 +29,13 @@ import {
TableColumn,
TrendLine,
} from '../../components';
import { Content } from '../Content';
import { ContentHeader } from '../ContentHeader';
import { Header } from '../Header';
import { HeaderLabel } from '../HeaderLabel';
import { HeaderTabs } from '../HeaderTabs';
import { InfoCard } from '../InfoCard';
import { Page } from '../Page';
export default {
title: 'Plugins/Examples',
@@ -22,15 +22,11 @@ import MenuBookIcon from '@material-ui/icons/MenuBook';
import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import {
Sidebar,
SidebarExpandButton,
SidebarItem,
SidebarSearchField,
SidebarPinStateProvider,
SidebarSubmenu,
SidebarSubmenuItem,
} from '.';
import { Sidebar } from './Bar';
import { SidebarExpandButton, SidebarItem, SidebarSearchField } from './Items';
import { SidebarPinStateProvider } from './SidebarPinStateContext';
import { SidebarSubmenu } from './SidebarSubmenu';
import { SidebarSubmenuItem } from './SidebarSubmenuItem';
async function renderScalableSidebar() {
await renderInTestApp(
@@ -53,16 +53,13 @@ import {
SidebarItemWithSubmenuContext,
SidebarConfig,
} from './config';
import {
SidebarSubmenuItemProps,
SidebarSubmenuProps,
SidebarSubmenu,
} from '.';
import { SidebarSubmenuProps, SidebarSubmenu } from './SidebarSubmenu';
import DoubleArrowLeft from './icons/DoubleArrowLeft';
import DoubleArrowRight from './icons/DoubleArrowRight';
import { isLocationMatch } from './utils';
import { Location } from 'history';
import { useSidebarOpenState } from './SidebarOpenStateContext';
import { SidebarSubmenuItemProps } from './SidebarSubmenuItem';
/** @public */
export type SidebarItemClassKey =
@@ -214,7 +211,7 @@ function useMemoStyles(sidebarConfig: SidebarConfig) {
/**
* Evaluates the routes of the SubmenuItems & nested DropdownItems.
* The reeveluation is only triggered, if the `locationPathname` changes, as `useElementFilter` uses memorization.
* The reevaluation is only triggered, if the `locationPathname` changes, as `useElementFilter` uses memorization.
*
* @param submenu SidebarSubmenu component
* @param location Location
@@ -21,13 +21,11 @@ import LayersIcon from '@material-ui/icons/Layers';
import LibraryBooks from '@material-ui/icons/LibraryBooks';
import { fireEvent } from '@testing-library/react';
import React from 'react';
import {
MobileSidebar,
Sidebar,
SidebarGroup,
SidebarItem,
SidebarPage,
} from '.';
import { Sidebar } from './Bar';
import { SidebarItem } from './Items';
import { MobileSidebar } from './MobileSidebar';
import { SidebarPage } from './Page';
import { SidebarGroup } from './SidebarGroup';
const MobileSidebarWithGroups = () => (
<SidebarPage>
@@ -24,19 +24,19 @@ import CloudQueueIcon from '@material-ui/icons/CloudQueue';
import AcUnitIcon from '@material-ui/icons/AcUnit';
import AppsIcon from '@material-ui/icons/Apps';
import React, { ComponentType } from 'react';
import { SidebarPage } from './Page';
import { Sidebar } from './Bar';
import { SidebarGroup } from './SidebarGroup';
import {
Sidebar,
SidebarDivider,
SidebarGroup,
SidebarExpandButton,
SidebarIntro,
SidebarItem,
SidebarPage,
SidebarSearchField,
SidebarSpace,
SidebarSubmenu,
SidebarSubmenuItem,
} from '.';
} from './Items';
import { SidebarIntro } from './Intro';
import { SidebarSubmenu } from './SidebarSubmenu';
import { SidebarSubmenuItem } from './SidebarSubmenuItem';
const routeRef = createRouteRef({
id: 'storybook.test-route',
@@ -20,8 +20,10 @@ import LayersIcon from '@material-ui/icons/Layers';
import LibraryBooks from '@material-ui/icons/LibraryBooks';
import { fireEvent } from '@testing-library/react';
import React from 'react';
import { SidebarItem } from './Items';
import { MobileSidebarContext } from './MobileSidebar';
import { SidebarGroup, SidebarItem, SidebarPage } from '.';
import { SidebarPage } from './Page';
import { SidebarGroup } from './SidebarGroup';
const SidebarGroupWithItems = () => (
<SidebarPage>
@@ -22,10 +22,10 @@ import BottomNavigationAction, {
import { makeStyles } from '@material-ui/core/styles';
import React, { useContext } from 'react';
import { useLocation } from 'react-router-dom';
import { useSidebarPinState } from '.';
import { Link } from '../../components';
import { SidebarConfigContext, SidebarConfig } from './config';
import { MobileSidebarContext } from './MobileSidebar';
import { useSidebarPinState } from './SidebarPinStateContext';
/**
* Props for the `SidebarGroup`
@@ -20,7 +20,7 @@ import {
GerritIntegrationConfig,
readGerritIntegrationConfigs,
} from './config';
import { parseGerritGitilesUrl, builldGerritGitilesUrl } from './core';
import { parseGerritGitilesUrl, buildGerritGitilesUrl } from './core';
/**
* A Gerrit based integration.
@@ -61,7 +61,7 @@ export class GerritIntegration implements ScmIntegration {
let updated;
if (url.startsWith('/')) {
const { branch, project } = parseGerritGitilesUrl(this.config, base);
return builldGerritGitilesUrl(this.config, project, branch, url);
return buildGerritGitilesUrl(this.config, project, branch, url);
}
if (url) {
updated = new URL(url, base);
+3 -3
View File
@@ -20,7 +20,7 @@ import fetch from 'cross-fetch';
import { setupRequestMockHandlers } from '@backstage/test-utils';
import { GerritIntegrationConfig } from './config';
import {
builldGerritGitilesUrl,
buildGerritGitilesUrl,
getGerritBranchApiUrl,
getGerritCloneRepoUrl,
getGerritRequestOptions,
@@ -33,14 +33,14 @@ describe('gerrit core', () => {
const worker = setupServer();
setupRequestMockHandlers(worker);
describe('builldGerritGitilesUrl', () => {
describe('buildGerritGitilesUrl', () => {
it('can create an url from arguments', () => {
const config: GerritIntegrationConfig = {
host: 'gerrit.com',
gitilesBaseUrl: 'https://gerrit.com/gitiles',
};
expect(
builldGerritGitilesUrl(config, 'repo', 'dev', 'catalog-info.yaml'),
buildGerritGitilesUrl(config, 'repo', 'dev', 'catalog-info.yaml'),
).toEqual(
'https://gerrit.com/gitiles/repo/+/refs/heads/dev/catalog-info.yaml',
);
+3 -2
View File
@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { trimStart } from 'lodash';
import { GerritIntegrationConfig } from '.';
import { GerritIntegrationConfig } from './config';
const GERRIT_BODY_PREFIX = ")]}'";
@@ -79,7 +80,7 @@ export function parseGerritGitilesUrl(
* @param filePath - The absolute file path.
* @public
*/
export function builldGerritGitilesUrl(
export function buildGerritGitilesUrl(
config: GerritIntegrationConfig,
project: string,
branch: string,