From 786117e98a86e68c7dde7d1fa4708f2e1f0a9a23 Mon Sep 17 00:00:00 2001 From: manusant Date: Wed, 2 Nov 2022 11:27:16 +0000 Subject: [PATCH 1/7] sonarqube improvements Signed-off-by: manusant --- .changeset/unlucky-pigs-end.md | 5 + plugins/sonarqube/api-report.md | 24 +++++ .../SonarQubeContentPage.test.tsx | 91 +++++++++++++++++++ .../SonarQubeContentPage.tsx | 57 ++++++++++++ .../components/SonarQubeContentPage/index.ts | 16 ++++ plugins/sonarqube/src/components/index.ts | 6 +- .../src/components/useProjectKey.test.ts | 32 +++++++ .../sonarqube/src/components/useProjectKey.ts | 16 +++- plugins/sonarqube/src/index.ts | 1 + plugins/sonarqube/src/plugin.ts | 13 +++ 10 files changed, 255 insertions(+), 6 deletions(-) create mode 100644 .changeset/unlucky-pigs-end.md create mode 100644 plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.test.tsx create mode 100644 plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.tsx create mode 100644 plugins/sonarqube/src/components/SonarQubeContentPage/index.ts diff --git a/.changeset/unlucky-pigs-end.md b/.changeset/unlucky-pigs-end.md new file mode 100644 index 0000000000..9a33827087 --- /dev/null +++ b/.changeset/unlucky-pigs-end.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-sonarqube': minor +--- + +Fix sonarqube annotation parsing. Add content page for Sonarqube. diff --git a/plugins/sonarqube/api-report.md b/plugins/sonarqube/api-report.md index e0a51479a4..3248dbbbed 100644 --- a/plugins/sonarqube/api-report.md +++ b/plugins/sonarqube/api-report.md @@ -8,6 +8,7 @@ import { BackstagePlugin } from '@backstage/core-plugin-api'; import { Entity } from '@backstage/catalog-model'; import { InfoCardVariants } from '@backstage/core-components'; +import { default as React_2 } from 'react'; // @public (undocumented) export type DuplicationRating = { @@ -21,15 +22,38 @@ export const EntitySonarQubeCard: (props: { duplicationRatings?: DuplicationRating[] | undefined; }) => JSX.Element; +// @public (undocumented) +export const EntitySonarQubeContentPage: ({ + title, + supportTitle, + ...otherProps +}: SonarQubeContentPageProps) => JSX.Element; + // @public (undocumented) export const isSonarQubeAvailable: (entity: Entity) => boolean; +// @public (undocumented) +export const SONARQUBE_PROJECT_KEY_ANNOTATION = 'sonarqube.org/project-key'; + // @public (undocumented) export const SonarQubeCard: (props: { variant?: InfoCardVariants; duplicationRatings?: DuplicationRating[]; }) => JSX.Element; +// @public (undocumented) +export const SonarQubeContentPage: ({ + title, + supportTitle, + ...otherProps +}: SonarQubeContentPageProps) => JSX.Element; + +// @public (undocumented) +export type SonarQubeContentPageProps = { + title?: string; + supportTitle?: string; +} & React_2.ComponentPropsWithoutRef<'div'>; + // @public (undocumented) const sonarQubePlugin: BackstagePlugin<{}, {}, {}>; export { sonarQubePlugin as plugin }; diff --git a/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.test.tsx b/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.test.tsx new file mode 100644 index 0000000000..8e847d7c31 --- /dev/null +++ b/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.test.tsx @@ -0,0 +1,91 @@ +/* + * Copyright 2020 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 { EntityProvider } from '@backstage/plugin-catalog-react'; +import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; +import { lightTheme } from '@backstage/theme'; +import { ThemeProvider } from '@material-ui/core'; +import React from 'react'; +import { + isSonarQubeAvailable, + SONARQUBE_PROJECT_KEY_ANNOTATION, +} from '../useProjectKey'; +import { SonarQubeApi, sonarQubeApiRef } from '../../api'; + +const Providers = ({ + annotation, + children, +}: { annotation: string } & React.PropsWithChildren): JSX.Element => ( + + + {children} + + +); + +describe('', () => { + beforeAll(() => { + jest.mock('@backstage/plugin-sonarqube', () => ({ + __esModule: true, + isSonarQubeAvailable, + EntitySonarQubeCard: () => { + return
; + }, + })); + }); + + it('renders EntitySonarQubeCard', async () => { + const { SonarQubeContentPage } = require('./SonarQubeContentPage'); + + const rendered = await renderInTestApp( + + + , + ); + expect(rendered.getByText('SonarQube Dashboard')).toBeInTheDocument(); + expect(rendered.getByText('No information to display')).toBeInTheDocument(); + expect( + rendered.getByText("There is no SonarQube project with key 'bar'."), + ).toBeInTheDocument(); + }, 15000); + + it('renders MissingAnnotationEmptyState if sonar annotation is missing', async () => { + const { SonarQubeContentPage } = require('./SonarQubeContentPage'); + + const rendered = await renderInTestApp( + + + , + ); + expect(rendered.getByText('Missing Annotation')).toBeInTheDocument(); + expect( + rendered.getAllByText(SONARQUBE_PROJECT_KEY_ANNOTATION, { exact: false }) + .length, + ).toBe(2); + }, 15000); +}); diff --git a/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.tsx b/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.tsx new file mode 100644 index 0000000000..124906bb12 --- /dev/null +++ b/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.tsx @@ -0,0 +1,57 @@ +/* + * Copyright 2020 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 { + Content, + ContentHeader, + SupportButton, +} from '@backstage/core-components'; +import { MissingAnnotationEmptyState } from '@backstage/core-components'; +import { useEntity } from '@backstage/plugin-catalog-react'; +import React from 'react'; +import { + isSonarQubeAvailable, + SONARQUBE_PROJECT_KEY_ANNOTATION, +} from '../useProjectKey'; +import { SonarQubeCard } from '../SonarQubeCard'; + +/** @public */ +export type SonarQubeContentPageProps = { + title?: string; + supportTitle?: string; +} & React.ComponentPropsWithoutRef<'div'>; + +/** @public */ +export const SonarQubeContentPage = ({ + title = 'SonarQube Dashboard', + supportTitle, + ...otherProps +}: SonarQubeContentPageProps) => { + const { entity } = useEntity(); + + return isSonarQubeAvailable(entity) ? ( + + + {supportTitle && {supportTitle}} + + + + ) : ( + + ); +}; diff --git a/plugins/sonarqube/src/components/SonarQubeContentPage/index.ts b/plugins/sonarqube/src/components/SonarQubeContentPage/index.ts new file mode 100644 index 0000000000..27c0c59365 --- /dev/null +++ b/plugins/sonarqube/src/components/SonarQubeContentPage/index.ts @@ -0,0 +1,16 @@ +/* + * Copyright 2022 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. + */ +export * from './SonarQubeContentPage'; diff --git a/plugins/sonarqube/src/components/index.ts b/plugins/sonarqube/src/components/index.ts index 7e58100efa..3edce60f37 100644 --- a/plugins/sonarqube/src/components/index.ts +++ b/plugins/sonarqube/src/components/index.ts @@ -15,4 +15,8 @@ */ export * from './SonarQubeCard'; -export { isSonarQubeAvailable } from './useProjectKey'; +export * from './SonarQubeContentPage'; +export { + isSonarQubeAvailable, + SONARQUBE_PROJECT_KEY_ANNOTATION, +} from './useProjectKey'; diff --git a/plugins/sonarqube/src/components/useProjectKey.test.ts b/plugins/sonarqube/src/components/useProjectKey.test.ts index 921e9455c0..8686ac82de 100644 --- a/plugins/sonarqube/src/components/useProjectKey.test.ts +++ b/plugins/sonarqube/src/components/useProjectKey.test.ts @@ -39,10 +39,12 @@ describe('isSonarQubeAvailable', () => { const entity = createDummyEntity('dummy'); expect(isSonarQubeAvailable(entity)).toBe(true); }); + it('returns false if sonarqube annotation empty', () => { const entity = createDummyEntity(''); expect(isSonarQubeAvailable(entity)).toBe(false); }); + it('returns false if sonarqube annotation not defined', () => { const entity = { apiVersion: '', @@ -59,6 +61,7 @@ describe('isSonarQubeAvailable', () => { describe('useProjectInfo', () => { const DUMMY_INSTANCE = 'dummyInstance'; const DUMMY_KEY = 'dummyKey'; + it('parse annotation with key and instance', () => { const entity = createDummyEntity( DUMMY_INSTANCE + SONARQUBE_PROJECT_INSTANCE_SEPARATOR + DUMMY_KEY, @@ -68,6 +71,33 @@ describe('useProjectInfo', () => { projectKey: DUMMY_KEY, }); }); + + it('parse annotation with instance, tenant/project-key', () => { + const DUMMY_KEY_WITH_TENANT = 'dummy-tenant/dummyKey'; + const entity = createDummyEntity( + DUMMY_INSTANCE + + SONARQUBE_PROJECT_INSTANCE_SEPARATOR + + DUMMY_KEY_WITH_TENANT, + ); + expect(useProjectInfo(entity)).toEqual({ + projectInstance: DUMMY_INSTANCE, + projectKey: DUMMY_KEY_WITH_TENANT, + }); + }); + + it('parse annotation with instance, tenant:project-key', () => { + const DUMMY_KEY_WITH_TENANT = 'dummy-tenant:dummyKey'; + const entity = createDummyEntity( + DUMMY_INSTANCE + + SONARQUBE_PROJECT_INSTANCE_SEPARATOR + + DUMMY_KEY_WITH_TENANT, + ); + expect(useProjectInfo(entity)).toEqual({ + projectInstance: DUMMY_INSTANCE, + projectKey: DUMMY_KEY_WITH_TENANT, + }); + }); + // compatibility with previous mono-instance sonarqube config it('parse annotation with only key', () => { const entity = createDummyEntity(DUMMY_KEY); @@ -76,6 +106,7 @@ describe('useProjectInfo', () => { projectKey: DUMMY_KEY, }); }); + it('handle empty annotation', () => { const entity = createDummyEntity(''); expect(useProjectInfo(entity)).toEqual({ @@ -83,6 +114,7 @@ describe('useProjectInfo', () => { projectKey: undefined, }); }); + it('handle non-existent annotation', () => { const entity = { apiVersion: '', diff --git a/plugins/sonarqube/src/components/useProjectKey.ts b/plugins/sonarqube/src/components/useProjectKey.ts index 59a572a6c4..20f7f03bb3 100644 --- a/plugins/sonarqube/src/components/useProjectKey.ts +++ b/plugins/sonarqube/src/components/useProjectKey.ts @@ -16,6 +16,7 @@ import { Entity } from '@backstage/catalog-model'; +/** @public */ export const SONARQUBE_PROJECT_KEY_ANNOTATION = 'sonarqube.org/project-key'; export const SONARQUBE_PROJECT_INSTANCE_SEPARATOR = '/'; @@ -42,11 +43,16 @@ export const useProjectInfo = ( const annotation = entity?.metadata.annotations?.[SONARQUBE_PROJECT_KEY_ANNOTATION]; if (annotation) { - if (annotation.indexOf(SONARQUBE_PROJECT_INSTANCE_SEPARATOR) > -1) { - [projectInstance, projectKey] = annotation.split( - SONARQUBE_PROJECT_INSTANCE_SEPARATOR, - 2, - ); + const instanceSeparatorIndex = annotation.indexOf( + SONARQUBE_PROJECT_INSTANCE_SEPARATOR, + ); + if (instanceSeparatorIndex > -1) { + // Examples: + // instanceA/projectA -> projectInstance = "instanceA" & projectKey = "projectA" + // instanceA/tenantA:projectA -> projectInstance = "instanceA" & projectKey = "tenantA:projectA" + // instanceA/tenantA/projectA -> projectInstance = "instanceA" & projectKey = "tenantA/projectA" + projectInstance = annotation.substring(0, instanceSeparatorIndex); + projectKey = annotation.substring(instanceSeparatorIndex + 1); } else { projectKey = annotation; } diff --git a/plugins/sonarqube/src/index.ts b/plugins/sonarqube/src/index.ts index 1e6f83aa49..8b2a4b86b8 100644 --- a/plugins/sonarqube/src/index.ts +++ b/plugins/sonarqube/src/index.ts @@ -26,4 +26,5 @@ export { sonarQubePlugin, sonarQubePlugin as plugin, EntitySonarQubeCard, + EntitySonarQubeContentPage, } from './plugin'; diff --git a/plugins/sonarqube/src/plugin.ts b/plugins/sonarqube/src/plugin.ts index 0ea62de492..5eb5ea82f3 100644 --- a/plugins/sonarqube/src/plugin.ts +++ b/plugins/sonarqube/src/plugin.ts @@ -52,3 +52,16 @@ export const EntitySonarQubeCard = sonarQubePlugin.provide( }, }), ); + +/** @public */ +export const EntitySonarQubeContentPage = sonarQubePlugin.provide( + createComponentExtension({ + name: 'EntitySonarQubeContentPage', + component: { + lazy: () => + import('./components/SonarQubeContentPage').then( + m => m.SonarQubeContentPage, + ), + }, + }), +); From f97835ff7b7aec6f598defdecd50273b765f4412 Mon Sep 17 00:00:00 2001 From: manusant Date: Wed, 2 Nov 2022 13:15:15 +0000 Subject: [PATCH 2/7] add missing type dependency Signed-off-by: manusant --- plugins/sonarqube/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/sonarqube/package.json b/plugins/sonarqube/package.json index b46cb5c0b1..5d91577fd8 100644 --- a/plugins/sonarqube/package.json +++ b/plugins/sonarqube/package.json @@ -59,7 +59,8 @@ "@testing-library/react": "^12.1.3", "@testing-library/user-event": "^14.0.0", "@types/node": "^16.11.26", - "msw": "^0.47.0" + "msw": "^0.47.0", + "@types/react": "^16.13.1 || ^17.0.0" }, "files": [ "dist", From f267548451366066598596e432ce5e48f21d328e Mon Sep 17 00:00:00 2001 From: manusant Date: Wed, 2 Nov 2022 13:29:42 +0000 Subject: [PATCH 3/7] update yarn lock Signed-off-by: manusant --- plugins/sonarqube/package.json | 4 ++-- yarn.lock | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/sonarqube/package.json b/plugins/sonarqube/package.json index 5d91577fd8..99f059a016 100644 --- a/plugins/sonarqube/package.json +++ b/plugins/sonarqube/package.json @@ -59,8 +59,8 @@ "@testing-library/react": "^12.1.3", "@testing-library/user-event": "^14.0.0", "@types/node": "^16.11.26", - "msw": "^0.47.0", - "@types/react": "^16.13.1 || ^17.0.0" + "@types/react": "^16.13.1 || ^17.0.0", + "msw": "^0.47.0" }, "files": [ "dist", diff --git a/yarn.lock b/yarn.lock index c42aac2eec..6ab3c2300a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7261,6 +7261,7 @@ __metadata: "@testing-library/react": ^12.1.3 "@testing-library/user-event": ^14.0.0 "@types/node": ^16.11.26 + "@types/react": ^16.13.1 || ^17.0.0 cross-fetch: ^3.1.5 msw: ^0.47.0 rc-progress: 3.4.0 From af951b40aa731f4a39dd7692d72403e49676bfef Mon Sep 17 00:00:00 2001 From: manusant Date: Thu, 3 Nov 2022 14:39:17 +0000 Subject: [PATCH 4/7] move type dependency Signed-off-by: manusant --- plugins/sonarqube/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/sonarqube/package.json b/plugins/sonarqube/package.json index 99f059a016..89cbb0c049 100644 --- a/plugins/sonarqube/package.json +++ b/plugins/sonarqube/package.json @@ -45,7 +45,8 @@ "@material-ui/styles": "^4.10.0", "cross-fetch": "^3.1.5", "rc-progress": "3.4.0", - "react-use": "^17.2.4" + "react-use": "^17.2.4", + "@types/react": "^16.13.1 || ^17.0.0" }, "peerDependencies": { "react": "^16.13.1 || ^17.0.0" @@ -59,7 +60,6 @@ "@testing-library/react": "^12.1.3", "@testing-library/user-event": "^14.0.0", "@types/node": "^16.11.26", - "@types/react": "^16.13.1 || ^17.0.0", "msw": "^0.47.0" }, "files": [ From ece8c70bb221726f353e0c0d830e58cd6a273473 Mon Sep 17 00:00:00 2001 From: manusant Date: Wed, 9 Nov 2022 16:25:10 +0000 Subject: [PATCH 5/7] API report cleanup Signed-off-by: manusant --- plugins/sonarqube/api-report.md | 24 ++++--------------- plugins/sonarqube/package.json | 3 +-- .../SonarQubeContentPage.tsx | 13 ++++------ plugins/sonarqube/src/index.ts | 8 ++++++- yarn.lock | 1 - 5 files changed, 17 insertions(+), 32 deletions(-) diff --git a/plugins/sonarqube/api-report.md b/plugins/sonarqube/api-report.md index 3248dbbbed..48cd38e97c 100644 --- a/plugins/sonarqube/api-report.md +++ b/plugins/sonarqube/api-report.md @@ -8,7 +8,6 @@ import { BackstagePlugin } from '@backstage/core-plugin-api'; import { Entity } from '@backstage/catalog-model'; import { InfoCardVariants } from '@backstage/core-components'; -import { default as React_2 } from 'react'; // @public (undocumented) export type DuplicationRating = { @@ -23,11 +22,9 @@ export const EntitySonarQubeCard: (props: { }) => JSX.Element; // @public (undocumented) -export const EntitySonarQubeContentPage: ({ - title, - supportTitle, - ...otherProps -}: SonarQubeContentPageProps) => JSX.Element; +export const EntitySonarQubeContentPage: ( + props: SonarQubeContentPageProps, +) => JSX.Element; // @public (undocumented) export const isSonarQubeAvailable: (entity: Entity) => boolean; @@ -35,24 +32,11 @@ export const isSonarQubeAvailable: (entity: Entity) => boolean; // @public (undocumented) export const SONARQUBE_PROJECT_KEY_ANNOTATION = 'sonarqube.org/project-key'; -// @public (undocumented) -export const SonarQubeCard: (props: { - variant?: InfoCardVariants; - duplicationRatings?: DuplicationRating[]; -}) => JSX.Element; - -// @public (undocumented) -export const SonarQubeContentPage: ({ - title, - supportTitle, - ...otherProps -}: SonarQubeContentPageProps) => JSX.Element; - // @public (undocumented) export type SonarQubeContentPageProps = { title?: string; supportTitle?: string; -} & React_2.ComponentPropsWithoutRef<'div'>; +}; // @public (undocumented) const sonarQubePlugin: BackstagePlugin<{}, {}, {}>; diff --git a/plugins/sonarqube/package.json b/plugins/sonarqube/package.json index 89cbb0c049..b46cb5c0b1 100644 --- a/plugins/sonarqube/package.json +++ b/plugins/sonarqube/package.json @@ -45,8 +45,7 @@ "@material-ui/styles": "^4.10.0", "cross-fetch": "^3.1.5", "rc-progress": "3.4.0", - "react-use": "^17.2.4", - "@types/react": "^16.13.1 || ^17.0.0" + "react-use": "^17.2.4" }, "peerDependencies": { "react": "^16.13.1 || ^17.0.0" diff --git a/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.tsx b/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.tsx index 124906bb12..c11fff7237 100644 --- a/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.tsx +++ b/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.tsx @@ -32,19 +32,16 @@ import { SonarQubeCard } from '../SonarQubeCard'; export type SonarQubeContentPageProps = { title?: string; supportTitle?: string; -} & React.ComponentPropsWithoutRef<'div'>; +}; /** @public */ -export const SonarQubeContentPage = ({ - title = 'SonarQube Dashboard', - supportTitle, - ...otherProps -}: SonarQubeContentPageProps) => { +export const SonarQubeContentPage = (props: SonarQubeContentPageProps) => { const { entity } = useEntity(); + const { title, supportTitle } = props; return isSonarQubeAvailable(entity) ? ( - - + + {supportTitle && {supportTitle}} diff --git a/plugins/sonarqube/src/index.ts b/plugins/sonarqube/src/index.ts index 8b2a4b86b8..9936cc04e9 100644 --- a/plugins/sonarqube/src/index.ts +++ b/plugins/sonarqube/src/index.ts @@ -21,7 +21,13 @@ * @packageDocumentation */ -export * from './components'; +export type { + DuplicationRating, + SonarQubeContentPageProps, + SONARQUBE_PROJECT_KEY_ANNOTATION, + isSonarQubeAvailable, +} from './components'; + export { sonarQubePlugin, sonarQubePlugin as plugin, diff --git a/yarn.lock b/yarn.lock index 6ab3c2300a..c42aac2eec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7261,7 +7261,6 @@ __metadata: "@testing-library/react": ^12.1.3 "@testing-library/user-event": ^14.0.0 "@types/node": ^16.11.26 - "@types/react": ^16.13.1 || ^17.0.0 cross-fetch: ^3.1.5 msw: ^0.47.0 rc-progress: 3.4.0 From a4a7166fd0ccb66addb80792f8c926b56050488e Mon Sep 17 00:00:00 2001 From: manusant Date: Thu, 10 Nov 2022 10:13:57 +0000 Subject: [PATCH 6/7] Cleanup exports Signed-off-by: manusant --- plugins/sonarqube/api-report.md | 15 ++++++++++++--- .../src/components/SonarQubeContentPage/index.ts | 3 ++- plugins/sonarqube/src/components/index.ts | 6 ++++-- plugins/sonarqube/src/index.ts | 15 ++------------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/plugins/sonarqube/api-report.md b/plugins/sonarqube/api-report.md index 48cd38e97c..df9601ea8f 100644 --- a/plugins/sonarqube/api-report.md +++ b/plugins/sonarqube/api-report.md @@ -32,6 +32,17 @@ export const isSonarQubeAvailable: (entity: Entity) => boolean; // @public (undocumented) export const SONARQUBE_PROJECT_KEY_ANNOTATION = 'sonarqube.org/project-key'; +// @public (undocumented) +export const SonarQubeCard: (props: { + variant?: InfoCardVariants; + duplicationRatings?: DuplicationRating[]; +}) => JSX.Element; + +// @public (undocumented) +export const SonarQubeContentPage: ( + props: SonarQubeContentPageProps, +) => JSX.Element; + // @public (undocumented) export type SonarQubeContentPageProps = { title?: string; @@ -39,7 +50,5 @@ export type SonarQubeContentPageProps = { }; // @public (undocumented) -const sonarQubePlugin: BackstagePlugin<{}, {}, {}>; -export { sonarQubePlugin as plugin }; -export { sonarQubePlugin }; +export const sonarQubePlugin: BackstagePlugin<{}, {}, {}>; ``` diff --git a/plugins/sonarqube/src/components/SonarQubeContentPage/index.ts b/plugins/sonarqube/src/components/SonarQubeContentPage/index.ts index 27c0c59365..59327e9a88 100644 --- a/plugins/sonarqube/src/components/SonarQubeContentPage/index.ts +++ b/plugins/sonarqube/src/components/SonarQubeContentPage/index.ts @@ -13,4 +13,5 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export * from './SonarQubeContentPage'; +export { SonarQubeContentPage } from './SonarQubeContentPage'; +export type { SonarQubeContentPageProps } from './SonarQubeContentPage'; diff --git a/plugins/sonarqube/src/components/index.ts b/plugins/sonarqube/src/components/index.ts index 3edce60f37..3cb54da601 100644 --- a/plugins/sonarqube/src/components/index.ts +++ b/plugins/sonarqube/src/components/index.ts @@ -14,8 +14,10 @@ * limitations under the License. */ -export * from './SonarQubeCard'; -export * from './SonarQubeContentPage'; +export { SonarQubeCard } from './SonarQubeCard'; +export type { DuplicationRating } from './SonarQubeCard'; +export { SonarQubeContentPage } from './SonarQubeContentPage'; +export type { SonarQubeContentPageProps } from './SonarQubeContentPage'; export { isSonarQubeAvailable, SONARQUBE_PROJECT_KEY_ANNOTATION, diff --git a/plugins/sonarqube/src/index.ts b/plugins/sonarqube/src/index.ts index 9936cc04e9..30f6351d4d 100644 --- a/plugins/sonarqube/src/index.ts +++ b/plugins/sonarqube/src/index.ts @@ -21,16 +21,5 @@ * @packageDocumentation */ -export type { - DuplicationRating, - SonarQubeContentPageProps, - SONARQUBE_PROJECT_KEY_ANNOTATION, - isSonarQubeAvailable, -} from './components'; - -export { - sonarQubePlugin, - sonarQubePlugin as plugin, - EntitySonarQubeCard, - EntitySonarQubeContentPage, -} from './plugin'; +export * from './components'; +export * from './plugin'; From b94af16ac85cc9626e2051a0d19018c6d10d012a Mon Sep 17 00:00:00 2001 From: manusant Date: Thu, 10 Nov 2022 16:08:42 +0000 Subject: [PATCH 7/7] Updates according PR commentas Signed-off-by: manusant --- .changeset/unlucky-pigs-end.md | 1 + plugins/sonarqube/api-report.md | 5 ----- .../components/SonarQubeContentPage/SonarQubeContentPage.tsx | 1 - plugins/sonarqube/src/components/index.ts | 1 - 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.changeset/unlucky-pigs-end.md b/.changeset/unlucky-pigs-end.md index 9a33827087..7088a92c48 100644 --- a/.changeset/unlucky-pigs-end.md +++ b/.changeset/unlucky-pigs-end.md @@ -3,3 +3,4 @@ --- Fix sonarqube annotation parsing. Add content page for Sonarqube. +Removed the deprecated `plugin` export; please use `sonarQubePlugin` instead. diff --git a/plugins/sonarqube/api-report.md b/plugins/sonarqube/api-report.md index df9601ea8f..2edf80618e 100644 --- a/plugins/sonarqube/api-report.md +++ b/plugins/sonarqube/api-report.md @@ -38,11 +38,6 @@ export const SonarQubeCard: (props: { duplicationRatings?: DuplicationRating[]; }) => JSX.Element; -// @public (undocumented) -export const SonarQubeContentPage: ( - props: SonarQubeContentPageProps, -) => JSX.Element; - // @public (undocumented) export type SonarQubeContentPageProps = { title?: string; diff --git a/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.tsx b/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.tsx index c11fff7237..33a145b746 100644 --- a/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.tsx +++ b/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.tsx @@ -34,7 +34,6 @@ export type SonarQubeContentPageProps = { supportTitle?: string; }; -/** @public */ export const SonarQubeContentPage = (props: SonarQubeContentPageProps) => { const { entity } = useEntity(); const { title, supportTitle } = props; diff --git a/plugins/sonarqube/src/components/index.ts b/plugins/sonarqube/src/components/index.ts index 3cb54da601..8e1d93f85b 100644 --- a/plugins/sonarqube/src/components/index.ts +++ b/plugins/sonarqube/src/components/index.ts @@ -16,7 +16,6 @@ export { SonarQubeCard } from './SonarQubeCard'; export type { DuplicationRating } from './SonarQubeCard'; -export { SonarQubeContentPage } from './SonarQubeContentPage'; export type { SonarQubeContentPageProps } from './SonarQubeContentPage'; export { isSonarQubeAvailable,