diff --git a/.changeset/purple-starfishes-design.md b/.changeset/purple-starfishes-design.md new file mode 100644 index 0000000000..d10602ee3d --- /dev/null +++ b/.changeset/purple-starfishes-design.md @@ -0,0 +1,8 @@ +--- +'@backstage/plugin-catalog-backend-module-github': patch +'@backstage/core-components': patch +'@backstage/plugin-playlist': patch +'@backstage/plugin-nomad': patch +--- + +Break some internal circular import chains diff --git a/packages/core-components/src/layout/ItemCard/ItemCard.stories.tsx b/packages/core-components/src/layout/ItemCard/ItemCard.stories.tsx index 1ba3dec3fd..a03ad9be41 100644 --- a/packages/core-components/src/layout/ItemCard/ItemCard.stories.tsx +++ b/packages/core-components/src/layout/ItemCard/ItemCard.stories.tsx @@ -22,7 +22,7 @@ import CardMedia from '@material-ui/core/CardMedia'; import Typography from '@material-ui/core/Typography'; import React from 'react'; import { MemoryRouter } from 'react-router-dom'; -import { LinkButton } from '../../components'; +import { LinkButton } from '../../components/LinkButton/LinkButton'; import { ItemCardGrid } from './ItemCardGrid'; import { ItemCardHeader } from './ItemCardHeader'; diff --git a/packages/core-components/src/layout/ItemCard/ItemCard.tsx b/packages/core-components/src/layout/ItemCard/ItemCard.tsx index 0b1ee34c0c..3d9963760b 100644 --- a/packages/core-components/src/layout/ItemCard/ItemCard.tsx +++ b/packages/core-components/src/layout/ItemCard/ItemCard.tsx @@ -21,7 +21,7 @@ import CardContent from '@material-ui/core/CardContent'; import CardMedia from '@material-ui/core/CardMedia'; import Chip from '@material-ui/core/Chip'; import React, { ReactNode } from 'react'; -import { LinkButton } from '../../components'; +import { LinkButton } from '../../components/LinkButton/LinkButton'; import { ItemCardHeader } from './ItemCardHeader'; type ItemCardProps = { diff --git a/packages/core-components/src/layout/Sidebar/SidebarGroup.tsx b/packages/core-components/src/layout/Sidebar/SidebarGroup.tsx index 1eb1423c61..1dd61d3170 100644 --- a/packages/core-components/src/layout/Sidebar/SidebarGroup.tsx +++ b/packages/core-components/src/layout/Sidebar/SidebarGroup.tsx @@ -22,7 +22,7 @@ import BottomNavigationAction, { import { makeStyles } from '@material-ui/core/styles'; import React, { useContext } from 'react'; import { useLocation } from 'react-router-dom'; -import { Link } from '../../components'; +import { Link } from '../../components/Link/Link'; import { SidebarConfig, SidebarConfigContext } from './config'; import { MobileSidebarContext } from './MobileSidebar'; import { useSidebarPinState } from './SidebarPinStateContext'; diff --git a/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.ts b/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.ts index c181510a67..bf82607c6b 100644 --- a/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.ts +++ b/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.ts @@ -28,48 +28,46 @@ import { ScmIntegrations, SingleInstanceGithubCredentialsProvider, } from '@backstage/integration'; -import { EventParams } from '@backstage/plugin-events-node'; -import { EventSubscriber } from '@backstage/plugin-events-node'; import { EntityProvider, EntityProviderConnection, } from '@backstage/plugin-catalog-node'; +import { EventParams, EventSubscriber } from '@backstage/plugin-events-node'; import { graphql } from '@octokit/graphql'; import { + MembershipEvent, OrganizationEvent, OrganizationMemberAddedEvent, OrganizationMemberRemovedEvent, - TeamEvent, TeamEditedEvent, - MembershipEvent, + TeamEvent, } from '@octokit/webhooks-types'; import { merge } from 'lodash'; import * as uuid from 'uuid'; import { Logger } from 'winston'; -import { - assignGroupsToUsers, - buildOrgHierarchy, - defaultOrganizationTeamTransformer, - defaultUserTransformer, - getOrganizationTeams, - getOrganizationUsers, - GithubTeam, - parseGithubOrgUrl, -} from '../lib'; -import { TeamTransformer, UserTransformer } from '../lib'; -import { - createAddEntitiesOperation, - createRemoveEntitiesOperation, - createReplaceEntitiesOperation, - DeferredEntitiesBuilder, - getOrganizationTeam, - getOrganizationTeamsFromUsers, -} from '../lib/github'; import { ANNOTATION_GITHUB_TEAM_SLUG, ANNOTATION_GITHUB_USER_LOGIN, } from '../lib/annotation'; -import { splitTeamSlug } from '../lib/util'; +import { + TeamTransformer, + UserTransformer, + defaultOrganizationTeamTransformer, + defaultUserTransformer, +} from '../lib/defaultTransformers'; +import { + DeferredEntitiesBuilder, + GithubTeam, + createAddEntitiesOperation, + createRemoveEntitiesOperation, + createReplaceEntitiesOperation, + getOrganizationTeam, + getOrganizationTeams, + getOrganizationTeamsFromUsers, + getOrganizationUsers, +} from '../lib/github'; +import { assignGroupsToUsers, buildOrgHierarchy } from '../lib/org'; +import { parseGithubOrgUrl, splitTeamSlug } from '../lib/util'; /** * Options for {@link GithubOrgEntityProvider}. diff --git a/plugins/nomad/src/Router.tsx b/plugins/nomad/src/Router.tsx index d7e6db1b44..4a3377779a 100644 --- a/plugins/nomad/src/Router.tsx +++ b/plugins/nomad/src/Router.tsx @@ -15,29 +15,15 @@ */ import React from 'react'; -import { Entity } from '@backstage/catalog-model'; import { useEntity } from '@backstage/plugin-catalog-react'; import { MissingAnnotationEmptyState } from '@backstage/core-components'; import { Route, Routes } from 'react-router-dom'; import { EntityNomadAllocationListTable } from './components/EntityNomadAllocationListTable/EntityNomadAllocationListTable'; - -/** @public */ -export const NOMAD_NAMESPACE_ANNOTATION = 'nomad.io/namespace'; - -/** @public */ -export const NOMAD_JOB_ID_ANNOTATION = 'nomad.io/job-id'; - -/** @public */ -export const NOMAD_GROUP_ANNOTATION = 'nomad.io/group'; - -/** @public */ -export const isNomadJobIDAvailable = (entity: Entity) => - Boolean(entity.metadata.annotations?.[NOMAD_JOB_ID_ANNOTATION]); - -/** @public */ -export const isNomadAllocationsAvailable = (entity: Entity) => - Boolean(entity.metadata.annotations?.[NOMAD_JOB_ID_ANNOTATION]) || - Boolean(entity.metadata.annotations?.[NOMAD_GROUP_ANNOTATION]); +import { + NOMAD_GROUP_ANNOTATION, + NOMAD_JOB_ID_ANNOTATION, + isNomadAllocationsAvailable, +} from './annotations'; export const EmbeddedRouter = () => { const { entity } = useEntity(); diff --git a/plugins/nomad/src/annotations.ts b/plugins/nomad/src/annotations.ts new file mode 100644 index 0000000000..9854288e5d --- /dev/null +++ b/plugins/nomad/src/annotations.ts @@ -0,0 +1,35 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Entity } from '@backstage/catalog-model'; + +/** @public */ +export const NOMAD_NAMESPACE_ANNOTATION = 'nomad.io/namespace'; + +/** @public */ +export const NOMAD_JOB_ID_ANNOTATION = 'nomad.io/job-id'; + +/** @public */ +export const NOMAD_GROUP_ANNOTATION = 'nomad.io/group'; + +/** @public */ +export const isNomadJobIDAvailable = (entity: Entity) => + Boolean(entity.metadata.annotations?.[NOMAD_JOB_ID_ANNOTATION]); + +/** @public */ +export const isNomadAllocationsAvailable = (entity: Entity) => + Boolean(entity.metadata.annotations?.[NOMAD_JOB_ID_ANNOTATION]) || + Boolean(entity.metadata.annotations?.[NOMAD_GROUP_ANNOTATION]); diff --git a/plugins/nomad/src/components/EntityNomadAllocationListTable/EntityNomadAllocationListTable.tsx b/plugins/nomad/src/components/EntityNomadAllocationListTable/EntityNomadAllocationListTable.tsx index 6d7a79c002..cc19d1ec53 100644 --- a/plugins/nomad/src/components/EntityNomadAllocationListTable/EntityNomadAllocationListTable.tsx +++ b/plugins/nomad/src/components/EntityNomadAllocationListTable/EntityNomadAllocationListTable.tsx @@ -35,7 +35,7 @@ import { NOMAD_JOB_ID_ANNOTATION, NOMAD_NAMESPACE_ANNOTATION, isNomadAllocationsAvailable, -} from '../../Router'; +} from '../../annotations'; import useAsync from 'react-use/lib/useAsync'; type rowType = Allocation & { nomadAddr: string }; diff --git a/plugins/nomad/src/components/EntityNomadJobVersionListCard/EntityNomadJobVersionListCard.tsx b/plugins/nomad/src/components/EntityNomadJobVersionListCard/EntityNomadJobVersionListCard.tsx index 0c1863b95e..bb4e4b0fad 100644 --- a/plugins/nomad/src/components/EntityNomadJobVersionListCard/EntityNomadJobVersionListCard.tsx +++ b/plugins/nomad/src/components/EntityNomadJobVersionListCard/EntityNomadJobVersionListCard.tsx @@ -30,7 +30,7 @@ import { NOMAD_JOB_ID_ANNOTATION, NOMAD_NAMESPACE_ANNOTATION, isNomadJobIDAvailable, -} from '../../Router'; +} from '../../annotations'; import OpenInNewIcon from '@material-ui/icons/OpenInNew'; import { Chip } from '@material-ui/core'; diff --git a/plugins/nomad/src/components/index.ts b/plugins/nomad/src/components/index.ts index 3951061b23..dcdae8cc99 100644 --- a/plugins/nomad/src/components/index.ts +++ b/plugins/nomad/src/components/index.ts @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { EntityNomadJobVersionListCard } from './EntityNomadJobVersionListCard/EntityNomadJobVersionListCard'; -import { EntityNomadAllocationListTable } from './EntityNomadAllocationListTable/EntityNomadAllocationListTable'; -export { EntityNomadJobVersionListCard, EntityNomadAllocationListTable }; +export { EntityNomadJobVersionListCard } from './EntityNomadJobVersionListCard/EntityNomadJobVersionListCard'; +export { EntityNomadAllocationListTable } from './EntityNomadAllocationListTable/EntityNomadAllocationListTable'; diff --git a/plugins/nomad/src/index.ts b/plugins/nomad/src/index.ts index 3785a5c7b5..d139935f1f 100644 --- a/plugins/nomad/src/index.ts +++ b/plugins/nomad/src/index.ts @@ -18,4 +18,7 @@ export { EntityNomadJobVersionListCard, EntityNomadAllocationListTable, } from './plugin'; -export { isNomadAllocationsAvailable, isNomadJobIDAvailable } from './Router'; +export { + isNomadAllocationsAvailable, + isNomadJobIDAvailable, +} from './annotations'; diff --git a/plugins/playlist/src/components/PlaylistSortPicker/PlaylistSortPicker.tsx b/plugins/playlist/src/components/PlaylistSortPicker/PlaylistSortPicker.tsx index 21c961eb91..01e3bd08ff 100644 --- a/plugins/playlist/src/components/PlaylistSortPicker/PlaylistSortPicker.tsx +++ b/plugins/playlist/src/components/PlaylistSortPicker/PlaylistSortPicker.tsx @@ -26,7 +26,7 @@ import SwapVertIcon from '@material-ui/icons/SwapVert'; import React from 'react'; import useEffectOnce from 'react-use/lib/useEffectOnce'; -import { usePlaylistList } from '../../hooks'; +import { usePlaylistList } from '../../hooks/usePlaylistList'; import { PlaylistSortCompareFunction } from '../../types'; export const enum DefaultPlaylistSortTypes {