Merge pull request #5676 from jrusso1020/jrusso/remove-circular-dependencies

Remove circular dependencies
This commit is contained in:
Fredrik Adelöw
2021-05-17 18:01:04 +02:00
committed by GitHub
78 changed files with 395 additions and 275 deletions
+1 -1
View File
@@ -16,7 +16,7 @@
import { ApiEntity } from '@backstage/catalog-model';
import { createApiRef } from '@backstage/core';
import { ApiDefinitionWidget } from './components';
import { ApiDefinitionWidget } from './components/ApiDefinitionCard/ApiDefinitionWidget';
export const apiDocsConfigRef = createApiRef<ApiDocsConfig>({
id: 'plugin.api-docs.config',
@@ -23,7 +23,7 @@ import {
AuthProviderConfig,
} from '../../providers/types';
import { InputError } from '@backstage/errors';
import { TokenIssuer } from '../../identity';
import { TokenIssuer } from '../../identity/types';
import { verifyNonce } from './helpers';
import { postMessageResponse, ensuresXRequestedWith } from '../flow';
import { OAuthHandlers, OAuthStartRequest, OAuthRefreshRequest } from './types';
@@ -39,7 +39,7 @@ import {
PassportDoneCallback,
} from '../../lib/passport';
import { AuthProviderFactory, RedirectInfo } from '../types';
import { TokenIssuer } from '../../identity';
import { TokenIssuer } from '../../identity/types';
type PrivateInfo = {
refreshToken: string;
@@ -28,7 +28,7 @@ import {
} from '../../lib/passport';
import { AuthProviderRouteHandlers, AuthProviderFactory } from '../types';
import { postMessageResponse } from '../../lib/flow';
import { TokenIssuer } from '../../identity';
import { TokenIssuer } from '../../identity/types';
type SamlInfo = {
fullProfile: any;
+1 -1
View File
@@ -19,7 +19,7 @@ import { CatalogApi } from '@backstage/catalog-client';
import { Config } from '@backstage/config';
import express from 'express';
import { Logger } from 'winston';
import { TokenIssuer } from '../identity';
import { TokenIssuer } from '../identity/types';
export type AuthProviderConfig = {
/**
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import React, { useEffect } from 'react';
import { useWorkflowRuns } from '../useWorkflowRuns';
import { WorkflowRun, WorkflowRunsTable } from '../WorkflowRunsTable';
import { useWorkflowRuns, WorkflowRun } from '../useWorkflowRuns';
import { WorkflowRunsTable } from '../WorkflowRunsTable';
import { Entity } from '@backstage/catalog-model';
import { useEntity } from '@backstage/plugin-catalog-react';
import { WorkflowRunStatus } from '../WorkflowRunStatus';
+1 -1
View File
@@ -17,7 +17,7 @@ import React from 'react';
import { Entity } from '@backstage/catalog-model';
import { useEntity } from '@backstage/plugin-catalog-react';
import { Routes, Route } from 'react-router';
import { rootRouteRef, buildRouteRef } from '../plugin';
import { rootRouteRef, buildRouteRef } from '../routes';
import { WorkflowRunDetails } from './WorkflowRunDetails';
import { WorkflowRunsTable } from './WorkflowRunsTable';
import { CLOUDBUILD_ANNOTATION } from './useProjectName';
@@ -19,26 +19,14 @@ import RetryIcon from '@material-ui/icons/Replay';
import GoogleIcon from '@material-ui/icons/CloudCircle';
import { Link as RouterLink, generatePath } from 'react-router-dom';
import { Table, TableColumn } from '@backstage/core';
import { useWorkflowRuns } from '../useWorkflowRuns';
import { useWorkflowRuns, WorkflowRun } from '../useWorkflowRuns';
import { WorkflowRunStatus } from '../WorkflowRunStatus';
import SyncIcon from '@material-ui/icons/Sync';
import { useProjectName } from '../useProjectName';
import { Entity } from '@backstage/catalog-model';
import { Substitutions } from '../../api/types';
import { buildRouteRef } from '../../plugin';
import { buildRouteRef } from '../../routes';
import moment from 'moment';
export type WorkflowRun = {
id: string;
message: string;
url?: string;
googleUrl?: string;
status: string;
substitutions: Substitutions;
createTime: string;
rerun: () => void;
};
const generatedColumns: TableColumn[] = [
{
title: 'Status',
@@ -14,4 +14,3 @@
* limitations under the License.
*/
export { WorkflowRunsTable, WorkflowRunsTableView } from './WorkflowRunsTable';
export type { WorkflowRun } from './WorkflowRunsTable';
@@ -15,10 +15,23 @@
*/
import { useState } from 'react';
import { useAsyncRetry } from 'react-use';
import { WorkflowRun } from './WorkflowRunsTable/WorkflowRunsTable';
import { cloudbuildApiRef } from '../api/CloudbuildApi';
import { useApi, errorApiRef } from '@backstage/core';
import { ActionsListWorkflowRunsForRepoResponseData } from '../api/types';
import {
ActionsListWorkflowRunsForRepoResponseData,
Substitutions,
} from '../api/types';
export type WorkflowRun = {
id: string;
message: string;
url?: string;
googleUrl?: string;
status: string;
substitutions: Substitutions;
createTime: string;
rerun: () => void;
};
export function useWorkflowRuns({ projectId }: { projectId: string }) {
const api = useApi(cloudbuildApiRef);
+1 -11
View File
@@ -15,23 +15,13 @@
*/
import {
createPlugin,
createRouteRef,
createApiFactory,
googleAuthApiRef,
createRoutableExtension,
createComponentExtension,
} from '@backstage/core';
import { cloudbuildApiRef, CloudbuildClient } from './api';
export const rootRouteRef = createRouteRef({
path: '',
title: 'Google Cloudbuild',
});
export const buildRouteRef = createRouteRef({
path: ':id',
title: 'Cloudbuild Run',
});
import { rootRouteRef } from './routes';
export const cloudbuildPlugin = createPlugin({
id: 'cloudbuild',
+26
View File
@@ -0,0 +1,26 @@
/*
* Copyright 2020 Spotify AB
*
* 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 { createRouteRef } from '@backstage/core';
export const rootRouteRef = createRouteRef({
path: '',
title: 'Google Cloudbuild',
});
export const buildRouteRef = createRouteRef({
path: ':id',
title: 'Cloudbuild Run',
});
@@ -34,8 +34,8 @@ import {
import ExternalLinkIcon from '@material-ui/icons/Launch';
import React, { useEffect } from 'react';
import { GITHUB_ACTIONS_ANNOTATION } from '../useProjectName';
import { useWorkflowRuns } from '../useWorkflowRuns';
import { WorkflowRun, WorkflowRunsTable } from '../WorkflowRunsTable';
import { useWorkflowRuns, WorkflowRun } from '../useWorkflowRuns';
import { WorkflowRunsTable } from '../WorkflowRunsTable';
import { WorkflowRunStatus } from '../WorkflowRunStatus';
const useStyles = makeStyles<Theme>({
@@ -17,7 +17,7 @@ import React from 'react';
import { Entity } from '@backstage/catalog-model';
import { useEntity } from '@backstage/plugin-catalog-react';
import { Routes, Route } from 'react-router';
import { rootRouteRef, buildRouteRef } from '../plugin';
import { rootRouteRef, buildRouteRef } from '../routes';
import { WorkflowRunDetails } from './WorkflowRunDetails';
import { WorkflowRunsTable } from './WorkflowRunsTable';
import { GITHUB_ACTIONS_ANNOTATION } from './useProjectName';
@@ -16,7 +16,7 @@
import { useApi, useRouteRefParams } from '@backstage/core';
import { useAsync } from 'react-use';
import { githubActionsApiRef } from '../../api';
import { buildRouteRef } from '../../plugin';
import { buildRouteRef } from '../../routes';
export const useWorkflowRunsDetails = ({
hostname,
@@ -32,32 +32,14 @@ import {
configApiRef,
useApi,
} from '@backstage/core';
import { useWorkflowRuns } from '../useWorkflowRuns';
import { useWorkflowRuns, WorkflowRun } from '../useWorkflowRuns';
import { WorkflowRunStatus } from '../WorkflowRunStatus';
import SyncIcon from '@material-ui/icons/Sync';
import { buildRouteRef } from '../../plugin';
import { buildRouteRef } from '../../routes';
import { useProjectName } from '../useProjectName';
import { Entity } from '@backstage/catalog-model';
import { readGitHubIntegrationConfigs } from '@backstage/integration';
export type WorkflowRun = {
workflowName: string;
id: string;
message: string;
url?: string;
githubUrl?: string;
source: {
branchName: string;
commit: {
hash: string;
url?: string;
};
};
status: string;
conclusion: string;
onReRunClick: () => void;
};
const generatedColumns: TableColumn[] = [
{
title: 'ID',
@@ -14,4 +14,3 @@
* limitations under the License.
*/
export { WorkflowRunsTable, WorkflowRunsTableView } from './WorkflowRunsTable';
export type { WorkflowRun } from './WorkflowRunsTable';
@@ -15,10 +15,27 @@
*/
import { useState } from 'react';
import { useAsyncRetry } from 'react-use';
import { WorkflowRun } from './WorkflowRunsTable/WorkflowRunsTable';
import { githubActionsApiRef } from '../api/GithubActionsApi';
import { useApi, errorApiRef } from '@backstage/core';
export type WorkflowRun = {
workflowName: string;
id: string;
message: string;
url?: string;
githubUrl?: string;
source: {
branchName: string;
commit: {
hash: string;
url?: string;
};
};
status: string;
conclusion: string;
onReRunClick: () => void;
};
export function useWorkflowRuns({
hostname,
owner,
+1 -13
View File
@@ -17,25 +17,13 @@
import {
configApiRef,
createPlugin,
createRouteRef,
createApiFactory,
githubAuthApiRef,
createRoutableExtension,
createComponentExtension,
} from '@backstage/core';
import { githubActionsApiRef, GithubActionsClient } from './api';
// TODO(freben): This is just a demo route for now
export const rootRouteRef = createRouteRef({
path: '',
title: 'GitHub Actions',
});
export const buildRouteRef = createRouteRef({
path: ':id',
params: ['id'],
title: 'GitHub Actions Workflow Run',
});
import { rootRouteRef } from './routes';
export const githubActionsPlugin = createPlugin({
id: 'github-actions',
+29
View File
@@ -0,0 +1,29 @@
/*
* Copyright 2020 Spotify AB
*
* 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 { createRouteRef } from '@backstage/core';
// TODO(freben): This is just a demo route for now
export const rootRouteRef = createRouteRef({
path: '',
title: 'GitHub Actions',
});
export const buildRouteRef = createRouteRef({
path: ':id',
params: ['id'],
title: 'GitHub Actions Workflow Run',
});
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { createLegacyActions } from './stages/legacy';
export * from './stages';
export * from './jobs';
export * from './actions';
@@ -17,5 +17,3 @@ export * from './prepare';
export * from './publish';
export * from './templater';
export * from './helpers';
export { createLegacyActions } from './legacy';
+1 -1
View File
@@ -23,7 +23,7 @@ import {
rootRouteRef,
rootDocsRouteRef,
rootCatalogDocsRouteRef,
} from './plugin';
} from './routes';
import { TechDocsHome } from './home/components/TechDocsHome';
import { TechDocsPage } from './reader/components/TechDocsPage';
import { EntityPageDocs } from './EntityPageDocs';
@@ -21,7 +21,7 @@ import { Entity } from '@backstage/catalog-model';
import { Button, ItemCardGrid, ItemCardHeader } from '@backstage/core';
import { Card, CardActions, CardContent, CardMedia } from '@material-ui/core';
import { rootDocsRouteRef } from '../../plugin';
import { rootDocsRouteRef } from '../../routes';
export const DocsCardGrid = ({
entities,
@@ -22,7 +22,7 @@ import { IconButton, Tooltip } from '@material-ui/core';
import ShareIcon from '@material-ui/icons/Share';
import { Table, EmptyState, Button, SubvalueCell, Link } from '@backstage/core';
import { Entity } from '@backstage/catalog-model';
import { rootDocsRouteRef } from '../../plugin';
import { rootDocsRouteRef } from '../../routes';
export const DocsTable = ({
entities,
+5 -16
View File
@@ -20,27 +20,16 @@ import {
createComponentExtension,
createPlugin,
createRoutableExtension,
createRouteRef,
discoveryApiRef,
identityApiRef,
} from '@backstage/core';
import { techdocsApiRef, techdocsStorageApiRef } from './api';
import { TechDocsClient, TechDocsStorageClient } from './client';
export const rootRouteRef = createRouteRef({
path: '',
title: 'TechDocs Landing Page',
});
export const rootDocsRouteRef = createRouteRef({
path: ':namespace/:kind/:name/*',
title: 'Docs',
});
export const rootCatalogDocsRouteRef = createRouteRef({
path: '*',
title: 'Docs',
});
import {
rootDocsRouteRef,
rootRouteRef,
rootCatalogDocsRouteRef,
} from './routes';
export const techdocsPlugin = createPlugin({
id: 'techdocs',
@@ -23,7 +23,7 @@ import React, { useEffect, useRef, useState } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
import { useAsync } from 'react-use';
import { techdocsStorageApiRef } from '../../api';
import transformer, {
import {
addBaseUrl,
addGitFeedbackLink,
addLinkClickListener,
@@ -33,6 +33,7 @@ import transformer, {
rewriteDocLinks,
sanitizeDOM,
simplifyMkdocsFooter,
transform as transformer,
} from '../transformers';
import { TechDocsNotFound } from './TechDocsNotFound';
import TechDocsProgressBar from './TechDocsProgressBar';
@@ -18,7 +18,7 @@ import { TechDocsPageHeader } from './TechDocsPageHeader';
import { act } from '@testing-library/react';
import { renderInTestApp } from '@backstage/test-utils';
import { entityRouteRef } from '@backstage/plugin-catalog-react';
import { rootRouteRef } from '../../plugin';
import { rootRouteRef } from '../../routes';
describe('<TechDocsPageHeader />', () => {
it('should render a techdocs page header', async () => {
@@ -24,7 +24,7 @@ import {
import CodeIcon from '@material-ui/icons/Code';
import React from 'react';
import { AsyncState } from 'react-use/lib/useAsync';
import { rootRouteRef } from '../../plugin';
import { rootRouteRef } from '../../routes';
import { TechDocsMetadata } from '../../types';
type TechDocsPageHeaderProps = {
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { EntityName } from '@backstage/catalog-model';
import type { Transformer } from './index';
import type { Transformer } from './transformer';
import { TechDocsStorageApi } from '../../api';
type AddBaseUrlOptions = {
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import type { Transformer } from './index';
import type { Transformer } from './transformer';
type AddLinkClickListenerOptions = {
baseUrl: string;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import transform, { Transformer } from './index';
import { Transformer, transform } from './transformer';
describe('transform', () => {
it('calls the transformers', () => {
@@ -23,30 +23,4 @@ export * from './simplifyMkdocsFooter';
export * from './onCssReady';
export * from './sanitizeDOM';
export * from './injectCss';
// TODO(freben): move all of this out of index
export type Transformer = (dom: Element) => Element;
function transform(
html: string | Element,
transformers: Transformer[],
): Element {
let dom: Element;
if (typeof html === 'string') {
dom = new DOMParser().parseFromString(html, 'text/html').documentElement;
} else if (html instanceof Element) {
dom = html;
} else {
throw new Error('dom is not a recognized type');
}
transformers.forEach(transformer => {
dom = transformer(dom);
});
return dom;
}
export default transform;
export * from './transformer';
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import type { Transformer } from './index';
import type { Transformer } from './transformer';
type InjectCssOptions = {
css: string;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import type { Transformer } from './index';
import type { Transformer } from './transformer';
type OnCssReadyOptions = {
docStorageUrl: Promise<string>;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import type { Transformer } from './index';
import type { Transformer } from './transformer';
export const removeMkdocsHeader = (): Transformer => {
return dom => {
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import type { Transformer } from './index';
import type { Transformer } from './transformer';
export const rewriteDocLinks = (): Transformer => {
return dom => {
@@ -16,7 +16,7 @@
// @ts-ignore
import sanitizeHtml from 'sanitize-html';
import type { Transformer } from '../index';
import type { Transformer } from '../transformer';
import { TECHDOCS_ALLOWED_TAGS } from './tags';
import { TECHDOCS_ALLOWED_ATTRIBUTES } from './attributes';
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import type { Transformer } from './index';
import type { Transformer } from './transformer';
export const simplifyMkdocsFooter = (): Transformer => {
return dom => {
@@ -0,0 +1,38 @@
/*
* Copyright 2020 Spotify AB
*
* 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.
*/
export type Transformer = (dom: Element) => Element;
export const transform = (
html: string | Element,
transformers: Transformer[],
): Element => {
let dom: Element;
if (typeof html === 'string') {
dom = new DOMParser().parseFromString(html, 'text/html').documentElement;
} else if (html instanceof Element) {
dom = html;
} else {
throw new Error('dom is not a recognized type');
}
transformers.forEach(transformer => {
dom = transformer(dom);
});
return dom;
};
+32
View File
@@ -0,0 +1,32 @@
/*
* Copyright 2020 Spotify AB
*
* 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 { createRouteRef } from '@backstage/core';
export const rootRouteRef = createRouteRef({
path: '',
title: 'TechDocs Landing Page',
});
export const rootDocsRouteRef = createRouteRef({
path: ':namespace/:kind/:name/*',
title: 'Docs',
});
export const rootCatalogDocsRouteRef = createRouteRef({
path: '*',
title: 'Docs',
});
+1 -1
View File
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import transformer from '../reader/transformers';
import type { Transformer } from '../reader/transformers';
import { transform as transformer } from '../reader/transformers';
export type CreateTestShadowDomOptions = {
preTransformers: Transformer[];