@backstage-community/plugin-tech-insights-react 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # @backstage-community/plugin-tech-insights-react
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e919e53: Backstage version bump to v1.35.1
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [f015469]
12
+ - Updated dependencies [e919e53]
13
+ - Updated dependencies [c107e0f]
14
+ - @backstage-community/plugin-tech-insights-common@0.5.0
package/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # @backstage-community/plugin-tech-insights-react
2
+
3
+ The tech-insights web library contains reusable frontend components and a reference implementation for the tech-insights api.
4
+
5
+ ## Rendering custom tech insights views
6
+
7
+ If you create a custom view which renders tech-insights results, you can use the `ResultCheckIcon`, which also (by default) is clickable and opens a popup menu with links for this particular check and entity.
8
+
9
+ You can also render the icon using the tech-insights renderer or pass the `disableLinksMenu` prop to `ResultCheckIcon` to disable the menu, and render it elsewhere, by importing `ResultLinksMenu`.
10
+
11
+ ### Render the check icon with a popup menu for links
12
+
13
+ ```tsx
14
+ import { ResultCheckIcon } from '@backstage-community/plugin-tech-insights-react';
15
+
16
+ export const MyComponent = () => {
17
+ const entity = getEntitySomehow();
18
+ const result = getCheckResultSomehow();
19
+
20
+ return <ResultCheckIcon result={result} entity={entity} />;
21
+ };
22
+ ```
23
+
24
+ ### Render the popup menu for links
25
+
26
+ You can render a custom component (like a button) which opens the popup menu with links.
27
+
28
+ The menu will be anchored to an element, likely the button being pressed, or icon being clicked. The `setMenu` prop is used to get a function to open the menu.
29
+
30
+ ```tsx
31
+ import {
32
+ TechInsightsLinksMenu,
33
+ ResultLinksMenuInfo,
34
+ } from '@backstage-community/plugin-tech-insights';
35
+
36
+ export const MyComponent = () => {
37
+ const entity = getEntitySomehow();
38
+ const result = getCheckResultSomehow();
39
+
40
+ const [menu, setMenu] = useState<ResultLinksMenuInfo | undefined>();
41
+
42
+ return (
43
+ <>
44
+ <Button
45
+ title="Show links"
46
+ disabled={!menu}
47
+ onClick={event => menu?.open(event.currentTarget)}
48
+ />
49
+ <TechInsightsLinksMenu
50
+ result={result}
51
+ entity={entity}
52
+ setMenu={setMenu}
53
+ />
54
+ </>
55
+ );
56
+ };
57
+ ```
58
+
59
+ ### Adding custom rendering components
60
+
61
+ Default implementation displays only `json-rules-engine` check results. If you would like to support different types, you need to inject custom rendering components to the `TechInsightsClient` constructor.
62
+
63
+ ```ts
64
+ // packages/app/src/apis.ts
65
+
66
+ export const apis: AnyApiFactory[] = [
67
+ ...
68
+ createApiFactory({
69
+ api: techInsightsApiRef,
70
+ deps: { discoveryApi: discoveryApiRef, identityApi: identityApiRef },
71
+ factory: ({ discoveryApi, identityApi }) =>
72
+ new TechInsightsClient({
73
+ discoveryApi,
74
+ identityApi,
75
+ renderers: [
76
+ jsonRulesEngineCheckResultRenderer, // default json-rules-engine renderer
77
+ myCustomBooleanRenderer, // custom renderer
78
+ ],
79
+ }),
80
+ }),
81
+ ...
82
+ ];
83
+ ```
84
+
85
+ ```tsx
86
+ // packages/app/src/components/myCustomBooleanRenderer.tsx
87
+ import { BooleanCheck } from '@backstage-community/plugin-tech-insights-react';
88
+ ...
89
+
90
+ export const myCustomBooleanRenderer: CheckResultRenderer = {
91
+ type: 'boolean',
92
+ component: (checkResult: CheckResult) => (
93
+ <BooleanCheck checkResult={checkResult} />
94
+ ),
95
+ };
96
+ ```
97
+
98
+ ### Customizing the description
99
+
100
+ It's possible to customize the description with either a string or a React component. For example, displaying additional information if the check has failed.
101
+
102
+ ```tsx
103
+ // packages/app/src/components/myCustomBooleanRenderer.tsx
104
+
105
+ export const myCustomBooleanRenderer: CheckResultRenderer = {
106
+ type: 'boolean',
107
+ component: (checkResult: CheckResult) => (
108
+ <BooleanCheck checkResult={checkResult} />
109
+ ),
110
+ description: (checkResult: CheckResult) => (
111
+ <>
112
+ {
113
+ checkResult.result
114
+ ? checkResult.check.description // In case of success, return the same description
115
+ : `The check has failed! ${checkResult.check.description}` // Add a prefix text if the check failed
116
+ }
117
+ </>
118
+ ),
119
+ };
120
+ ```
@@ -0,0 +1,8 @@
1
+ import { createApiRef } from '@backstage/core-plugin-api';
2
+
3
+ const techInsightsApiRef = createApiRef({
4
+ id: "plugin.techinsights.service"
5
+ });
6
+
7
+ export { techInsightsApiRef };
8
+ //# sourceMappingURL=TechInsightsApi.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TechInsightsApi.esm.js","sources":["../../src/api/TechInsightsApi.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport {\n CheckResult,\n BulkCheckResponse,\n FactSchema,\n CheckLink,\n Check,\n InsightFacts,\n} from '@backstage-community/plugin-tech-insights-common';\nimport { CheckResultRenderer } from '../components/CheckResultRenderer';\nimport { CompoundEntityRef, Entity } from '@backstage/catalog-model';\n\n/**\n * {@link @backstage/core-plugin-api#ApiRef} for the {@link TechInsightsApi}\n *\n * @public\n */\nexport const techInsightsApiRef = createApiRef<TechInsightsApi>({\n id: 'plugin.techinsights.service',\n});\n\n/**\n * Tech Insights API client interface\n *\n * @public\n */\nexport interface TechInsightsApi {\n getCheckResultRenderers: (types: string[]) => CheckResultRenderer[];\n isCheckResultFailed: (check: CheckResult) => boolean;\n getAllChecks(): Promise<Check[]>;\n runChecks(\n entityParams: CompoundEntityRef,\n checks?: string[],\n ): Promise<CheckResult[]>;\n runBulkChecks(\n entities: CompoundEntityRef[],\n checks?: Check[],\n ): Promise<BulkCheckResponse>;\n getFacts(entity: CompoundEntityRef, facts: string[]): Promise<InsightFacts>;\n getFactSchemas(): Promise<FactSchema[]>;\n getLinksForEntity(\n result: CheckResult,\n entity: Entity,\n options?: { includeStaticLinks?: boolean },\n ): CheckLink[];\n}\n"],"names":[],"mappings":";;AAiCO,MAAM,qBAAqB,YAA8B,CAAA;AAAA,EAC9D,EAAI,EAAA;AACN,CAAC;;;;"}
@@ -0,0 +1,61 @@
1
+ import { TechInsightsClient as TechInsightsClient$1 } from '@backstage-community/plugin-tech-insights-common/client';
2
+ import { jsonRulesEngineCheckResultRenderer } from '../components/CheckResultRenderer.esm.js';
3
+
4
+ class TechInsightsClient extends TechInsightsClient$1 {
5
+ renderers;
6
+ customGetEntityLinks;
7
+ constructor(options) {
8
+ super(options);
9
+ this.renderers = options.renderers;
10
+ this.customGetEntityLinks = options.getEntityLinks ?? (() => []);
11
+ }
12
+ /**
13
+ * Get the check result renderers for the given check types.
14
+ *
15
+ * @param types - The types of checks to get renderers for
16
+ * @returns An array of check result renderers
17
+ *
18
+ * @public
19
+ */
20
+ getCheckResultRenderers(types) {
21
+ const renderers = this.renderers ?? [jsonRulesEngineCheckResultRenderer];
22
+ return renderers.filter((d) => types.includes(d.type));
23
+ }
24
+ /**
25
+ * Determine if a check result represents a failure.
26
+ *
27
+ * @param check - The check result to evaluate
28
+ * @returns true if the check result represents a failure, false otherwise
29
+ *
30
+ * @public
31
+ */
32
+ isCheckResultFailed(check) {
33
+ const checkResultRenderers = this.getCheckResultRenderers([
34
+ check.check.type
35
+ ]);
36
+ if (checkResultRenderers[0] && checkResultRenderers[0].isFailed) {
37
+ return checkResultRenderers[0].isFailed(check);
38
+ }
39
+ return true;
40
+ }
41
+ /**
42
+ * Get the links for a given check result and entity.
43
+ *
44
+ * @param result - The check result to get links for
45
+ * @param entity - The entity to get links for
46
+ * @param options - Optional options for the links
47
+ * @returns An array of check links
48
+ *
49
+ * @public
50
+ */
51
+ getLinksForEntity(result, entity, options = {}) {
52
+ const links = this.customGetEntityLinks(result, entity);
53
+ if (options.includeStaticLinks) {
54
+ links.push(...result.check.links ?? []);
55
+ }
56
+ return links;
57
+ }
58
+ }
59
+
60
+ export { TechInsightsClient };
61
+ //# sourceMappingURL=TechInsightsClient.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TechInsightsClient.esm.js","sources":["../../src/api/TechInsightsClient.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TechInsightsApi } from './TechInsightsApi';\nimport { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';\nimport { TechInsightsClient as TechInsightsClientBase } from '@backstage-community/plugin-tech-insights-common/client';\nimport {\n CheckLink,\n CheckResult,\n} from '@backstage-community/plugin-tech-insights-common';\nimport {\n CheckResultRenderer,\n jsonRulesEngineCheckResultRenderer,\n} from '../components/CheckResultRenderer';\nimport { Entity } from '@backstage/catalog-model';\n\n/**\n * Implementation of the {@link TechInsightsApi} interface.\n *\n * @public\n */\nexport class TechInsightsClient\n extends TechInsightsClientBase\n implements TechInsightsApi\n{\n private readonly renderers?: CheckResultRenderer[];\n private readonly customGetEntityLinks: (\n result: CheckResult,\n entity: Entity,\n ) => CheckLink[];\n\n constructor(options: {\n discoveryApi: DiscoveryApi;\n identityApi: IdentityApi;\n renderers?: CheckResultRenderer[];\n getEntityLinks?: (result: CheckResult, entity: Entity) => CheckLink[];\n }) {\n super(options);\n this.renderers = options.renderers;\n this.customGetEntityLinks = options.getEntityLinks ?? (() => []);\n }\n\n /**\n * Get the check result renderers for the given check types.\n *\n * @param types - The types of checks to get renderers for\n * @returns An array of check result renderers\n *\n * @public\n */\n getCheckResultRenderers(types: string[]): CheckResultRenderer[] {\n const renderers = this.renderers ?? [jsonRulesEngineCheckResultRenderer];\n return renderers.filter(d => types.includes(d.type));\n }\n\n /**\n * Determine if a check result represents a failure.\n *\n * @param check - The check result to evaluate\n * @returns true if the check result represents a failure, false otherwise\n *\n * @public\n */\n isCheckResultFailed(check: CheckResult) {\n const checkResultRenderers = this.getCheckResultRenderers([\n check.check.type,\n ]);\n if (checkResultRenderers[0] && checkResultRenderers[0].isFailed) {\n return checkResultRenderers[0].isFailed(check);\n }\n return true;\n }\n\n /**\n * Get the links for a given check result and entity.\n *\n * @param result - The check result to get links for\n * @param entity - The entity to get links for\n * @param options - Optional options for the links\n * @returns An array of check links\n *\n * @public\n */\n getLinksForEntity(\n result: CheckResult,\n entity: Entity,\n options: { includeStaticLinks?: boolean } = {},\n ): CheckLink[] {\n const links = this.customGetEntityLinks(result, entity);\n if (options.includeStaticLinks) {\n links.push(...(result.check.links ?? []));\n }\n return links;\n }\n}\n"],"names":["TechInsightsClientBase"],"mappings":";;;AAkCO,MAAM,2BACHA,oBAEV,CAAA;AAAA,EACmB,SAAA;AAAA,EACA,oBAAA;AAAA,EAKjB,YAAY,OAKT,EAAA;AACD,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,YAAY,OAAQ,CAAA,SAAA;AACzB,IAAA,IAAA,CAAK,oBAAuB,GAAA,OAAA,CAAQ,cAAmB,KAAA,MAAM,EAAC,CAAA;AAAA;AAChE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,wBAAwB,KAAwC,EAAA;AAC9D,IAAA,MAAM,SAAY,GAAA,IAAA,CAAK,SAAa,IAAA,CAAC,kCAAkC,CAAA;AACvE,IAAA,OAAO,UAAU,MAAO,CAAA,CAAA,CAAA,KAAK,MAAM,QAAS,CAAA,CAAA,CAAE,IAAI,CAAC,CAAA;AAAA;AACrD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,oBAAoB,KAAoB,EAAA;AACtC,IAAM,MAAA,oBAAA,GAAuB,KAAK,uBAAwB,CAAA;AAAA,MACxD,MAAM,KAAM,CAAA;AAAA,KACb,CAAA;AACD,IAAA,IAAI,qBAAqB,CAAC,CAAA,IAAK,oBAAqB,CAAA,CAAC,EAAE,QAAU,EAAA;AAC/D,MAAA,OAAO,oBAAqB,CAAA,CAAC,CAAE,CAAA,QAAA,CAAS,KAAK,CAAA;AAAA;AAE/C,IAAO,OAAA,IAAA;AAAA;AACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,iBACE,CAAA,MAAA,EACA,MACA,EAAA,OAAA,GAA4C,EAC/B,EAAA;AACb,IAAA,MAAM,KAAQ,GAAA,IAAA,CAAK,oBAAqB,CAAA,MAAA,EAAQ,MAAM,CAAA;AACtD,IAAA,IAAI,QAAQ,kBAAoB,EAAA;AAC9B,MAAA,KAAA,CAAM,KAAK,GAAI,MAAA,CAAO,KAAM,CAAA,KAAA,IAAS,EAAG,CAAA;AAAA;AAE1C,IAAO,OAAA,KAAA;AAAA;AAEX;;;;"}
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import CheckCircleOutline from '@material-ui/icons/CheckCircleOutline';
3
+ import ErrorOutlineIcon from '@material-ui/icons/ErrorOutline';
4
+
5
+ const BooleanCheck = (props) => {
6
+ return !!props.checkResult.result ? /* @__PURE__ */ React.createElement(CheckCircleOutline, { color: "primary" }) : /* @__PURE__ */ React.createElement(ErrorOutlineIcon, { color: "error" });
7
+ };
8
+ const isBooleanCheckFailed = (checkResult) => !checkResult.result;
9
+
10
+ export { BooleanCheck, isBooleanCheckFailed };
11
+ //# sourceMappingURL=BooleanCheck.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BooleanCheck.esm.js","sources":["../../../src/components/BooleanCheck/BooleanCheck.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport CheckCircleOutline from '@material-ui/icons/CheckCircleOutline';\nimport ErrorOutlineIcon from '@material-ui/icons/ErrorOutline';\nimport { CheckResult } from '@backstage-community/plugin-tech-insights-common';\n\n/**\n * A component that renders a boolean check result as either a success or failure icon.\n *\n * @public\n */\nexport const BooleanCheck = (props: { checkResult: CheckResult }) => {\n return !!props.checkResult.result ? (\n <CheckCircleOutline color=\"primary\" />\n ) : (\n <ErrorOutlineIcon color=\"error\" />\n );\n};\n\n/**\n * Helper function to determine if a boolean check result represents a failure.\n *\n * @returns true if the check result represents a failure (result is false), false otherwise\n *\n * @public\n */\nexport const isBooleanCheckFailed = (checkResult: CheckResult) =>\n !checkResult.result;\n"],"names":[],"mappings":";;;;AAyBa,MAAA,YAAA,GAAe,CAAC,KAAwC,KAAA;AACnE,EAAA,OAAO,CAAC,CAAC,KAAM,CAAA,WAAA,CAAY,MACzB,mBAAA,KAAA,CAAA,aAAA,CAAC,kBAAmB,EAAA,EAAA,KAAA,EAAM,SAAU,EAAA,CAAA,mBAEnC,KAAA,CAAA,aAAA,CAAA,gBAAA,EAAA,EAAiB,OAAM,OAAQ,EAAA,CAAA;AAEpC;AASO,MAAM,oBAAuB,GAAA,CAAC,WACnC,KAAA,CAAC,WAAY,CAAA;;;;"}
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { BooleanCheck, isBooleanCheckFailed } from './BooleanCheck/BooleanCheck.esm.js';
3
+
4
+ const jsonRulesEngineCheckResultRenderer = {
5
+ type: "json-rules-engine",
6
+ component: (checkResult) => /* @__PURE__ */ React.createElement(BooleanCheck, { checkResult }),
7
+ isFailed: isBooleanCheckFailed
8
+ };
9
+
10
+ export { jsonRulesEngineCheckResultRenderer };
11
+ //# sourceMappingURL=CheckResultRenderer.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckResultRenderer.esm.js","sources":["../../src/components/CheckResultRenderer.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { CheckResult } from '@backstage-community/plugin-tech-insights-common';\nimport { BooleanCheck, isBooleanCheckFailed } from './BooleanCheck';\n\n/**\n * Defines a react component that is responsible for rendering a result of a given type.\n *\n * @public\n */\nexport type CheckResultRenderer = {\n type: string;\n component: (check: CheckResult) => React.ReactElement;\n description?: (check: CheckResult) => string | React.ReactElement;\n isFailed?: (check: CheckResult) => boolean;\n};\n\n/**\n * Default renderer for json-rules-engine check results.\n *\n * @public\n */\nexport const jsonRulesEngineCheckResultRenderer: CheckResultRenderer = {\n type: 'json-rules-engine',\n component: (checkResult: CheckResult) => (\n <BooleanCheck checkResult={checkResult} />\n ),\n isFailed: isBooleanCheckFailed,\n};\n"],"names":[],"mappings":";;;AAqCO,MAAM,kCAA0D,GAAA;AAAA,EACrE,IAAM,EAAA,mBAAA;AAAA,EACN,SAAW,EAAA,CAAC,WACV,qBAAA,KAAA,CAAA,aAAA,CAAC,gBAAa,WAA0B,EAAA,CAAA;AAAA,EAE1C,QAAU,EAAA;AACZ;;;;"}
@@ -0,0 +1,45 @@
1
+ import React, { useState } from 'react';
2
+ import { useApi } from '@backstage/core-plugin-api';
3
+ import IconButton from '@material-ui/core/IconButton';
4
+ import Alert from '@material-ui/lab/Alert';
5
+ import { techInsightsApiRef } from '../../api/TechInsightsApi.esm.js';
6
+ import '@backstage-community/plugin-tech-insights-common/client';
7
+ import '@material-ui/icons/CheckCircleOutline';
8
+ import '@material-ui/icons/ErrorOutline';
9
+ import { ResultLinksMenu } from '../ResultLinksMenu/ResultLinksMenu.esm.js';
10
+
11
+ const ResultCheckIcon = (props) => {
12
+ const {
13
+ result,
14
+ entity,
15
+ disableLinksMenu,
16
+ component,
17
+ componentProps,
18
+ missingRendererComponent = /* @__PURE__ */ React.createElement(Alert, { severity: "error" }, "Unknown type.")
19
+ } = props;
20
+ const api = useApi(techInsightsApiRef);
21
+ const checkResultRenderer = props.checkResultRenderer ?? api.getCheckResultRenderers([result.check.type])[0];
22
+ const [menu, setMenu] = useState();
23
+ const iconComponent = checkResultRenderer?.component(result);
24
+ const onClick = (event) => {
25
+ menu?.open(event.currentTarget);
26
+ };
27
+ const wrapActions = (inner) => {
28
+ if (!menu) {
29
+ if (component) {
30
+ const Component = component;
31
+ return /* @__PURE__ */ React.createElement(Component, { ...componentProps }, inner);
32
+ }
33
+ return inner;
34
+ }
35
+ if (component) {
36
+ const Component = component;
37
+ return /* @__PURE__ */ React.createElement(Component, { ...componentProps, onClick }, /* @__PURE__ */ React.createElement(IconButton, { edge: "end", "aria-label": "icon" }, inner));
38
+ }
39
+ return /* @__PURE__ */ React.createElement(IconButton, { edge: "end", "aria-label": "icon", onClick }, inner);
40
+ };
41
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, !disableLinksMenu && /* @__PURE__ */ React.createElement(ResultLinksMenu, { result, entity, setMenu }), wrapActions(iconComponent ?? missingRendererComponent));
42
+ };
43
+
44
+ export { ResultCheckIcon };
45
+ //# sourceMappingURL=ResultCheckIcon.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResultCheckIcon.esm.js","sources":["../../../src/components/ResultCheckIcon/ResultCheckIcon.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React, {\n ElementType,\n MouseEventHandler,\n PropsWithChildren,\n ReactNode,\n useState,\n} from 'react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { CheckResult } from '@backstage-community/plugin-tech-insights-common';\nimport { Entity } from '@backstage/catalog-model';\nimport IconButton from '@material-ui/core/IconButton';\nimport Alert from '@material-ui/lab/Alert';\nimport { techInsightsApiRef } from '../../api';\nimport { ResultLinksMenu, ResultLinksMenuInfo } from '../ResultLinksMenu';\nimport { CheckResultRenderer } from '../CheckResultRenderer';\n\n/** @public */\nexport type ResultCheckIconBaseComponentProps = PropsWithChildren<{\n onClick?: MouseEventHandler;\n}>;\n\n/**\n * ResultCheckIcon props\n *\n * The only necessary prop is {@link ResultCheckIconProps.result}, but if\n * {@link ResultCheckIconProps.entity} is provided, the popup menu with links\n * will also include links specifically for this entity.\n *\n * @public\n */\nexport interface ResultCheckIconProps<\n P extends ResultCheckIconBaseComponentProps,\n> {\n /**\n * The CheckResult object to create an icon for\n */\n result: CheckResult;\n /**\n * The entity for which this check result is created. This is optional, but if\n * provided, entity-specific links will be added to the popup menu, if any.\n */\n entity?: Entity;\n /**\n * This can optionally be provided, with a small performance improvement, if\n * it is already cashed upstream.\n */\n checkResultRenderer?: CheckResultRenderer;\n /**\n * Will disable the popup menu\n */\n disableLinksMenu?: boolean;\n /**\n * The icon is rendered with an `IconButton` which handles the onClick.\n * To wrap this in another component, handling the onClick, pass a component,\n * such as `ListItemSecondaryAction` which handles the `onClick` to open the\n * popup menu.\n *\n * The {@link ResultCheckIconProps.componentProps} prop can be specified to\n * add props to the wrapping component.\n */\n component?: ElementType<P>;\n /**\n * Props to provide to the wrapping component\n * {@link ResultCheckIconProps.component}.\n */\n componentProps?: Omit<P, 'onClick' | 'children'>;\n /**\n * Override the component used to display instead of a result icon, when no\n * renderer was found for this check type.\n */\n missingRendererComponent?: ReactNode;\n}\n\n/**\n * A component that renders an icon representing a check result, optionally with a popup menu\n * containing links related to the check.\n *\n * @public\n */\nexport const ResultCheckIcon = <P extends ResultCheckIconBaseComponentProps>(\n props: ResultCheckIconProps<P>,\n) => {\n const {\n result,\n entity,\n disableLinksMenu,\n component,\n componentProps,\n missingRendererComponent = <Alert severity=\"error\">Unknown type.</Alert>,\n } = props;\n\n const api = useApi(techInsightsApiRef);\n\n const checkResultRenderer =\n props.checkResultRenderer ??\n api.getCheckResultRenderers([result.check.type])[0];\n\n const [menu, setMenu] = useState<ResultLinksMenuInfo | undefined>();\n\n const iconComponent = checkResultRenderer?.component(result);\n\n const onClick: MouseEventHandler = event => {\n menu?.open(event.currentTarget);\n };\n\n const wrapActions = (inner: React.ReactElement): ReactNode => {\n if (!menu) {\n if (component) {\n const Component =\n component as ElementType<ResultCheckIconBaseComponentProps>;\n return <Component {...componentProps}>{inner}</Component>;\n }\n return inner;\n }\n\n if (component) {\n const Component =\n component as ElementType<ResultCheckIconBaseComponentProps>;\n return (\n <Component {...componentProps} onClick={onClick}>\n <IconButton edge=\"end\" aria-label=\"icon\">\n {inner}\n </IconButton>\n </Component>\n );\n }\n return (\n <IconButton edge=\"end\" aria-label=\"icon\" onClick={onClick}>\n {inner}\n </IconButton>\n );\n };\n\n return (\n <>\n {!disableLinksMenu && (\n <ResultLinksMenu result={result} entity={entity} setMenu={setMenu} />\n )}\n {wrapActions(iconComponent ?? missingRendererComponent)}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AA8Fa,MAAA,eAAA,GAAkB,CAC7B,KACG,KAAA;AACH,EAAM,MAAA;AAAA,IACJ,MAAA;AAAA,IACA,MAAA;AAAA,IACA,gBAAA;AAAA,IACA,SAAA;AAAA,IACA,cAAA;AAAA,IACA,wBAA2B,mBAAA,KAAA,CAAA,aAAA,CAAC,KAAM,EAAA,EAAA,QAAA,EAAS,WAAQ,eAAa;AAAA,GAC9D,GAAA,KAAA;AAEJ,EAAM,MAAA,GAAA,GAAM,OAAO,kBAAkB,CAAA;AAErC,EAAM,MAAA,mBAAA,GACJ,KAAM,CAAA,mBAAA,IACN,GAAI,CAAA,uBAAA,CAAwB,CAAC,MAAA,CAAO,KAAM,CAAA,IAAI,CAAC,CAAA,CAAE,CAAC,CAAA;AAEpD,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,QAA0C,EAAA;AAElE,EAAM,MAAA,aAAA,GAAgB,mBAAqB,EAAA,SAAA,CAAU,MAAM,CAAA;AAE3D,EAAA,MAAM,UAA6B,CAAS,KAAA,KAAA;AAC1C,IAAM,IAAA,EAAA,IAAA,CAAK,MAAM,aAAa,CAAA;AAAA,GAChC;AAEA,EAAM,MAAA,WAAA,GAAc,CAAC,KAAyC,KAAA;AAC5D,IAAA,IAAI,CAAC,IAAM,EAAA;AACT,MAAA,IAAI,SAAW,EAAA;AACb,QAAA,MAAM,SACJ,GAAA,SAAA;AACF,QAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,SAAA,EAAA,EAAW,GAAG,cAAA,EAAA,EAAiB,KAAM,CAAA;AAAA;AAE/C,MAAO,OAAA,KAAA;AAAA;AAGT,IAAA,IAAI,SAAW,EAAA;AACb,MAAA,MAAM,SACJ,GAAA,SAAA;AACF,MAAA,uBACG,KAAA,CAAA,aAAA,CAAA,SAAA,EAAA,EAAW,GAAG,cAAA,EAAgB,OAC7B,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,IAAA,EAAK,KAAM,EAAA,YAAA,EAAW,MAC/B,EAAA,EAAA,KACH,CACF,CAAA;AAAA;AAGJ,IAAA,2CACG,UAAW,EAAA,EAAA,IAAA,EAAK,OAAM,YAAW,EAAA,MAAA,EAAO,WACtC,KACH,CAAA;AAAA,GAEJ;AAEA,EAAA,uBAEK,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAA,CAAC,gBACA,oBAAA,KAAA,CAAA,aAAA,CAAC,eAAgB,EAAA,EAAA,MAAA,EAAgB,MAAgB,EAAA,OAAA,EAAkB,CAEpE,EAAA,WAAA,CAAY,aAAiB,IAAA,wBAAwB,CACxD,CAAA;AAEJ;;;;"}
@@ -0,0 +1,66 @@
1
+ import React, { useMemo, useEffect, useCallback } from 'react';
2
+ import { useApi } from '@backstage/core-plugin-api';
3
+ import Menu from '@material-ui/core/Menu';
4
+ import MenuItem from '@material-ui/core/MenuItem';
5
+ import { techInsightsApiRef } from '../../api/TechInsightsApi.esm.js';
6
+ import '@backstage-community/plugin-tech-insights-common/client';
7
+ import '@material-ui/icons/CheckCircleOutline';
8
+ import '@material-ui/icons/ErrorOutline';
9
+ import { stringifyEntityRef } from '@backstage/catalog-model';
10
+
11
+ const ResultLinksMenu = (props) => {
12
+ const { result, entity, setMenu } = props;
13
+ const api = useApi(techInsightsApiRef);
14
+ const links = useMemo(
15
+ () => entity ? api.getLinksForEntity(result, entity, {
16
+ includeStaticLinks: true
17
+ }) : result.check.links ?? [],
18
+ [api, result, entity]
19
+ );
20
+ const menuId = `menu-${result.check.id}-${entity ? stringifyEntityRef(entity) : "unknown"}`;
21
+ const [anchorEl, setAnchorEl] = React.useState(
22
+ void 0
23
+ );
24
+ useEffect(() => {
25
+ if (links.length === 0) {
26
+ setMenu(void 0);
27
+ return;
28
+ }
29
+ setMenu({
30
+ open: (elem) => {
31
+ setAnchorEl(elem);
32
+ }
33
+ });
34
+ }, [setMenu, links]);
35
+ const handleClose = useCallback(() => {
36
+ setAnchorEl(void 0);
37
+ }, [setAnchorEl]);
38
+ if (links.length === 0) {
39
+ return null;
40
+ }
41
+ return /* @__PURE__ */ React.createElement(
42
+ Menu,
43
+ {
44
+ id: menuId,
45
+ anchorEl: anchorEl ?? null,
46
+ keepMounted: true,
47
+ open: Boolean(anchorEl),
48
+ onClose: handleClose
49
+ },
50
+ links.map((link, i) => /* @__PURE__ */ React.createElement(
51
+ MenuItem,
52
+ {
53
+ key: `${i}-${link.url}`,
54
+ button: true,
55
+ component: "a",
56
+ href: link.url,
57
+ target: link.url.startsWith("/") ? void 0 : "_blank",
58
+ onClick: handleClose
59
+ },
60
+ link.title
61
+ ))
62
+ );
63
+ };
64
+
65
+ export { ResultLinksMenu };
66
+ //# sourceMappingURL=ResultLinksMenu.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResultLinksMenu.esm.js","sources":["../../../src/components/ResultLinksMenu/ResultLinksMenu.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, {\n PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n} from 'react';\nimport { useApi } from '@backstage/core-plugin-api';\nimport Menu from '@material-ui/core/Menu';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport { techInsightsApiRef } from '../../api';\nimport { CheckResult } from '@backstage-community/plugin-tech-insights-common';\nimport { Entity, stringifyEntityRef } from '@backstage/catalog-model';\n\n/**\n * ResultLinksMenu setMenu receiver.\n *\n * This object contains an {@link ResultLinksMenuInfo.open | open} function,\n * which can be used to open the popup menu. It closes automatically on\n * click-away.\n *\n * @public\n */\nexport type ResultLinksMenuInfo = {\n /**\n * Call this function to open the popup menu. The element argument should be\n * an element which is used as an anchor for the menu - where to display it.\n */\n open: (element: Element) => void;\n};\n\n/**\n * A component that renders a popup menu with links related to a check result.\n *\n * @public\n */\nexport const ResultLinksMenu = (\n props: PropsWithChildren<{\n result: CheckResult;\n entity?: Entity;\n setMenu(opener: ResultLinksMenuInfo | undefined): void;\n }>,\n) => {\n const { result, entity, setMenu } = props;\n const api = useApi(techInsightsApiRef);\n\n const links = useMemo(\n () =>\n entity\n ? api.getLinksForEntity(result, entity, {\n includeStaticLinks: true,\n })\n : result.check.links ?? [],\n [api, result, entity],\n );\n\n const menuId = `menu-${result.check.id}-${\n entity ? stringifyEntityRef(entity) : 'unknown'\n }`;\n\n const [anchorEl, setAnchorEl] = React.useState<Element | undefined>(\n undefined,\n );\n\n useEffect(() => {\n if (links.length === 0) {\n setMenu(undefined);\n return;\n }\n setMenu({\n open: (elem: Element) => {\n setAnchorEl(elem);\n },\n });\n }, [setMenu, links]);\n\n const handleClose = useCallback(() => {\n setAnchorEl(undefined);\n }, [setAnchorEl]);\n\n if (links.length === 0) {\n return null;\n }\n\n return (\n <Menu\n id={menuId}\n anchorEl={anchorEl ?? null}\n keepMounted\n open={Boolean(anchorEl)}\n onClose={handleClose}\n >\n {links.map((link, i) => (\n <MenuItem\n key={`${i}-${link.url}`}\n button\n component=\"a\"\n href={link.url}\n target={link.url.startsWith('/') ? undefined : '_blank'}\n onClick={handleClose}\n >\n {link.title}\n </MenuItem>\n ))}\n </Menu>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAmDa,MAAA,eAAA,GAAkB,CAC7B,KAKG,KAAA;AACH,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAQ,EAAA,OAAA,EAAY,GAAA,KAAA;AACpC,EAAM,MAAA,GAAA,GAAM,OAAO,kBAAkB,CAAA;AAErC,EAAA,MAAM,KAAQ,GAAA,OAAA;AAAA,IACZ,MACE,MAAA,GACI,GAAI,CAAA,iBAAA,CAAkB,QAAQ,MAAQ,EAAA;AAAA,MACpC,kBAAoB,EAAA;AAAA,KACrB,CAAA,GACD,MAAO,CAAA,KAAA,CAAM,SAAS,EAAC;AAAA,IAC7B,CAAC,GAAK,EAAA,MAAA,EAAQ,MAAM;AAAA,GACtB;AAEA,EAAM,MAAA,MAAA,GAAS,CAAQ,KAAA,EAAA,MAAA,CAAO,KAAM,CAAA,EAAE,IACpC,MAAS,GAAA,kBAAA,CAAmB,MAAM,CAAA,GAAI,SACxC,CAAA,CAAA;AAEA,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,KAAM,CAAA,QAAA;AAAA,IACpC,KAAA;AAAA,GACF;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAI,IAAA,KAAA,CAAM,WAAW,CAAG,EAAA;AACtB,MAAA,OAAA,CAAQ,KAAS,CAAA,CAAA;AACjB,MAAA;AAAA;AAEF,IAAQ,OAAA,CAAA;AAAA,MACN,IAAA,EAAM,CAAC,IAAkB,KAAA;AACvB,QAAA,WAAA,CAAY,IAAI,CAAA;AAAA;AAClB,KACD,CAAA;AAAA,GACA,EAAA,CAAC,OAAS,EAAA,KAAK,CAAC,CAAA;AAEnB,EAAM,MAAA,WAAA,GAAc,YAAY,MAAM;AACpC,IAAA,WAAA,CAAY,KAAS,CAAA,CAAA;AAAA,GACvB,EAAG,CAAC,WAAW,CAAC,CAAA;AAEhB,EAAI,IAAA,KAAA,CAAM,WAAW,CAAG,EAAA;AACtB,IAAO,OAAA,IAAA;AAAA;AAGT,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,EAAI,EAAA,MAAA;AAAA,MACJ,UAAU,QAAY,IAAA,IAAA;AAAA,MACtB,WAAW,EAAA,IAAA;AAAA,MACX,IAAA,EAAM,QAAQ,QAAQ,CAAA;AAAA,MACtB,OAAS,EAAA;AAAA,KAAA;AAAA,IAER,KAAM,CAAA,GAAA,CAAI,CAAC,IAAA,EAAM,CAChB,qBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QACC,GAAK,EAAA,CAAA,EAAG,CAAC,CAAA,CAAA,EAAI,KAAK,GAAG,CAAA,CAAA;AAAA,QACrB,MAAM,EAAA,IAAA;AAAA,QACN,SAAU,EAAA,GAAA;AAAA,QACV,MAAM,IAAK,CAAA,GAAA;AAAA,QACX,QAAQ,IAAK,CAAA,GAAA,CAAI,UAAW,CAAA,GAAG,IAAI,KAAY,CAAA,GAAA,QAAA;AAAA,QAC/C,OAAS,EAAA;AAAA,OAAA;AAAA,MAER,IAAK,CAAA;AAAA,KAET;AAAA,GACH;AAEJ;;;;"}
@@ -0,0 +1,202 @@
1
+ import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
2
+ import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';
3
+ import { CheckResult, Check, BulkCheckResponse, InsightFacts, FactSchema, CheckLink } from '@backstage-community/plugin-tech-insights-common';
4
+ import React, { PropsWithChildren, MouseEventHandler, ElementType, ReactNode } from 'react';
5
+ import { CompoundEntityRef, Entity } from '@backstage/catalog-model';
6
+ import { TechInsightsClient as TechInsightsClient$1 } from '@backstage-community/plugin-tech-insights-common/client';
7
+
8
+ /**
9
+ * Defines a react component that is responsible for rendering a result of a given type.
10
+ *
11
+ * @public
12
+ */
13
+ type CheckResultRenderer = {
14
+ type: string;
15
+ component: (check: CheckResult) => React.ReactElement;
16
+ description?: (check: CheckResult) => string | React.ReactElement;
17
+ isFailed?: (check: CheckResult) => boolean;
18
+ };
19
+ /**
20
+ * Default renderer for json-rules-engine check results.
21
+ *
22
+ * @public
23
+ */
24
+ declare const jsonRulesEngineCheckResultRenderer: CheckResultRenderer;
25
+
26
+ /**
27
+ * {@link @backstage/core-plugin-api#ApiRef} for the {@link TechInsightsApi}
28
+ *
29
+ * @public
30
+ */
31
+ declare const techInsightsApiRef: _backstage_core_plugin_api.ApiRef<TechInsightsApi>;
32
+ /**
33
+ * Tech Insights API client interface
34
+ *
35
+ * @public
36
+ */
37
+ interface TechInsightsApi {
38
+ getCheckResultRenderers: (types: string[]) => CheckResultRenderer[];
39
+ isCheckResultFailed: (check: CheckResult) => boolean;
40
+ getAllChecks(): Promise<Check[]>;
41
+ runChecks(entityParams: CompoundEntityRef, checks?: string[]): Promise<CheckResult[]>;
42
+ runBulkChecks(entities: CompoundEntityRef[], checks?: Check[]): Promise<BulkCheckResponse>;
43
+ getFacts(entity: CompoundEntityRef, facts: string[]): Promise<InsightFacts>;
44
+ getFactSchemas(): Promise<FactSchema[]>;
45
+ getLinksForEntity(result: CheckResult, entity: Entity, options?: {
46
+ includeStaticLinks?: boolean;
47
+ }): CheckLink[];
48
+ }
49
+
50
+ /**
51
+ * Implementation of the {@link TechInsightsApi} interface.
52
+ *
53
+ * @public
54
+ */
55
+ declare class TechInsightsClient extends TechInsightsClient$1 implements TechInsightsApi {
56
+ private readonly renderers?;
57
+ private readonly customGetEntityLinks;
58
+ constructor(options: {
59
+ discoveryApi: DiscoveryApi;
60
+ identityApi: IdentityApi;
61
+ renderers?: CheckResultRenderer[];
62
+ getEntityLinks?: (result: CheckResult, entity: Entity) => CheckLink[];
63
+ });
64
+ /**
65
+ * Get the check result renderers for the given check types.
66
+ *
67
+ * @param types - The types of checks to get renderers for
68
+ * @returns An array of check result renderers
69
+ *
70
+ * @public
71
+ */
72
+ getCheckResultRenderers(types: string[]): CheckResultRenderer[];
73
+ /**
74
+ * Determine if a check result represents a failure.
75
+ *
76
+ * @param check - The check result to evaluate
77
+ * @returns true if the check result represents a failure, false otherwise
78
+ *
79
+ * @public
80
+ */
81
+ isCheckResultFailed(check: CheckResult): boolean;
82
+ /**
83
+ * Get the links for a given check result and entity.
84
+ *
85
+ * @param result - The check result to get links for
86
+ * @param entity - The entity to get links for
87
+ * @param options - Optional options for the links
88
+ * @returns An array of check links
89
+ *
90
+ * @public
91
+ */
92
+ getLinksForEntity(result: CheckResult, entity: Entity, options?: {
93
+ includeStaticLinks?: boolean;
94
+ }): CheckLink[];
95
+ }
96
+
97
+ /**
98
+ * A component that renders a boolean check result as either a success or failure icon.
99
+ *
100
+ * @public
101
+ */
102
+ declare const BooleanCheck: (props: {
103
+ checkResult: CheckResult;
104
+ }) => React.JSX.Element;
105
+ /**
106
+ * Helper function to determine if a boolean check result represents a failure.
107
+ *
108
+ * @returns true if the check result represents a failure (result is false), false otherwise
109
+ *
110
+ * @public
111
+ */
112
+ declare const isBooleanCheckFailed: (checkResult: CheckResult) => boolean;
113
+
114
+ /** @public */
115
+ type ResultCheckIconBaseComponentProps = PropsWithChildren<{
116
+ onClick?: MouseEventHandler;
117
+ }>;
118
+ /**
119
+ * ResultCheckIcon props
120
+ *
121
+ * The only necessary prop is {@link ResultCheckIconProps.result}, but if
122
+ * {@link ResultCheckIconProps.entity} is provided, the popup menu with links
123
+ * will also include links specifically for this entity.
124
+ *
125
+ * @public
126
+ */
127
+ interface ResultCheckIconProps<P extends ResultCheckIconBaseComponentProps> {
128
+ /**
129
+ * The CheckResult object to create an icon for
130
+ */
131
+ result: CheckResult;
132
+ /**
133
+ * The entity for which this check result is created. This is optional, but if
134
+ * provided, entity-specific links will be added to the popup menu, if any.
135
+ */
136
+ entity?: Entity;
137
+ /**
138
+ * This can optionally be provided, with a small performance improvement, if
139
+ * it is already cashed upstream.
140
+ */
141
+ checkResultRenderer?: CheckResultRenderer;
142
+ /**
143
+ * Will disable the popup menu
144
+ */
145
+ disableLinksMenu?: boolean;
146
+ /**
147
+ * The icon is rendered with an `IconButton` which handles the onClick.
148
+ * To wrap this in another component, handling the onClick, pass a component,
149
+ * such as `ListItemSecondaryAction` which handles the `onClick` to open the
150
+ * popup menu.
151
+ *
152
+ * The {@link ResultCheckIconProps.componentProps} prop can be specified to
153
+ * add props to the wrapping component.
154
+ */
155
+ component?: ElementType<P>;
156
+ /**
157
+ * Props to provide to the wrapping component
158
+ * {@link ResultCheckIconProps.component}.
159
+ */
160
+ componentProps?: Omit<P, 'onClick' | 'children'>;
161
+ /**
162
+ * Override the component used to display instead of a result icon, when no
163
+ * renderer was found for this check type.
164
+ */
165
+ missingRendererComponent?: ReactNode;
166
+ }
167
+ /**
168
+ * A component that renders an icon representing a check result, optionally with a popup menu
169
+ * containing links related to the check.
170
+ *
171
+ * @public
172
+ */
173
+ declare const ResultCheckIcon: <P extends ResultCheckIconBaseComponentProps>(props: ResultCheckIconProps<P>) => React.JSX.Element;
174
+
175
+ /**
176
+ * ResultLinksMenu setMenu receiver.
177
+ *
178
+ * This object contains an {@link ResultLinksMenuInfo.open | open} function,
179
+ * which can be used to open the popup menu. It closes automatically on
180
+ * click-away.
181
+ *
182
+ * @public
183
+ */
184
+ type ResultLinksMenuInfo = {
185
+ /**
186
+ * Call this function to open the popup menu. The element argument should be
187
+ * an element which is used as an anchor for the menu - where to display it.
188
+ */
189
+ open: (element: Element) => void;
190
+ };
191
+ /**
192
+ * A component that renders a popup menu with links related to a check result.
193
+ *
194
+ * @public
195
+ */
196
+ declare const ResultLinksMenu: (props: React.PropsWithChildren<{
197
+ result: CheckResult;
198
+ entity?: Entity | undefined;
199
+ setMenu(opener: ResultLinksMenuInfo | undefined): void;
200
+ }>) => React.JSX.Element | null;
201
+
202
+ export { BooleanCheck, type CheckResultRenderer, ResultCheckIcon, type ResultCheckIconBaseComponentProps, type ResultCheckIconProps, ResultLinksMenu, type ResultLinksMenuInfo, type TechInsightsApi, TechInsightsClient, isBooleanCheckFailed, jsonRulesEngineCheckResultRenderer, techInsightsApiRef };
@@ -0,0 +1,7 @@
1
+ export { techInsightsApiRef } from './api/TechInsightsApi.esm.js';
2
+ export { TechInsightsClient } from './api/TechInsightsClient.esm.js';
3
+ export { BooleanCheck, isBooleanCheckFailed } from './components/BooleanCheck/BooleanCheck.esm.js';
4
+ export { jsonRulesEngineCheckResultRenderer } from './components/CheckResultRenderer.esm.js';
5
+ export { ResultCheckIcon } from './components/ResultCheckIcon/ResultCheckIcon.esm.js';
6
+ export { ResultLinksMenu } from './components/ResultLinksMenu/ResultLinksMenu.esm.js';
7
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@backstage-community/plugin-tech-insights-react",
3
+ "description": "Web library for the tech-insights plugin",
4
+ "version": "1.1.0",
5
+ "main": "dist/index.esm.js",
6
+ "types": "dist/index.d.ts",
7
+ "license": "Apache-2.0",
8
+ "publishConfig": {
9
+ "access": "public",
10
+ "main": "dist/index.esm.js",
11
+ "types": "dist/index.d.ts"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/backstage/community-plugins",
16
+ "directory": "workspaces/tech-insights/plugins/tech-insights-react"
17
+ },
18
+ "backstage": {
19
+ "role": "web-library",
20
+ "pluginId": "tech-insights",
21
+ "pluginPackages": [
22
+ "@backstage-community/plugin-tech-insights",
23
+ "@backstage-community/plugin-tech-insights-backend",
24
+ "@backstage-community/plugin-tech-insights-common",
25
+ "@backstage-community/plugin-tech-insights-maturity",
26
+ "@backstage-community/plugin-tech-insights-maturity-common",
27
+ "@backstage-community/plugin-tech-insights-node",
28
+ "@backstage-community/plugin-tech-insights-react"
29
+ ]
30
+ },
31
+ "sideEffects": false,
32
+ "scripts": {
33
+ "start": "backstage-cli package start",
34
+ "build": "backstage-cli package build",
35
+ "lint": "backstage-cli package lint",
36
+ "test": "backstage-cli package test",
37
+ "clean": "backstage-cli package clean",
38
+ "prepack": "backstage-cli package prepack",
39
+ "postpack": "backstage-cli package postpack"
40
+ },
41
+ "dependencies": {
42
+ "@backstage-community/plugin-tech-insights-common": "^0.5.0",
43
+ "@backstage/catalog-model": "^1.7.3",
44
+ "@backstage/core-plugin-api": "^1.10.3",
45
+ "@backstage/types": "^1.2.1",
46
+ "@material-ui/core": "^4.9.13",
47
+ "@material-ui/icons": "^4.9.1",
48
+ "@material-ui/lab": "4.0.0-alpha.61"
49
+ },
50
+ "peerDependencies": {
51
+ "react": "^16.13.1 || ^17.0.0 || ^18.0.0"
52
+ },
53
+ "devDependencies": {
54
+ "@backstage/cli": "^0.29.6",
55
+ "@backstage/test-utils": "^1.7.4",
56
+ "@testing-library/jest-dom": "^6.0.0",
57
+ "@testing-library/react": "^14.0.0",
58
+ "react": "^16.13.1 || ^17.0.0 || ^18.0.0"
59
+ },
60
+ "files": [
61
+ "dist"
62
+ ],
63
+ "typesVersions": {
64
+ "*": {
65
+ "index": [
66
+ "dist/index.d.ts"
67
+ ]
68
+ }
69
+ },
70
+ "module": "./dist/index.esm.js"
71
+ }