@backstage-community/plugin-tech-insights 0.6.1 → 0.6.2
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 +9 -0
- package/dist/components/ScorecardsCard/ScorecardsCard.esm.js +6 -3
- package/dist/components/ScorecardsCard/ScorecardsCard.esm.js.map +1 -1
- package/dist/components/ScorecardsGauge/ScorecardsGauge.esm.js +13 -2
- package/dist/components/ScorecardsGauge/ScorecardsGauge.esm.js.map +1 -1
- package/dist/components/ScorecardsInfo/ScorecardInfo.esm.js +4 -3
- package/dist/components/ScorecardsInfo/ScorecardInfo.esm.js.map +1 -1
- package/dist/components/ScorecardsPage/ScorecardsPage.esm.js +3 -1
- package/dist/components/ScorecardsPage/ScorecardsPage.esm.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @backstage-community/plugin-tech-insights
|
|
2
2
|
|
|
3
|
+
## 0.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 43064bf: Updated default non-dense behavior to include a description instead of reverting to tooltip
|
|
8
|
+
- Updated dependencies [ba5bf7b]
|
|
9
|
+
- @backstage-community/plugin-tech-insights-common@0.7.1
|
|
10
|
+
- @backstage-community/plugin-tech-insights-react@1.2.1
|
|
11
|
+
|
|
3
12
|
## 0.6.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -17,7 +17,8 @@ const ScorecardsCard = (props) => {
|
|
|
17
17
|
filter,
|
|
18
18
|
onlyFailed,
|
|
19
19
|
gauge,
|
|
20
|
-
expanded = !gauge
|
|
20
|
+
expanded = !gauge,
|
|
21
|
+
dense = true
|
|
21
22
|
} = props;
|
|
22
23
|
const api = useApi(techInsightsApiRef);
|
|
23
24
|
const { entity } = useEntity();
|
|
@@ -50,7 +51,8 @@ const ScorecardsCard = (props) => {
|
|
|
50
51
|
entity,
|
|
51
52
|
checkResults: filteredValue,
|
|
52
53
|
noWarning: onlyFailed,
|
|
53
|
-
expanded
|
|
54
|
+
expanded,
|
|
55
|
+
dense
|
|
54
56
|
}
|
|
55
57
|
) : /* @__PURE__ */ jsx(
|
|
56
58
|
ScorecardInfo,
|
|
@@ -60,7 +62,8 @@ const ScorecardsCard = (props) => {
|
|
|
60
62
|
entity,
|
|
61
63
|
checkResults: filteredValue,
|
|
62
64
|
noWarning: onlyFailed,
|
|
63
|
-
expanded
|
|
65
|
+
expanded,
|
|
66
|
+
dense
|
|
64
67
|
}
|
|
65
68
|
);
|
|
66
69
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScorecardsCard.esm.js","sources":["../../../src/components/ScorecardsCard/ScorecardsCard.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 */\n\nimport { useMemo } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { ErrorPanel, Progress } from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { ScorecardInfo } from '../ScorecardsInfo';\nimport { techInsightsApiRef } from '@backstage-community/plugin-tech-insights-react';\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport { getCompoundEntityRef } from '@backstage/catalog-model';\nimport { Check } from '@backstage-community/plugin-tech-insights-common';\nimport { ScorecardsGauge } from '../ScorecardsGauge';\n\nexport const ScorecardsCard = (props: {\n title: string;\n description?: string;\n checksId?: string[];\n filter?: (check: Check) => boolean;\n onlyFailed?: boolean;\n expanded?: boolean;\n gauge?: boolean;\n}) => {\n const {\n title,\n description,\n checksId,\n filter,\n onlyFailed,\n gauge,\n expanded = !gauge,\n } = props;\n const api = useApi(techInsightsApiRef);\n const { entity } = useEntity();\n const { value, loading, error } = useAsync(\n async () => await api.runChecks(getCompoundEntityRef(entity), checksId),\n [api, entity, JSON.stringify(checksId)],\n );\n\n const filteredValues =\n !filter || !value ? value : value.filter(val => filter(val.check));\n\n const checkResultRenderers = useMemo(() => {\n if (!onlyFailed || !filteredValues) return {};\n\n const types = [...new Set(filteredValues.map(({ check }) => check.type))];\n const renderers = api.getCheckResultRenderers(types);\n return Object.fromEntries(\n renderers.map(renderer => [renderer.type, renderer]),\n );\n }, [api, filteredValues, onlyFailed]);\n\n if (loading) {\n return <Progress />;\n } else if (error) {\n return <ErrorPanel error={error} />;\n }\n\n const filteredValue = !onlyFailed\n ? filteredValues || []\n : (filteredValues || []).filter(val =>\n checkResultRenderers[val.check.type]?.isFailed?.(val),\n );\n\n return gauge ? (\n <ScorecardsGauge\n title={title}\n description={description}\n entity={entity}\n checkResults={filteredValue}\n noWarning={onlyFailed}\n expanded={expanded}\n />\n ) : (\n <ScorecardInfo\n title={title}\n description={description}\n entity={entity}\n checkResults={filteredValue}\n noWarning={onlyFailed}\n expanded={expanded}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AA2Ba,MAAA,cAAA,GAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"ScorecardsCard.esm.js","sources":["../../../src/components/ScorecardsCard/ScorecardsCard.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 */\n\nimport { useMemo } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { ErrorPanel, Progress } from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { ScorecardInfo } from '../ScorecardsInfo';\nimport { techInsightsApiRef } from '@backstage-community/plugin-tech-insights-react';\nimport { useEntity } from '@backstage/plugin-catalog-react';\nimport { getCompoundEntityRef } from '@backstage/catalog-model';\nimport { Check } from '@backstage-community/plugin-tech-insights-common';\nimport { ScorecardsGauge } from '../ScorecardsGauge';\n\nexport const ScorecardsCard = (props: {\n title: string;\n description?: string;\n checksId?: string[];\n filter?: (check: Check) => boolean;\n onlyFailed?: boolean;\n expanded?: boolean;\n gauge?: boolean;\n dense?: boolean;\n}) => {\n const {\n title,\n description,\n checksId,\n filter,\n onlyFailed,\n gauge,\n expanded = !gauge,\n dense = true,\n } = props;\n const api = useApi(techInsightsApiRef);\n const { entity } = useEntity();\n const { value, loading, error } = useAsync(\n async () => await api.runChecks(getCompoundEntityRef(entity), checksId),\n [api, entity, JSON.stringify(checksId)],\n );\n\n const filteredValues =\n !filter || !value ? value : value.filter(val => filter(val.check));\n\n const checkResultRenderers = useMemo(() => {\n if (!onlyFailed || !filteredValues) return {};\n\n const types = [...new Set(filteredValues.map(({ check }) => check.type))];\n const renderers = api.getCheckResultRenderers(types);\n return Object.fromEntries(\n renderers.map(renderer => [renderer.type, renderer]),\n );\n }, [api, filteredValues, onlyFailed]);\n\n if (loading) {\n return <Progress />;\n } else if (error) {\n return <ErrorPanel error={error} />;\n }\n\n const filteredValue = !onlyFailed\n ? filteredValues || []\n : (filteredValues || []).filter(val =>\n checkResultRenderers[val.check.type]?.isFailed?.(val),\n );\n\n return gauge ? (\n <ScorecardsGauge\n title={title}\n description={description}\n entity={entity}\n checkResults={filteredValue}\n noWarning={onlyFailed}\n expanded={expanded}\n dense={dense}\n />\n ) : (\n <ScorecardInfo\n title={title}\n description={description}\n entity={entity}\n checkResults={filteredValue}\n noWarning={onlyFailed}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AAC,QAAS,CAAA,IAAA,EAAM,QAAQ,CAAC;AAAA,KACrD;AAAA,GACC,EAAA,CAAC,GAAK,EAAA,cAAA,EAAgB,UAAU,CAAC,CAAA;AAEpC,EAAA,IAAI,OAAS,EAAA;AACX,IAAA,2BAAQ,QAAS,EAAA,EAAA,CAAA;AAAA,aACR,KAAO,EAAA;AAChB,IAAO,uBAAA,GAAA,CAAC,cAAW,KAAc,EAAA,CAAA;AAAA;AAGnC,EAAM,MAAA,aAAA,GAAgB,CAAC,UACnB,GAAA,cAAA,IAAkB,EACjB,GAAA,CAAA,cAAA,IAAkB,EAAI,EAAA,MAAA;AAAA,IAAO,SAC5B,oBAAqB,CAAA,GAAA,CAAI,MAAM,IAAI,CAAA,EAAG,WAAW,GAAG;AAAA,GACtD;AAEJ,EAAA,OAAO,KACL,mBAAA,GAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,WAAA;AAAA,MACA,MAAA;AAAA,MACA,YAAc,EAAA,aAAA;AAAA,MACd,SAAW,EAAA,UAAA;AAAA,MACX,QAAA;AAAA,MACA;AAAA;AAAA,GAGF,mBAAA,GAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,WAAA;AAAA,MACA,MAAA;AAAA,MACA,YAAc,EAAA,aAAA;AAAA,MACd,SAAW,EAAA,UAAA;AAAA,MACX,QAAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -7,7 +7,16 @@ import Typography from '@material-ui/core/Typography';
|
|
|
7
7
|
import Grid from '@material-ui/core/Grid';
|
|
8
8
|
|
|
9
9
|
const ScorecardsGauge = (props) => {
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
checkResults,
|
|
12
|
+
entity,
|
|
13
|
+
title,
|
|
14
|
+
description,
|
|
15
|
+
noWarning,
|
|
16
|
+
expanded,
|
|
17
|
+
dense = true,
|
|
18
|
+
hideDescription
|
|
19
|
+
} = props;
|
|
11
20
|
const api = useApi(techInsightsApiRef);
|
|
12
21
|
const types = [...new Set(checkResults.map(({ check }) => check.type))];
|
|
13
22
|
const checkResultRenderers = api.getCheckResultRenderers(types);
|
|
@@ -30,7 +39,9 @@ const ScorecardsGauge = (props) => {
|
|
|
30
39
|
checkResults,
|
|
31
40
|
entity,
|
|
32
41
|
noWarning,
|
|
33
|
-
expanded
|
|
42
|
+
expanded,
|
|
43
|
+
dense,
|
|
44
|
+
hideDescription
|
|
34
45
|
}
|
|
35
46
|
)
|
|
36
47
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScorecardsGauge.esm.js","sources":["../../../src/components/ScorecardsGauge/ScorecardsGauge.tsx"],"sourcesContent":["/*\n * Copyright 2025 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 { CheckResult } from '@backstage-community/plugin-tech-insights-common';\nimport { Entity } from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { techInsightsApiRef } from '@backstage-community/plugin-tech-insights-react';\nimport { Gauge, InfoCard } from '@backstage/core-components';\nimport { ScorecardInfo } from '../ScorecardsInfo';\nimport Typography from '@material-ui/core/Typography';\nimport Grid from '@material-ui/core/Grid';\n\nexport const ScorecardsGauge = (props: {\n checkResults: CheckResult[];\n entity?: Entity;\n title: string;\n description?: string;\n noWarning?: boolean;\n expanded?: boolean;\n}) => {\n const {
|
|
1
|
+
{"version":3,"file":"ScorecardsGauge.esm.js","sources":["../../../src/components/ScorecardsGauge/ScorecardsGauge.tsx"],"sourcesContent":["/*\n * Copyright 2025 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 { CheckResult } from '@backstage-community/plugin-tech-insights-common';\nimport { Entity } from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { techInsightsApiRef } from '@backstage-community/plugin-tech-insights-react';\nimport { Gauge, InfoCard } from '@backstage/core-components';\nimport { ScorecardInfo } from '../ScorecardsInfo';\nimport Typography from '@material-ui/core/Typography';\nimport Grid from '@material-ui/core/Grid';\n\nexport const ScorecardsGauge = (props: {\n checkResults: CheckResult[];\n entity?: Entity;\n title: string;\n description?: string;\n noWarning?: boolean;\n expanded?: boolean;\n dense?: boolean;\n hideDescription?: boolean;\n}) => {\n const {\n checkResults,\n entity,\n title,\n description,\n noWarning,\n expanded,\n dense = true,\n hideDescription,\n } = props;\n\n const api = useApi(techInsightsApiRef);\n\n const types = [...new Set(checkResults.map(({ check }) => check.type))];\n const checkResultRenderers = api.getCheckResultRenderers(types);\n const checkResultsWithRenderer = checkResults.map(result => ({\n result,\n renderer: checkResultRenderers.find(\n renderer => renderer.type === result.check.type,\n ),\n }));\n\n const succeeded = checkResultsWithRenderer.filter(\n ({ result, renderer }) => !renderer?.isFailed?.(result),\n ).length;\n const progress = succeeded / checkResults.length;\n\n return (\n <InfoCard title={title} subheader={description}>\n <Grid container justifyContent=\"center\">\n <Grid item style={{ width: '160px', marginBottom: '1em' }}>\n <Gauge value={progress} size=\"small\" />\n </Grid>\n </Grid>\n <ScorecardInfo\n title={<Typography variant=\"h6\">Checks</Typography>}\n checkResults={checkResults}\n entity={entity}\n noWarning={noWarning}\n expanded={expanded}\n dense={dense}\n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AAA,IAAA,EAAC,KAAO,EAAA,EAAE,OAAO,OAAS,EAAA,YAAA,EAAc,KAAM,EAAA,EACtD,QAAC,kBAAA,GAAA,CAAA,KAAA,EAAA,EAAM,OAAO,QAAU,EAAA,IAAA,EAAK,OAAQ,EAAA,CAAA,EACvC,CACF,EAAA,CAAA;AAAA,oBACA,GAAA;AAAA,MAAC,aAAA;AAAA,MAAA;AAAA,QACC,KAAO,kBAAA,GAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,MAAK,QAAM,EAAA,QAAA,EAAA,CAAA;AAAA,QACtC,YAAA;AAAA,QACA,MAAA;AAAA,QACA,SAAA;AAAA,QACA,QAAA;AAAA,QACA,KAAA;AAAA,QACA;AAAA;AAAA;AACF,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -73,7 +73,8 @@ const ScorecardInfo = (props) => {
|
|
|
73
73
|
description,
|
|
74
74
|
noWarning,
|
|
75
75
|
expanded = true,
|
|
76
|
-
dense
|
|
76
|
+
dense,
|
|
77
|
+
hideDescription = dense
|
|
77
78
|
} = props;
|
|
78
79
|
const classes = useStyles();
|
|
79
80
|
const api = useApi(techInsightsApiRef);
|
|
@@ -104,8 +105,8 @@ const ScorecardInfo = (props) => {
|
|
|
104
105
|
{
|
|
105
106
|
checkResults,
|
|
106
107
|
entity,
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
dense,
|
|
109
|
+
hideDescription
|
|
109
110
|
}
|
|
110
111
|
),
|
|
111
112
|
expanded,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScorecardInfo.esm.js","sources":["../../../src/components/ScorecardsInfo/ScorecardInfo.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 */\n\nimport { ReactElement, ReactNode } from 'react';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { CheckResult } from '@backstage-community/plugin-tech-insights-common';\nimport Alert from '@material-ui/lab/Alert';\nimport { ScorecardsList } from '../ScorecardsList';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport Accordion from '@material-ui/core/Accordion';\nimport AccordionDetails from '@material-ui/core/AccordionDetails';\nimport AccordionSummary from '@material-ui/core/AccordionSummary';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { Entity } from '@backstage/catalog-model';\nimport { MarkdownContent } from '@backstage/core-components';\nimport { techInsightsApiRef } from '@backstage-community/plugin-tech-insights-react';\n\nconst useStyles = makeStyles(theme => ({\n subheader: {\n paddingLeft: theme.spacing(0.5),\n },\n accordionHeader: {\n borderBottom: `1px solid ${theme.palette.border}`,\n },\n accordionHeaderContent: {\n margin: `${theme.spacing(2)}px 0 !important`,\n },\n accordionDetails: {\n margin: 0,\n paddingBottom: 0,\n },\n}));\n\nconst infoAccordion = (\n title: ReactNode,\n children: ReactNode,\n classes: ReturnType<typeof useStyles>,\n expanded: boolean,\n summary?: string,\n) => (\n <Accordion defaultExpanded={expanded}>\n <AccordionSummary\n expandIcon={<ExpandMoreIcon />}\n className={classes.accordionHeader}\n classes={{\n content: classes.accordionHeaderContent,\n }}\n >\n <Grid container justifyContent=\"space-between\" alignItems=\"center\">\n <Grid item>\n <Typography variant=\"h5\">{title}</Typography>\n </Grid>\n <Grid item>\n <Typography>{summary}</Typography>\n </Grid>\n </Grid>\n </AccordionSummary>\n <AccordionDetails classes={{ root: classes.accordionDetails }}>\n {children}\n </AccordionDetails>\n </Accordion>\n);\n\nconst infoDetails = (\n description: string | undefined,\n classes: ReturnType<typeof useStyles>,\n element: ReactElement,\n) => {\n return (\n <Grid container>\n {description && (\n <Grid item xs={12}>\n <Typography\n className={classes.subheader}\n variant=\"body1\"\n gutterBottom\n >\n <MarkdownContent content={description} />\n </Typography>\n </Grid>\n )}\n <Grid item xs={12}>\n {element}\n </Grid>\n </Grid>\n );\n};\n\nconst infoCard = (\n title: ReactNode,\n description: string | undefined,\n classes: ReturnType<typeof useStyles>,\n element: ReactElement,\n expanded: boolean,\n summary?: string,\n) => (\n <Grid item xs={12}>\n {infoAccordion(\n title,\n infoDetails(description, classes, element),\n classes,\n expanded,\n summary,\n )}\n </Grid>\n);\n\nexport const ScorecardInfo = (props: {\n checkResults: CheckResult[];\n title: ReactNode;\n entity?: Entity;\n description?: string;\n noWarning?: boolean;\n expanded?: boolean;\n dense?: boolean;\n}) => {\n const {\n checkResults,\n title,\n entity,\n description,\n noWarning,\n expanded = true,\n dense,\n } = props;\n const classes = useStyles();\n const api = useApi(techInsightsApiRef);\n\n if (!checkResults.length) {\n if (noWarning) {\n return infoCard(\n title,\n description,\n classes,\n <Alert severity=\"info\">\n All checks passed, or no checks have been performed yet\n </Alert>,\n expanded,\n );\n }\n return infoCard(\n title,\n description,\n classes,\n <Alert severity=\"warning\">No checks have any data yet.</Alert>,\n expanded,\n );\n }\n\n return infoCard(\n title,\n description,\n classes,\n <ScorecardsList\n checkResults={checkResults}\n entity={entity}\n
|
|
1
|
+
{"version":3,"file":"ScorecardInfo.esm.js","sources":["../../../src/components/ScorecardsInfo/ScorecardInfo.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 */\n\nimport { ReactElement, ReactNode } from 'react';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { CheckResult } from '@backstage-community/plugin-tech-insights-common';\nimport Alert from '@material-ui/lab/Alert';\nimport { ScorecardsList } from '../ScorecardsList';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport Accordion from '@material-ui/core/Accordion';\nimport AccordionDetails from '@material-ui/core/AccordionDetails';\nimport AccordionSummary from '@material-ui/core/AccordionSummary';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { Entity } from '@backstage/catalog-model';\nimport { MarkdownContent } from '@backstage/core-components';\nimport { techInsightsApiRef } from '@backstage-community/plugin-tech-insights-react';\n\nconst useStyles = makeStyles(theme => ({\n subheader: {\n paddingLeft: theme.spacing(0.5),\n },\n accordionHeader: {\n borderBottom: `1px solid ${theme.palette.border}`,\n },\n accordionHeaderContent: {\n margin: `${theme.spacing(2)}px 0 !important`,\n },\n accordionDetails: {\n margin: 0,\n paddingBottom: 0,\n },\n}));\n\nconst infoAccordion = (\n title: ReactNode,\n children: ReactNode,\n classes: ReturnType<typeof useStyles>,\n expanded: boolean,\n summary?: string,\n) => (\n <Accordion defaultExpanded={expanded}>\n <AccordionSummary\n expandIcon={<ExpandMoreIcon />}\n className={classes.accordionHeader}\n classes={{\n content: classes.accordionHeaderContent,\n }}\n >\n <Grid container justifyContent=\"space-between\" alignItems=\"center\">\n <Grid item>\n <Typography variant=\"h5\">{title}</Typography>\n </Grid>\n <Grid item>\n <Typography>{summary}</Typography>\n </Grid>\n </Grid>\n </AccordionSummary>\n <AccordionDetails classes={{ root: classes.accordionDetails }}>\n {children}\n </AccordionDetails>\n </Accordion>\n);\n\nconst infoDetails = (\n description: string | undefined,\n classes: ReturnType<typeof useStyles>,\n element: ReactElement,\n) => {\n return (\n <Grid container>\n {description && (\n <Grid item xs={12}>\n <Typography\n className={classes.subheader}\n variant=\"body1\"\n gutterBottom\n >\n <MarkdownContent content={description} />\n </Typography>\n </Grid>\n )}\n <Grid item xs={12}>\n {element}\n </Grid>\n </Grid>\n );\n};\n\nconst infoCard = (\n title: ReactNode,\n description: string | undefined,\n classes: ReturnType<typeof useStyles>,\n element: ReactElement,\n expanded: boolean,\n summary?: string,\n) => (\n <Grid item xs={12}>\n {infoAccordion(\n title,\n infoDetails(description, classes, element),\n classes,\n expanded,\n summary,\n )}\n </Grid>\n);\n\nexport const ScorecardInfo = (props: {\n checkResults: CheckResult[];\n title: ReactNode;\n entity?: Entity;\n description?: string;\n noWarning?: boolean;\n expanded?: boolean;\n dense?: boolean;\n hideDescription?: boolean;\n}) => {\n const {\n checkResults,\n title,\n entity,\n description,\n noWarning,\n expanded = true,\n dense,\n hideDescription = dense,\n } = props;\n const classes = useStyles();\n const api = useApi(techInsightsApiRef);\n\n if (!checkResults.length) {\n if (noWarning) {\n return infoCard(\n title,\n description,\n classes,\n <Alert severity=\"info\">\n All checks passed, or no checks have been performed yet\n </Alert>,\n expanded,\n );\n }\n return infoCard(\n title,\n description,\n classes,\n <Alert severity=\"warning\">No checks have any data yet.</Alert>,\n expanded,\n );\n }\n\n return infoCard(\n title,\n description,\n classes,\n <ScorecardsList\n checkResults={checkResults}\n entity={entity}\n dense={dense}\n hideDescription={hideDescription}\n />,\n expanded,\n `${\n checkResults.filter(checkResult => !api.isCheckResultFailed(checkResult))\n .length\n }/${checkResults.length}`,\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAgCA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,SAAW,EAAA;AAAA,IACT,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,GAAG;AAAA,GAChC;AAAA,EACA,eAAiB,EAAA;AAAA,IACf,YAAc,EAAA,CAAA,UAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,MAAM,CAAA;AAAA,GACjD;AAAA,EACA,sBAAwB,EAAA;AAAA,IACtB,MAAQ,EAAA,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,WAAA;AAAA,QACA,OAAA;AAAA,wBACC,GAAA,CAAA,KAAA,EAAA,EAAM,QAAS,EAAA,MAAA,EAAO,QAEvB,EAAA,yDAAA,EAAA,CAAA;AAAA,QACA;AAAA,OACF;AAAA;AAEF,IAAO,OAAA,QAAA;AAAA,MACL,KAAA;AAAA,MACA,WAAA;AAAA,MACA,OAAA;AAAA,sBACC,GAAA,CAAA,KAAA,EAAA,EAAM,QAAS,EAAA,SAAA,EAAU,QAA4B,EAAA,8BAAA,EAAA,CAAA;AAAA,MACtD;AAAA,KACF;AAAA;AAGF,EAAO,OAAA,QAAA;AAAA,IACL,KAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA;AAAA,oBACA,GAAA;AAAA,MAAC,cAAA;AAAA,MAAA;AAAA,QACC,YAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA;AAAA,QACA;AAAA;AAAA,KACF;AAAA,IACA,QAAA;AAAA,IACA,CACE,EAAA,YAAA,CAAa,MAAO,CAAA,CAAA,WAAA,KAAe,CAAC,GAAA,CAAI,mBAAoB,CAAA,WAAW,CAAC,CAAA,CACrE,MACL,CAAA,CAAA,EAAI,aAAa,MAAM,CAAA;AAAA,GACzB;AACF;;;;"}
|
|
@@ -32,7 +32,9 @@ const ScorecardsPage = (props) => {
|
|
|
32
32
|
const result = await api.runBulkChecks([], filterSelectedChecks);
|
|
33
33
|
return {
|
|
34
34
|
checks,
|
|
35
|
-
result: filterWithResults ? result.filter((response) => response.results.length > 0) : result
|
|
35
|
+
result: filterWithResults ? result.filter((response) => response.results.length > 0) : result.filter(
|
|
36
|
+
(response) => (response.results?.length ?? 0) === 0 || response.results.every((r) => r.result === false)
|
|
37
|
+
)
|
|
36
38
|
};
|
|
37
39
|
}, [api, filterSelectedChecks, filterWithResults]);
|
|
38
40
|
const tableColumns = useMemo(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScorecardsPage.esm.js","sources":["../../../src/components/ScorecardsPage/ScorecardsPage.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 */\n\nimport { useMemo, useState } from 'react';\nimport {\n Content,\n ErrorPanel,\n Header,\n HeaderLabel,\n Page,\n TableColumn,\n Table,\n TableOptions,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n Check,\n BulkCheckResponse,\n} from '@backstage-community/plugin-tech-insights-common';\nimport useAsync from 'react-use/lib/useAsync';\nimport { EntityRefLink } from '@backstage/plugin-catalog-react';\nimport { ScorecardsList } from '../ScorecardsList';\nimport Grid from '@material-ui/core/Grid';\nimport { Filters } from './Filters';\nimport { ExportCsv as exportCsv } from '@material-table/exporters';\nimport { techInsightsApiRef } from '@backstage-community/plugin-tech-insights-react';\nimport { ScorecardsBadge } from '../ScorecardsBadge';\n\nexport const ScorecardsPage = (props: { badge?: boolean; dense?: boolean }) => {\n const api = useApi(techInsightsApiRef);\n const [filterSelectedChecks, setFilterSelectedChecks] = useState<Check[]>([]);\n const [filterWithResults, setFilterWithResults] = useState<boolean>(true);\n const tableOptions: TableOptions = {\n exportAllData: true,\n exportMenu: [\n {\n label: 'Export CSV',\n exportFunc: (cols, datas) => exportCsv(cols, datas, 'tech-insights'),\n },\n ],\n pageSize: props.badge ? 15 : 5,\n pageSizeOptions: props.badge ? [15, 30, 100] : [5, 10, 20],\n padding: `${props.dense ? 'dense' : 'default'}`,\n };\n\n const { value, loading, error } = useAsync(async () => {\n const checks = await api.getAllChecks();\n const result = await api.runBulkChecks([], filterSelectedChecks);\n\n return {\n checks,\n result: filterWithResults\n ? result.filter(response => response.results.length > 0)\n : result,\n };\n }, [api, filterSelectedChecks, filterWithResults]);\n\n const tableColumns = useMemo(() => {\n const columns: TableColumn<BulkCheckResponse[0]>[] = [\n {\n field: 'entity',\n title: 'Entity',\n render: row => <EntityRefLink entityRef={row.entity} />,\n },\n {\n field: 'results',\n title: 'Results',\n render: row =>\n props.badge ? (\n <ScorecardsBadge checkResults={row.results} />\n ) : (\n <ScorecardsList checkResults={row.results} dense={props.dense} />\n ),\n export: false,\n },\n ];\n\n (filterSelectedChecks.length === 0\n ? value?.checks || []\n : filterSelectedChecks\n ).forEach(check => {\n columns.push({\n field: check.id,\n title: check.name,\n customExport: row =>\n `${\n row.results.filter(\n result => result && result.check && result.check.id === check.id,\n )[0]?.result\n }`,\n hidden: true,\n export: true,\n });\n });\n\n return columns;\n }, [props, value, filterSelectedChecks]);\n\n if (error) {\n return <ErrorPanel error={error} />;\n }\n\n return (\n <Page themeId=\"tool\">\n <Header title=\"Tech insights\">\n <HeaderLabel label=\"Entities\" value={value?.result.length ?? 0} />\n <HeaderLabel label=\"Checks\" value={value?.checks.length ?? 0} />\n </Header>\n <Content>\n <Grid container>\n <Grid item style={{ width: '300px' }}>\n <Filters\n checksChanged={checks => setFilterSelectedChecks(checks)}\n withResultsChanged={withResults =>\n setFilterWithResults(withResults)\n }\n />\n </Grid>\n <Grid item xs>\n <Table\n columns={tableColumns}\n data={value?.result ?? []}\n isLoading={loading}\n options={tableOptions}\n />\n </Grid>\n </Grid>\n </Content>\n </Page>\n );\n};\n"],"names":["exportCsv"],"mappings":";;;;;;;;;;;;;AAyCa,MAAA,cAAA,GAAiB,CAAC,KAAgD,KAAA;AAC7E,EAAM,MAAA,GAAA,GAAM,OAAO,kBAAkB,CAAA;AACrC,EAAA,MAAM,CAAC,oBAAsB,EAAA,uBAAuB,CAAI,GAAA,QAAA,CAAkB,EAAE,CAAA;AAC5E,EAAA,MAAM,CAAC,iBAAA,EAAmB,oBAAoB,CAAA,GAAI,SAAkB,IAAI,CAAA;AACxE,EAAA,MAAM,YAA6B,GAAA;AAAA,IACjC,aAAe,EAAA,IAAA;AAAA,IACf,UAAY,EAAA;AAAA,MACV;AAAA,QACE,KAAO,EAAA,YAAA;AAAA,QACP,YAAY,CAAC,IAAA,EAAM,UAAUA,SAAU,CAAA,IAAA,EAAM,OAAO,eAAe;AAAA;AACrE,KACF;AAAA,IACA,QAAA,EAAU,KAAM,CAAA,KAAA,GAAQ,EAAK,GAAA,CAAA;AAAA,IAC7B,eAAA,EAAiB,KAAM,CAAA,KAAA,GAAQ,CAAC,EAAA,EAAI,EAAI,EAAA,GAAG,CAAI,GAAA,CAAC,CAAG,EAAA,EAAA,EAAI,EAAE,CAAA;AAAA,IACzD,OAAS,EAAA,CAAA,EAAG,KAAM,CAAA,KAAA,GAAQ,UAAU,SAAS,CAAA;AAAA,GAC/C;AAEA,EAAA,MAAM,EAAE,KAAO,EAAA,OAAA,EAAS,KAAM,EAAA,GAAI,SAAS,YAAY;AACrD,IAAM,MAAA,MAAA,GAAS,MAAM,GAAA,CAAI,YAAa,EAAA;AACtC,IAAA,MAAM,SAAS,MAAM,GAAA,CAAI,aAAc,CAAA,IAAI,oBAAoB,CAAA;AAE/D,IAAO,OAAA;AAAA,MACL,MAAA;AAAA,MACA,MAAA,EAAQ,
|
|
1
|
+
{"version":3,"file":"ScorecardsPage.esm.js","sources":["../../../src/components/ScorecardsPage/ScorecardsPage.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 */\n\nimport { useMemo, useState } from 'react';\nimport {\n Content,\n ErrorPanel,\n Header,\n HeaderLabel,\n Page,\n TableColumn,\n Table,\n TableOptions,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport {\n Check,\n BulkCheckResponse,\n} from '@backstage-community/plugin-tech-insights-common';\nimport useAsync from 'react-use/lib/useAsync';\nimport { EntityRefLink } from '@backstage/plugin-catalog-react';\nimport { ScorecardsList } from '../ScorecardsList';\nimport Grid from '@material-ui/core/Grid';\nimport { Filters } from './Filters';\nimport { ExportCsv as exportCsv } from '@material-table/exporters';\nimport { techInsightsApiRef } from '@backstage-community/plugin-tech-insights-react';\nimport { ScorecardsBadge } from '../ScorecardsBadge';\n\nexport const ScorecardsPage = (props: { badge?: boolean; dense?: boolean }) => {\n const api = useApi(techInsightsApiRef);\n const [filterSelectedChecks, setFilterSelectedChecks] = useState<Check[]>([]);\n const [filterWithResults, setFilterWithResults] = useState<boolean>(true);\n const tableOptions: TableOptions = {\n exportAllData: true,\n exportMenu: [\n {\n label: 'Export CSV',\n exportFunc: (cols, datas) => exportCsv(cols, datas, 'tech-insights'),\n },\n ],\n pageSize: props.badge ? 15 : 5,\n pageSizeOptions: props.badge ? [15, 30, 100] : [5, 10, 20],\n padding: `${props.dense ? 'dense' : 'default'}`,\n };\n\n const { value, loading, error } = useAsync(async () => {\n const checks = await api.getAllChecks();\n const result = await api.runBulkChecks([], filterSelectedChecks);\n\n return {\n checks,\n result: filterWithResults\n ? result.filter(response => response.results.length > 0)\n : result.filter(\n response =>\n (response.results?.length ?? 0) === 0 ||\n response.results.every(r => r.result === false),\n ),\n };\n }, [api, filterSelectedChecks, filterWithResults]);\n\n const tableColumns = useMemo(() => {\n const columns: TableColumn<BulkCheckResponse[0]>[] = [\n {\n field: 'entity',\n title: 'Entity',\n render: row => <EntityRefLink entityRef={row.entity} />,\n },\n {\n field: 'results',\n title: 'Results',\n render: row =>\n props.badge ? (\n <ScorecardsBadge checkResults={row.results} />\n ) : (\n <ScorecardsList checkResults={row.results} dense={props.dense} />\n ),\n export: false,\n },\n ];\n\n (filterSelectedChecks.length === 0\n ? value?.checks || []\n : filterSelectedChecks\n ).forEach(check => {\n columns.push({\n field: check.id,\n title: check.name,\n customExport: row =>\n `${\n row.results.filter(\n result => result && result.check && result.check.id === check.id,\n )[0]?.result\n }`,\n hidden: true,\n export: true,\n });\n });\n\n return columns;\n }, [props, value, filterSelectedChecks]);\n\n if (error) {\n return <ErrorPanel error={error} />;\n }\n\n return (\n <Page themeId=\"tool\">\n <Header title=\"Tech insights\">\n <HeaderLabel label=\"Entities\" value={value?.result.length ?? 0} />\n <HeaderLabel label=\"Checks\" value={value?.checks.length ?? 0} />\n </Header>\n <Content>\n <Grid container>\n <Grid item style={{ width: '300px' }}>\n <Filters\n checksChanged={checks => setFilterSelectedChecks(checks)}\n withResultsChanged={withResults =>\n setFilterWithResults(withResults)\n }\n />\n </Grid>\n <Grid item xs>\n <Table\n columns={tableColumns}\n data={value?.result ?? []}\n isLoading={loading}\n options={tableOptions}\n />\n </Grid>\n </Grid>\n </Content>\n </Page>\n );\n};\n"],"names":["exportCsv"],"mappings":";;;;;;;;;;;;;AAyCa,MAAA,cAAA,GAAiB,CAAC,KAAgD,KAAA;AAC7E,EAAM,MAAA,GAAA,GAAM,OAAO,kBAAkB,CAAA;AACrC,EAAA,MAAM,CAAC,oBAAsB,EAAA,uBAAuB,CAAI,GAAA,QAAA,CAAkB,EAAE,CAAA;AAC5E,EAAA,MAAM,CAAC,iBAAA,EAAmB,oBAAoB,CAAA,GAAI,SAAkB,IAAI,CAAA;AACxE,EAAA,MAAM,YAA6B,GAAA;AAAA,IACjC,aAAe,EAAA,IAAA;AAAA,IACf,UAAY,EAAA;AAAA,MACV;AAAA,QACE,KAAO,EAAA,YAAA;AAAA,QACP,YAAY,CAAC,IAAA,EAAM,UAAUA,SAAU,CAAA,IAAA,EAAM,OAAO,eAAe;AAAA;AACrE,KACF;AAAA,IACA,QAAA,EAAU,KAAM,CAAA,KAAA,GAAQ,EAAK,GAAA,CAAA;AAAA,IAC7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AAAA,sBAChE,GAAA,CAAC,eAAY,KAAM,EAAA,QAAA,EAAS,OAAO,KAAO,EAAA,MAAA,CAAO,UAAU,CAAG,EAAA;AAAA,KAChE,EAAA,CAAA;AAAA,oBACC,GAAA,CAAA,OAAA,EAAA,EACC,QAAC,kBAAA,IAAA,CAAA,IAAA,EAAA,EAAK,WAAS,IACb,EAAA,QAAA,EAAA;AAAA,sBAAA,GAAA,CAAC,QAAK,IAAI,EAAA,IAAA,EAAC,OAAO,EAAE,KAAA,EAAO,SACzB,EAAA,QAAA,kBAAA,GAAA;AAAA,QAAC,OAAA;AAAA,QAAA;AAAA,UACC,aAAA,EAAe,CAAU,MAAA,KAAA,uBAAA,CAAwB,MAAM,CAAA;AAAA,UACvD,kBAAA,EAAoB,CAClB,WAAA,KAAA,oBAAA,CAAqB,WAAW;AAAA;AAAA,OAGtC,EAAA,CAAA;AAAA,sBACC,GAAA,CAAA,IAAA,EAAA,EAAK,IAAI,EAAA,IAAA,EAAC,IAAE,IACX,EAAA,QAAA,kBAAA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,OAAS,EAAA,YAAA;AAAA,UACT,IAAA,EAAM,KAAO,EAAA,MAAA,IAAU,EAAC;AAAA,UACxB,SAAW,EAAA,OAAA;AAAA,UACX,OAAS,EAAA;AAAA;AAAA,OAEb,EAAA;AAAA,KAAA,EACF,CACF,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ declare const ScorecardInfo: (props: {
|
|
|
25
25
|
noWarning?: boolean | undefined;
|
|
26
26
|
expanded?: boolean | undefined;
|
|
27
27
|
dense?: boolean | undefined;
|
|
28
|
+
hideDescription?: boolean | undefined;
|
|
28
29
|
}) => react_jsx_runtime.JSX.Element;
|
|
29
30
|
/**
|
|
30
31
|
* @public
|
|
@@ -59,6 +60,7 @@ declare const EntityTechInsightsScorecardCard: (props: {
|
|
|
59
60
|
onlyFailed?: boolean | undefined;
|
|
60
61
|
expanded?: boolean | undefined;
|
|
61
62
|
gauge?: boolean | undefined;
|
|
63
|
+
dense?: boolean | undefined;
|
|
62
64
|
}) => react_jsx_runtime.JSX.Element;
|
|
63
65
|
/**
|
|
64
66
|
* @public
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-tech-insights",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "frontend-plugin",
|
|
6
6
|
"pluginId": "tech-insights",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"test": "backstage-cli package test"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@backstage-community/plugin-tech-insights-common": "^0.7.
|
|
46
|
-
"@backstage-community/plugin-tech-insights-react": "^1.2.
|
|
45
|
+
"@backstage-community/plugin-tech-insights-common": "^0.7.1",
|
|
46
|
+
"@backstage-community/plugin-tech-insights-react": "^1.2.1",
|
|
47
47
|
"@backstage/catalog-model": "^1.7.4",
|
|
48
48
|
"@backstage/core-components": "^0.17.2",
|
|
49
49
|
"@backstage/core-plugin-api": "^1.10.7",
|