remove some circular imports

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-06-20 21:15:14 +02:00
parent 07e8526b30
commit 68531cc70e
12 changed files with 82 additions and 53 deletions
+8
View File
@@ -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
@@ -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';
@@ -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 = {
@@ -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';
@@ -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}.
+5 -19
View File
@@ -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();
+35
View File
@@ -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]);
@@ -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 };
@@ -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';
+2 -3
View File
@@ -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';
+4 -1
View File
@@ -18,4 +18,7 @@ export {
EntityNomadJobVersionListCard,
EntityNomadAllocationListTable,
} from './plugin';
export { isNomadAllocationsAvailable, isNomadJobIDAvailable } from './Router';
export {
isNomadAllocationsAvailable,
isNomadJobIDAvailable,
} from './annotations';
@@ -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 {