code-coverage: clean up exports

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-07-05 14:38:30 +02:00
parent bddec9bc0c
commit d70aaa7622
11 changed files with 67 additions and 45 deletions
+5 -15
View File
@@ -9,8 +9,6 @@ import { BackstagePlugin } from '@backstage/core-plugin-api';
import { Entity } from '@backstage/catalog-model';
import { RouteRef } from '@backstage/core-plugin-api';
// Warning: (ae-missing-release-tag) "codeCoveragePlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const codeCoveragePlugin: BackstagePlugin<
{
@@ -19,20 +17,12 @@ export const codeCoveragePlugin: BackstagePlugin<
{}
>;
// Warning: (ae-missing-release-tag) "EntityCodeCoverageContent" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
// @public
export const EntityCodeCoverageContent: () => JSX.Element;
// Warning: (ae-missing-release-tag) "isCodeCoverageAvailable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
const isCodeCoverageAvailable: (entity: Entity) => boolean;
export { isCodeCoverageAvailable };
export { isCodeCoverageAvailable as isPluginApplicableToEntity };
// @public
export function isCodeCoverageAvailable(entity: Entity): boolean;
// Warning: (ae-missing-release-tag) "Router" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const Router: () => JSX.Element;
// @public @deprecated (undocumented)
export const isPluginApplicableToEntity: typeof isCodeCoverageAvailable;
```
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import 'highlight.js/styles/atom-one-dark.css';
import highlight from 'highlight.js';
@@ -13,16 +13,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import { Entity } from '@backstage/catalog-model';
import { useEntity } from '@backstage/plugin-catalog-react';
import { CodeCoveragePage } from './CodeCoveragePage';
import { MissingAnnotationEmptyState } from '@backstage/core-components';
export const isCodeCoverageAvailable = (entity: Entity) =>
Boolean(entity.metadata.annotations?.['backstage.io/code-coverage']);
/**
* Returns true if the given entity has code coverage enabled.
*
* @public
*/
export function isCodeCoverageAvailable(entity: Entity) {
return Boolean(entity.metadata.annotations?.['backstage.io/code-coverage']);
}
export const Router = () => {
/**
* @public
*/
export const Router = (): JSX.Element => {
const { entity } = useEntity();
if (!isCodeCoverageAvailable(entity)) {
@@ -30,5 +40,6 @@ export const Router = () => {
<MissingAnnotationEmptyState annotation="backstage.io/code-coverage" />
);
}
return <CodeCoveragePage />;
};
+9 -5
View File
@@ -20,9 +20,13 @@
* @packageDocumentation
*/
import { isCodeCoverageAvailable } from './components/Router';
export { codeCoveragePlugin, EntityCodeCoverageContent } from './plugin';
export {
Router,
isCodeCoverageAvailable,
isCodeCoverageAvailable as isPluginApplicableToEntity,
} from './components/Router';
export { isCodeCoverageAvailable };
/**
* @public
* @deprecated Use `isPluginApplicableToEntity` instead.
*/
export const isPluginApplicableToEntity = isCodeCoverageAvailable;
+8
View File
@@ -23,6 +23,9 @@ import {
discoveryApiRef,
} from '@backstage/core-plugin-api';
/**
* @public
*/
export const codeCoveragePlugin = createPlugin({
id: 'code-coverage',
routes: {
@@ -37,6 +40,11 @@ export const codeCoveragePlugin = createPlugin({
],
});
/**
* An entity code coverage page.
*
* @public
*/
export const EntityCodeCoverageContent = codeCoveragePlugin.provide(
createRoutableExtension({
name: 'EntityCodeCoverageContent',