@backstage-community/plugin-sonarqube 0.7.17 → 0.7.19

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +22 -0
  3. package/dist/api/SonarQubeClient.esm.js +89 -0
  4. package/dist/api/SonarQubeClient.esm.js.map +1 -0
  5. package/dist/components/SonarQubeCard/Percentage.esm.js +29 -0
  6. package/dist/components/SonarQubeCard/Percentage.esm.js.map +1 -0
  7. package/dist/components/SonarQubeCard/Rating.esm.js +81 -0
  8. package/dist/components/SonarQubeCard/Rating.esm.js.map +1 -0
  9. package/dist/components/SonarQubeCard/RatingCard.esm.js +46 -0
  10. package/dist/components/SonarQubeCard/RatingCard.esm.js.map +1 -0
  11. package/dist/components/SonarQubeCard/SonarQubeCard.esm.js +213 -0
  12. package/dist/components/SonarQubeCard/SonarQubeCard.esm.js.map +1 -0
  13. package/dist/components/SonarQubeCard/Value.esm.js +19 -0
  14. package/dist/components/SonarQubeCard/Value.esm.js.map +1 -0
  15. package/dist/components/SonarQubeCard/index.esm.js +2 -0
  16. package/dist/components/SonarQubeCard/index.esm.js.map +1 -0
  17. package/dist/components/SonarQubeContentPage/SonarQubeContentPage.esm.js +25 -0
  18. package/dist/components/SonarQubeContentPage/SonarQubeContentPage.esm.js.map +1 -0
  19. package/dist/components/SonarQubeContentPage/index.esm.js +2 -0
  20. package/dist/components/SonarQubeContentPage/index.esm.js.map +1 -0
  21. package/dist/components/index.esm.js +8 -0
  22. package/dist/components/index.esm.js.map +1 -0
  23. package/dist/index.d.ts +3 -0
  24. package/dist/index.esm.js +4 -488
  25. package/dist/index.esm.js.map +1 -1
  26. package/dist/plugin.esm.js +41 -0
  27. package/dist/plugin.esm.js.map +1 -0
  28. package/package.json +18 -12
  29. package/dist/esm/index-CwJaLZxM.esm.js +0 -22
  30. package/dist/esm/index-CwJaLZxM.esm.js.map +0 -1
  31. package/dist/esm/index-D3iMIkzq.esm.js +0 -35
  32. package/dist/esm/index-D3iMIkzq.esm.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @backstage-community/plugin-sonarqube
2
2
 
3
+ ## 0.7.19
4
+
5
+ ### Patch Changes
6
+
7
+ - eabcfbf: version:bump to v1.29.1
8
+ - Updated dependencies [eabcfbf]
9
+ - @backstage-community/plugin-sonarqube-react@0.1.17
10
+
11
+ ## 0.7.18
12
+
13
+ ### Patch Changes
14
+
15
+ - c9ceb6e: Added optional `missingAnnotationReadMoreUrl` prop to `SonarQubeContentPage` and `SonarQubeCard` to allow configurable links to documentation.
16
+ - 842559f: Updated dependency `rc-progress` to `4.0.0`.
17
+
3
18
  ## 0.7.17
4
19
 
5
20
  ### Patch Changes
package/README.md CHANGED
@@ -33,6 +33,28 @@ yarn --cwd packages/app add @backstage-community/plugin-sonarqube
33
33
  );
34
34
  ```
35
35
 
36
+ The "Read more" link that shows in the MissingAnnotationEmptyState is also configurable.
37
+
38
+ ```diff
39
+ // packages/app/src/components/catalog/EntityPage.tsx
40
+ + import { EntitySonarQubeCard } from '@backstage-community/plugin-sonarqube';
41
+
42
+ + const MISSING_ANNOTATION_READ_MORE_URL = 'https://backstage.io/docs/features/software-catalog/descriptor';
43
+
44
+ ...
45
+
46
+ const overviewContent = (
47
+ <Grid container spacing={3} alignItems="stretch">
48
+ <Grid item md={6}>
49
+ <EntityAboutCard variant="gridItem" />
50
+ </Grid>
51
+ + <Grid item md={6}>
52
+ + <EntitySonarQubeCard variant="gridItem" readMoreUrl={MISSING_ANNOTATION_READ_MORE_URL} />
53
+ + </Grid>
54
+ </Grid>
55
+ );
56
+ ```
57
+
36
58
  3. Run the following commands in the root folder of the project to install and compile the changes.
37
59
 
38
60
  ```yaml
@@ -0,0 +1,89 @@
1
+ import fetch from 'cross-fetch';
2
+
3
+ class SonarQubeClient {
4
+ discoveryApi;
5
+ identityApi;
6
+ constructor(options) {
7
+ this.discoveryApi = options.discoveryApi;
8
+ this.identityApi = options.identityApi;
9
+ }
10
+ async callApi(path, query) {
11
+ const { token: idToken } = await this.identityApi.getCredentials();
12
+ const apiUrl = `${await this.discoveryApi.getBaseUrl("sonarqube")}`;
13
+ const response = await fetch(
14
+ `${apiUrl}/${path}?${new URLSearchParams(query).toString()}`,
15
+ {
16
+ headers: {
17
+ "Content-Type": "application/json",
18
+ ...idToken && { Authorization: `Bearer ${idToken}` }
19
+ }
20
+ }
21
+ );
22
+ if (response.status === 200) {
23
+ return await response.json();
24
+ }
25
+ return void 0;
26
+ }
27
+ async getFindingSummary({
28
+ componentKey,
29
+ projectInstance
30
+ } = {}) {
31
+ if (!componentKey) {
32
+ return void 0;
33
+ }
34
+ const instanceKey = projectInstance || "";
35
+ const metrics = {
36
+ alert_status: void 0,
37
+ bugs: void 0,
38
+ reliability_rating: void 0,
39
+ vulnerabilities: void 0,
40
+ security_rating: void 0,
41
+ security_hotspots_reviewed: void 0,
42
+ security_review_rating: void 0,
43
+ code_smells: void 0,
44
+ sqale_rating: void 0,
45
+ coverage: void 0,
46
+ duplicated_lines_density: void 0
47
+ };
48
+ const baseUrlWrapper = await this.callApi(
49
+ "instanceUrl",
50
+ {
51
+ instanceKey
52
+ }
53
+ );
54
+ let baseUrl = baseUrlWrapper?.instanceUrl;
55
+ if (!baseUrl) {
56
+ return void 0;
57
+ }
58
+ if (!baseUrl.endsWith("/")) {
59
+ baseUrl += "/";
60
+ }
61
+ const findings = await this.callApi("findings", {
62
+ componentKey,
63
+ instanceKey
64
+ });
65
+ if (!findings) {
66
+ return void 0;
67
+ }
68
+ findings.measures.forEach((m) => {
69
+ metrics[m.metric] = m.value;
70
+ });
71
+ return {
72
+ lastAnalysis: findings.analysisDate,
73
+ metrics,
74
+ projectUrl: `${baseUrl}dashboard?id=${encodeURIComponent(componentKey)}`,
75
+ getIssuesUrl: (identifier) => `${baseUrl}project/issues?id=${encodeURIComponent(
76
+ componentKey
77
+ )}&types=${identifier.toLocaleUpperCase("en-US")}&resolved=false`,
78
+ getComponentMeasuresUrl: (identifier) => `${baseUrl}component_measures?id=${encodeURIComponent(
79
+ componentKey
80
+ )}&metric=${identifier.toLocaleLowerCase(
81
+ "en-US"
82
+ )}&resolved=false&view=list`,
83
+ getSecurityHotspotsUrl: () => `${baseUrl}${baseUrl === "https://sonarcloud.io/" ? "project/" : ""}security_hotspots?id=${encodeURIComponent(componentKey)}`
84
+ };
85
+ }
86
+ }
87
+
88
+ export { SonarQubeClient };
89
+ //# sourceMappingURL=SonarQubeClient.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SonarQubeClient.esm.js","sources":["../../src/api/SonarQubeClient.ts"],"sourcesContent":["/*\n * Copyright 2020 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 fetch from 'cross-fetch';\nimport {\n FindingSummary,\n Metrics,\n SonarQubeApi,\n} from '@backstage-community/plugin-sonarqube-react';\nimport { InstanceUrlWrapper, FindingsWrapper } from './types';\nimport { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api';\n\n/** @public */\nexport class SonarQubeClient implements SonarQubeApi {\n discoveryApi: DiscoveryApi;\n identityApi: IdentityApi;\n\n constructor(options: {\n discoveryApi: DiscoveryApi;\n identityApi: IdentityApi;\n }) {\n this.discoveryApi = options.discoveryApi;\n this.identityApi = options.identityApi;\n }\n\n private async callApi<T>(\n path: string,\n query: { [key in string]: any },\n ): Promise<T | undefined> {\n const { token: idToken } = await this.identityApi.getCredentials();\n\n const apiUrl = `${await this.discoveryApi.getBaseUrl('sonarqube')}`;\n const response = await fetch(\n `${apiUrl}/${path}?${new URLSearchParams(query).toString()}`,\n {\n headers: {\n 'Content-Type': 'application/json',\n ...(idToken && { Authorization: `Bearer ${idToken}` }),\n },\n },\n );\n if (response.status === 200) {\n return (await response.json()) as T;\n }\n return undefined;\n }\n\n async getFindingSummary({\n componentKey,\n projectInstance,\n }: {\n componentKey?: string;\n projectInstance?: string;\n } = {}): Promise<FindingSummary | undefined> {\n if (!componentKey) {\n return undefined;\n }\n\n const instanceKey = projectInstance || '';\n\n const metrics: Metrics = {\n alert_status: undefined,\n bugs: undefined,\n reliability_rating: undefined,\n vulnerabilities: undefined,\n security_rating: undefined,\n security_hotspots_reviewed: undefined,\n security_review_rating: undefined,\n code_smells: undefined,\n sqale_rating: undefined,\n coverage: undefined,\n duplicated_lines_density: undefined,\n };\n\n const baseUrlWrapper = await this.callApi<InstanceUrlWrapper>(\n 'instanceUrl',\n {\n instanceKey,\n },\n );\n let baseUrl = baseUrlWrapper?.instanceUrl;\n if (!baseUrl) {\n return undefined;\n }\n // ensure trailing slash for later on\n if (!baseUrl.endsWith('/')) {\n baseUrl += '/';\n }\n\n const findings = await this.callApi<FindingsWrapper>('findings', {\n componentKey,\n instanceKey,\n });\n if (!findings) {\n return undefined;\n }\n\n findings.measures.forEach(m => {\n metrics[m.metric] = m.value;\n });\n\n return {\n lastAnalysis: findings.analysisDate,\n metrics,\n projectUrl: `${baseUrl}dashboard?id=${encodeURIComponent(componentKey)}`,\n getIssuesUrl: identifier =>\n `${baseUrl}project/issues?id=${encodeURIComponent(\n componentKey,\n )}&types=${identifier.toLocaleUpperCase('en-US')}&resolved=false`,\n getComponentMeasuresUrl: identifier =>\n `${baseUrl}component_measures?id=${encodeURIComponent(\n componentKey,\n )}&metric=${identifier.toLocaleLowerCase(\n 'en-US',\n )}&resolved=false&view=list`,\n getSecurityHotspotsUrl: () =>\n `${baseUrl}${\n baseUrl === 'https://sonarcloud.io/' ? 'project/' : ''\n }security_hotspots?id=${encodeURIComponent(componentKey)}`,\n };\n }\n}\n"],"names":[],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;AAAA,MACL,cAAc,QAAS,CAAA,YAAA;AAAA,MACvB,OAAA;AAAA,MACA,YAAY,CAAG,EAAA,OAAO,CAAgB,aAAA,EAAA,kBAAA,CAAmB,YAAY,CAAC,CAAA,CAAA;AAAA,MACtE,YAAc,EAAA,CAAA,UAAA,KACZ,CAAG,EAAA,OAAO,CAAqB,kBAAA,EAAA,kBAAA;AAAA,QAC7B,YAAA;AAAA,OACD,CAAA,OAAA,EAAU,UAAW,CAAA,iBAAA,CAAkB,OAAO,CAAC,CAAA,eAAA,CAAA;AAAA,MAClD,uBAAyB,EAAA,CAAA,UAAA,KACvB,CAAG,EAAA,OAAO,CAAyB,sBAAA,EAAA,kBAAA;AAAA,QACjC,YAAA;AAAA,OACD,WAAW,UAAW,CAAA,iBAAA;AAAA,QACrB,OAAA;AAAA,OACD,CAAA,yBAAA,CAAA;AAAA,MACH,sBAAwB,EAAA,MACtB,CAAG,EAAA,OAAO,CACR,EAAA,OAAA,KAAY,wBAA2B,GAAA,UAAA,GAAa,EACtD,CAAA,qBAAA,EAAwB,kBAAmB,CAAA,YAAY,CAAC,CAAA,CAAA;AAAA,KAC5D,CAAA;AAAA,GACF;AACF;;;;"}
@@ -0,0 +1,29 @@
1
+ import { makeStyles, useTheme } from '@material-ui/core/styles';
2
+ import { Circle } from 'rc-progress';
3
+ import React from 'react';
4
+
5
+ const useStyles = makeStyles((theme) => ({
6
+ root: {
7
+ height: theme.spacing(3),
8
+ width: theme.spacing(3)
9
+ }
10
+ }));
11
+ const Percentage = ({ value }) => {
12
+ const classes = useStyles();
13
+ const theme = useTheme();
14
+ return /* @__PURE__ */ React.createElement(
15
+ Circle,
16
+ {
17
+ strokeLinecap: "butt",
18
+ percent: +(value || 0),
19
+ strokeWidth: 16,
20
+ strokeColor: theme.palette.status.ok,
21
+ trailColor: theme.palette.status.error,
22
+ trailWidth: 16,
23
+ className: classes.root
24
+ }
25
+ );
26
+ };
27
+
28
+ export { Percentage };
29
+ //# sourceMappingURL=Percentage.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Percentage.esm.js","sources":["../../../src/components/SonarQubeCard/Percentage.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { makeStyles } from '@material-ui/core/styles';\nimport { useTheme } from '@material-ui/core/styles';\nimport { Circle } from 'rc-progress';\nimport React from 'react';\n\nconst useStyles = makeStyles(theme => ({\n root: {\n height: theme.spacing(3),\n width: theme.spacing(3),\n },\n}));\n\nexport const Percentage = ({ value }: { value?: string }) => {\n const classes = useStyles();\n const theme = useTheme();\n\n return (\n <Circle\n strokeLinecap=\"butt\"\n percent={+(value || 0)}\n strokeWidth={16}\n strokeColor={theme.palette.status.ok}\n trailColor={theme.palette.status.error}\n trailWidth={16}\n className={classes.root}\n />\n );\n};\n"],"names":[],"mappings":";;;;AAqBA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,IAAM,EAAA;AAAA,IACJ,MAAA,EAAQ,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IACvB,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,GACxB;AACF,CAAE,CAAA,CAAA,CAAA;AAEK,MAAM,UAAa,GAAA,CAAC,EAAE,KAAA,EAAgC,KAAA;AAC3D,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EAAA,MAAM,QAAQ,QAAS,EAAA,CAAA;AAEvB,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,aAAc,EAAA,MAAA;AAAA,MACd,OAAA,EAAS,EAAE,KAAS,IAAA,CAAA,CAAA;AAAA,MACpB,WAAa,EAAA,EAAA;AAAA,MACb,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA,EAAA;AAAA,MAClC,UAAA,EAAY,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA,KAAA;AAAA,MACjC,UAAY,EAAA,EAAA;AAAA,MACZ,WAAW,OAAQ,CAAA,IAAA;AAAA,KAAA;AAAA,GACrB,CAAA;AAEJ;;;;"}
@@ -0,0 +1,81 @@
1
+ import Avatar from '@material-ui/core/Avatar';
2
+ import { makeStyles, lighten } from '@material-ui/core/styles';
3
+ import React, { useMemo } from 'react';
4
+
5
+ const useStyles = makeStyles((theme) => {
6
+ const commonCardRating = {
7
+ height: theme.spacing(3),
8
+ width: theme.spacing(3),
9
+ color: theme.palette.common.white
10
+ };
11
+ return {
12
+ ratingDefault: {
13
+ ...commonCardRating,
14
+ background: theme.palette.status.aborted
15
+ },
16
+ ratingA: {
17
+ ...commonCardRating,
18
+ background: theme.palette.status.ok
19
+ },
20
+ ratingB: {
21
+ ...commonCardRating,
22
+ background: lighten(theme.palette.status.ok, 0.5)
23
+ },
24
+ ratingC: {
25
+ ...commonCardRating,
26
+ background: theme.palette.status.pending
27
+ },
28
+ ratingD: {
29
+ ...commonCardRating,
30
+ background: theme.palette.status.warning
31
+ },
32
+ ratingE: {
33
+ ...commonCardRating,
34
+ background: theme.palette.error.main
35
+ }
36
+ };
37
+ });
38
+ const Rating = ({
39
+ rating,
40
+ hideValue
41
+ }) => {
42
+ const classes = useStyles();
43
+ const ratingProp = useMemo(() => {
44
+ switch (rating) {
45
+ case "1.0":
46
+ return {
47
+ name: "A",
48
+ className: classes.ratingA
49
+ };
50
+ case "2.0":
51
+ return {
52
+ name: "B",
53
+ className: classes.ratingB
54
+ };
55
+ case "3.0":
56
+ return {
57
+ name: "C",
58
+ className: classes.ratingC
59
+ };
60
+ case "4.0":
61
+ return {
62
+ name: "D",
63
+ className: classes.ratingD
64
+ };
65
+ case "5.0":
66
+ return {
67
+ name: "E",
68
+ className: classes.ratingE
69
+ };
70
+ default:
71
+ return {
72
+ name: "",
73
+ className: classes.ratingDefault
74
+ };
75
+ }
76
+ }, [classes, rating]);
77
+ return /* @__PURE__ */ React.createElement(Avatar, { className: ratingProp.className }, !hideValue && ratingProp.name);
78
+ };
79
+
80
+ export { Rating };
81
+ //# sourceMappingURL=Rating.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Rating.esm.js","sources":["../../../src/components/SonarQubeCard/Rating.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 Avatar from '@material-ui/core/Avatar';\nimport { lighten, makeStyles } from '@material-ui/core/styles';\nimport { CSSProperties } from '@material-ui/styles/withStyles';\nimport React, { useMemo } from 'react';\n\nconst useStyles = makeStyles(theme => {\n const commonCardRating: CSSProperties = {\n height: theme.spacing(3),\n width: theme.spacing(3),\n color: theme.palette.common.white,\n };\n\n return {\n ratingDefault: {\n ...commonCardRating,\n background: theme.palette.status.aborted,\n },\n ratingA: {\n ...commonCardRating,\n background: theme.palette.status.ok,\n },\n ratingB: {\n ...commonCardRating,\n background: lighten(theme.palette.status.ok, 0.5),\n },\n ratingC: {\n ...commonCardRating,\n background: theme.palette.status.pending,\n },\n ratingD: {\n ...commonCardRating,\n background: theme.palette.status.warning,\n },\n ratingE: {\n ...commonCardRating,\n background: theme.palette.error.main,\n },\n };\n});\n\nexport const Rating = ({\n rating,\n hideValue,\n}: {\n rating?: string;\n hideValue?: boolean;\n}) => {\n const classes = useStyles();\n\n const ratingProp = useMemo(() => {\n switch (rating) {\n case '1.0':\n return {\n name: 'A',\n className: classes.ratingA,\n };\n\n case '2.0':\n return {\n name: 'B',\n className: classes.ratingB,\n };\n\n case '3.0':\n return {\n name: 'C',\n className: classes.ratingC,\n };\n\n case '4.0':\n return {\n name: 'D',\n className: classes.ratingD,\n };\n\n case '5.0':\n return {\n name: 'E',\n className: classes.ratingE,\n };\n\n default:\n return {\n name: '',\n className: classes.ratingDefault,\n };\n }\n }, [classes, rating]);\n\n return (\n <Avatar className={ratingProp.className}>\n {!hideValue && ratingProp.name}\n </Avatar>\n );\n};\n"],"names":[],"mappings":";;;;AAqBA,MAAM,SAAA,GAAY,WAAW,CAAS,KAAA,KAAA;AACpC,EAAA,MAAM,gBAAkC,GAAA;AAAA,IACtC,MAAA,EAAQ,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IACvB,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,IACtB,KAAA,EAAO,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA,KAAA;AAAA,GAC9B,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,aAAe,EAAA;AAAA,MACb,GAAG,gBAAA;AAAA,MACH,UAAA,EAAY,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA,OAAA;AAAA,KACnC;AAAA,IACA,OAAS,EAAA;AAAA,MACP,GAAG,gBAAA;AAAA,MACH,UAAA,EAAY,KAAM,CAAA,OAAA,CAAQ,MAAO,CAAA,EAAA;AAAA,KACnC;AAAA,IACA,OAAS,EAAA;AAAA,MACP,GAAG,gBAAA;AAAA,MACH,YAAY,OAAQ,CAAA,KAAA,CAAM,OAAQ,CAAA,MAAA,CAAO,IAAI,GAAG,CAAA;AAAA,KAClD;AAAA,IACA,OAAS,EAAA;AAAA,MACP,GAAG,gBAAA;AAAA,MACH,UAAA,EAAY,KAAM,CAAA,OA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;AAAA,SACrB,CAAA;AAAA,KACJ;AAAA,GACC,EAAA,CAAC,OAAS,EAAA,MAAM,CAAC,CAAA,CAAA;AAEpB,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,UAAO,SAAW,EAAA,UAAA,CAAW,aAC3B,CAAC,SAAA,IAAa,WAAW,IAC5B,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,46 @@
1
+ import { Link } from '@backstage/core-components';
2
+ import Grid from '@material-ui/core/Grid';
3
+ import Typography from '@material-ui/core/Typography';
4
+ import { makeStyles } from '@material-ui/core/styles';
5
+ import React from 'react';
6
+
7
+ const useStyles = makeStyles((theme) => {
8
+ return {
9
+ root: {
10
+ margin: theme.spacing(1, 0),
11
+ minWidth: "140px"
12
+ },
13
+ upper: {
14
+ display: "flex",
15
+ justifyContent: "center",
16
+ alignItems: "center"
17
+ },
18
+ cardTitle: {
19
+ textAlign: "center"
20
+ },
21
+ wrapIcon: {
22
+ display: "inline-flex",
23
+ verticalAlign: "baseline"
24
+ },
25
+ left: {
26
+ display: "flex"
27
+ },
28
+ right: {
29
+ display: "flex",
30
+ marginLeft: theme.spacing(0.5)
31
+ }
32
+ };
33
+ });
34
+ const RatingCard = ({
35
+ leftSlot,
36
+ rightSlot,
37
+ title,
38
+ titleIcon,
39
+ link
40
+ }) => {
41
+ const classes = useStyles();
42
+ return /* @__PURE__ */ React.createElement(Link, { to: link, color: "inherit", underline: "none" }, /* @__PURE__ */ React.createElement(Grid, { item: true, className: classes.root }, /* @__PURE__ */ React.createElement(Grid, { item: true, className: classes.upper }, /* @__PURE__ */ React.createElement(Grid, { item: true, className: classes.left }, leftSlot), /* @__PURE__ */ React.createElement(Grid, { item: true, className: classes.right }, rightSlot)), /* @__PURE__ */ React.createElement(Grid, { item: true, className: classes.cardTitle }, /* @__PURE__ */ React.createElement(Typography, { variant: "body1", className: classes.wrapIcon }, titleIcon, " ", title))));
43
+ };
44
+
45
+ export { RatingCard };
46
+ //# sourceMappingURL=RatingCard.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RatingCard.esm.js","sources":["../../../src/components/SonarQubeCard/RatingCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { Link } from '@backstage/core-components';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { makeStyles } from '@material-ui/core/styles';\nimport React, { ReactNode } from 'react';\n\nconst useStyles = makeStyles(theme => {\n return {\n root: {\n margin: theme.spacing(1, 0),\n minWidth: '140px',\n },\n upper: {\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n },\n cardTitle: {\n textAlign: 'center',\n },\n wrapIcon: {\n display: 'inline-flex',\n verticalAlign: 'baseline',\n },\n left: {\n display: 'flex',\n },\n right: {\n display: 'flex',\n marginLeft: theme.spacing(0.5),\n },\n };\n});\n\nexport const RatingCard = ({\n leftSlot,\n rightSlot,\n title,\n titleIcon,\n link,\n}: {\n leftSlot: ReactNode;\n rightSlot: ReactNode;\n title: string;\n titleIcon?: ReactNode;\n link: string;\n}) => {\n const classes = useStyles();\n\n return (\n <Link to={link} color=\"inherit\" underline=\"none\">\n <Grid item className={classes.root}>\n <Grid item className={classes.upper}>\n <Grid item className={classes.left}>\n {leftSlot}\n </Grid>\n <Grid item className={classes.right}>\n {rightSlot}\n </Grid>\n </Grid>\n <Grid item className={classes.cardTitle}>\n <Typography variant=\"body1\" className={classes.wrapIcon}>\n {titleIcon} {title}\n </Typography>\n </Grid>\n </Grid>\n </Link>\n );\n};\n"],"names":[],"mappings":";;;;;;AAsB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A,kBAC3B,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,IAAI,EAAA,IAAA,EAAC,SAAW,EAAA,OAAA,CAAQ,IAC3B,EAAA,EAAA,QACH,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,IAAC,EAAA,SAAA,EAAW,OAAQ,CAAA,KAAA,EAAA,EAC3B,SACH,CACF,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,IAAA,EAAI,IAAC,EAAA,SAAA,EAAW,OAAQ,CAAA,SAAA,EAAA,kBAC3B,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,OAAQ,EAAA,OAAA,EAAQ,SAAW,EAAA,OAAA,CAAQ,QAC5C,EAAA,EAAA,SAAA,EAAU,GAAE,EAAA,KACf,CACF,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,213 @@
1
+ import { useEntity, MissingAnnotationEmptyState } from '@backstage/plugin-catalog-react';
2
+ import { sonarQubeApiRef, useProjectInfo, SONARQUBE_PROJECT_KEY_ANNOTATION } from '@backstage-community/plugin-sonarqube-react';
3
+ import Chip from '@material-ui/core/Chip';
4
+ import Grid from '@material-ui/core/Grid';
5
+ import { makeStyles } from '@material-ui/core/styles';
6
+ import BugReport from '@material-ui/icons/BugReport';
7
+ import Lock from '@material-ui/icons/Lock';
8
+ import LockOpen from '@material-ui/icons/LockOpen';
9
+ import Security from '@material-ui/icons/Security';
10
+ import SentimentVeryDissatisfied from '@material-ui/icons/SentimentVeryDissatisfied';
11
+ import SentimentVerySatisfied from '@material-ui/icons/SentimentVerySatisfied';
12
+ import React, { useMemo } from 'react';
13
+ import useAsync from 'react-use/esm/useAsync';
14
+ import { Percentage } from './Percentage.esm.js';
15
+ import { Rating } from './Rating.esm.js';
16
+ import { RatingCard } from './RatingCard.esm.js';
17
+ import { Value } from './Value.esm.js';
18
+ import { InfoCard, Progress, EmptyState } from '@backstage/core-components';
19
+ import { useApi } from '@backstage/core-plugin-api';
20
+ import { DateTime } from 'luxon';
21
+
22
+ const useStyles = makeStyles((theme) => ({
23
+ badgeLabel: {
24
+ color: theme.palette.common.white
25
+ },
26
+ badgeError: {
27
+ margin: 0,
28
+ backgroundColor: theme.palette.error.main
29
+ },
30
+ badgeSuccess: {
31
+ margin: 0,
32
+ backgroundColor: theme.palette.success.main
33
+ },
34
+ badgeUnknown: {
35
+ backgroundColor: theme.palette.grey[500]
36
+ },
37
+ header: {
38
+ padding: theme.spacing(2, 2, 2, 2.5)
39
+ },
40
+ action: {
41
+ margin: 0
42
+ },
43
+ lastAnalyzed: {
44
+ color: theme.palette.text.secondary
45
+ }
46
+ }));
47
+ const defaultDuplicationRatings = [
48
+ { greaterThan: 0, rating: "1.0" },
49
+ { greaterThan: 3, rating: "2.0" },
50
+ { greaterThan: 5, rating: "3.0" },
51
+ { greaterThan: 10, rating: "4.0" },
52
+ { greaterThan: 20, rating: "5.0" }
53
+ ];
54
+ const SonarQubeCard = (props) => {
55
+ const {
56
+ variant = "gridItem",
57
+ duplicationRatings = defaultDuplicationRatings,
58
+ missingAnnotationReadMoreUrl
59
+ } = props;
60
+ const { entity } = useEntity();
61
+ const sonarQubeApi = useApi(sonarQubeApiRef);
62
+ const { projectKey: projectTitle, projectInstance } = useProjectInfo(entity);
63
+ const { value, loading } = useAsync(
64
+ async () => sonarQubeApi.getFindingSummary({
65
+ componentKey: projectTitle,
66
+ projectInstance
67
+ }),
68
+ [sonarQubeApi, projectTitle]
69
+ );
70
+ const deepLink = !loading && value ? {
71
+ title: "View more",
72
+ link: value.projectUrl
73
+ } : void 0;
74
+ const classes = useStyles();
75
+ let gateLabel = "Not computed";
76
+ let gateColor = classes.badgeUnknown;
77
+ if (value?.metrics.alert_status) {
78
+ const gatePassed = value.metrics.alert_status === "OK";
79
+ gateLabel = gatePassed ? "Gate passed" : "Gate failed";
80
+ gateColor = gatePassed ? classes.badgeSuccess : classes.badgeError;
81
+ }
82
+ const qualityBadge = !loading && value && /* @__PURE__ */ React.createElement(
83
+ Chip,
84
+ {
85
+ label: gateLabel,
86
+ classes: { root: gateColor, label: classes.badgeLabel }
87
+ }
88
+ );
89
+ const duplicationRating = useMemo(() => {
90
+ if (loading || !value || !value.metrics.duplicated_lines_density) {
91
+ return "";
92
+ }
93
+ let rating = "";
94
+ for (const r of duplicationRatings) {
95
+ if (+value.metrics.duplicated_lines_density >= r.greaterThan) {
96
+ rating = r.rating;
97
+ }
98
+ }
99
+ return rating;
100
+ }, [loading, value, duplicationRatings]);
101
+ return /* @__PURE__ */ React.createElement(
102
+ InfoCard,
103
+ {
104
+ title: "Code Quality",
105
+ deepLink,
106
+ variant,
107
+ headerProps: {
108
+ action: qualityBadge,
109
+ classes: {
110
+ root: classes.header,
111
+ action: classes.action
112
+ }
113
+ }
114
+ },
115
+ loading && /* @__PURE__ */ React.createElement(Progress, null),
116
+ !loading && !projectTitle && /* @__PURE__ */ React.createElement(
117
+ MissingAnnotationEmptyState,
118
+ {
119
+ annotation: SONARQUBE_PROJECT_KEY_ANNOTATION,
120
+ readMoreUrl: missingAnnotationReadMoreUrl
121
+ }
122
+ ),
123
+ !loading && projectTitle && !value && /* @__PURE__ */ React.createElement(
124
+ EmptyState,
125
+ {
126
+ missing: "info",
127
+ title: "No information to display",
128
+ description: `There is no SonarQube project with key '${projectTitle}'.`
129
+ }
130
+ ),
131
+ !loading && value && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
132
+ Grid,
133
+ {
134
+ item: true,
135
+ container: true,
136
+ direction: "column",
137
+ justifyContent: "space-between",
138
+ alignItems: "center",
139
+ style: { height: "100%" },
140
+ spacing: 0
141
+ },
142
+ /* @__PURE__ */ React.createElement(Grid, { item: true, container: true, justifyContent: "space-around" }, /* @__PURE__ */ React.createElement(
143
+ RatingCard,
144
+ {
145
+ titleIcon: /* @__PURE__ */ React.createElement(BugReport, null),
146
+ title: "Bugs",
147
+ link: value.getIssuesUrl("BUG"),
148
+ leftSlot: /* @__PURE__ */ React.createElement(Value, { value: value.metrics.bugs }),
149
+ rightSlot: /* @__PURE__ */ React.createElement(Rating, { rating: value.metrics.reliability_rating })
150
+ }
151
+ ), /* @__PURE__ */ React.createElement(
152
+ RatingCard,
153
+ {
154
+ titleIcon: value.metrics.vulnerabilities === "0" ? /* @__PURE__ */ React.createElement(Lock, null) : /* @__PURE__ */ React.createElement(LockOpen, null),
155
+ title: "Vulnerabilities",
156
+ link: value.getIssuesUrl("VULNERABILITY"),
157
+ leftSlot: /* @__PURE__ */ React.createElement(Value, { value: value.metrics.vulnerabilities }),
158
+ rightSlot: /* @__PURE__ */ React.createElement(Rating, { rating: value.metrics.security_rating })
159
+ }
160
+ ), /* @__PURE__ */ React.createElement(
161
+ RatingCard,
162
+ {
163
+ titleIcon: value.metrics.code_smells === "0" ? /* @__PURE__ */ React.createElement(SentimentVerySatisfied, null) : /* @__PURE__ */ React.createElement(SentimentVeryDissatisfied, null),
164
+ title: "Code Smells",
165
+ link: value.getIssuesUrl("CODE_SMELL"),
166
+ leftSlot: /* @__PURE__ */ React.createElement(Value, { value: value.metrics.code_smells }),
167
+ rightSlot: /* @__PURE__ */ React.createElement(Rating, { rating: value.metrics.sqale_rating })
168
+ }
169
+ ), value.metrics.security_review_rating && /* @__PURE__ */ React.createElement(
170
+ RatingCard,
171
+ {
172
+ titleIcon: /* @__PURE__ */ React.createElement(Security, null),
173
+ title: "Hotspots Reviewed",
174
+ link: value.getSecurityHotspotsUrl(),
175
+ leftSlot: /* @__PURE__ */ React.createElement(
176
+ Value,
177
+ {
178
+ value: value.metrics.security_hotspots_reviewed ? `${value.metrics.security_hotspots_reviewed}%` : "\u2014"
179
+ }
180
+ ),
181
+ rightSlot: /* @__PURE__ */ React.createElement(Rating, { rating: value.metrics.security_review_rating })
182
+ }
183
+ ), /* @__PURE__ */ React.createElement("div", { style: { width: "100%" } }), /* @__PURE__ */ React.createElement(
184
+ RatingCard,
185
+ {
186
+ link: value.getComponentMeasuresUrl("COVERAGE"),
187
+ title: "Coverage",
188
+ leftSlot: /* @__PURE__ */ React.createElement(Percentage, { value: value.metrics.coverage }),
189
+ rightSlot: /* @__PURE__ */ React.createElement(
190
+ Value,
191
+ {
192
+ value: value.metrics.coverage !== void 0 ? `${value.metrics.coverage}%` : "\u2014"
193
+ }
194
+ )
195
+ }
196
+ ), /* @__PURE__ */ React.createElement(
197
+ RatingCard,
198
+ {
199
+ title: "Duplications",
200
+ link: value.getComponentMeasuresUrl("DUPLICATED_LINES_DENSITY"),
201
+ leftSlot: /* @__PURE__ */ React.createElement(Rating, { rating: duplicationRating, hideValue: true }),
202
+ rightSlot: /* @__PURE__ */ React.createElement(Value, { value: `${value.metrics.duplicated_lines_density}%` })
203
+ }
204
+ )),
205
+ /* @__PURE__ */ React.createElement(Grid, { item: true, className: classes.lastAnalyzed }, "Last analyzed on", " ", DateTime.fromISO(value.lastAnalysis).toLocaleString(
206
+ DateTime.DATETIME_MED
207
+ ))
208
+ ))
209
+ );
210
+ };
211
+
212
+ export { SonarQubeCard };
213
+ //# sourceMappingURL=SonarQubeCard.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SonarQubeCard.esm.js","sources":["../../../src/components/SonarQubeCard/SonarQubeCard.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 {\n useEntity,\n MissingAnnotationEmptyState,\n} from '@backstage/plugin-catalog-react';\nimport {\n sonarQubeApiRef,\n useProjectInfo,\n} from '@backstage-community/plugin-sonarqube-react';\nimport { SONARQUBE_PROJECT_KEY_ANNOTATION } from '@backstage-community/plugin-sonarqube-react';\nimport Chip from '@material-ui/core/Chip';\nimport Grid from '@material-ui/core/Grid';\nimport { makeStyles } from '@material-ui/core/styles';\nimport BugReport from '@material-ui/icons/BugReport';\nimport Lock from '@material-ui/icons/Lock';\nimport LockOpen from '@material-ui/icons/LockOpen';\nimport Security from '@material-ui/icons/Security';\nimport SentimentVeryDissatisfied from '@material-ui/icons/SentimentVeryDissatisfied';\nimport SentimentVerySatisfied from '@material-ui/icons/SentimentVerySatisfied';\nimport React, { useMemo } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { Percentage } from './Percentage';\nimport { Rating } from './Rating';\nimport { RatingCard } from './RatingCard';\nimport { Value } from './Value';\nimport {\n EmptyState,\n InfoCard,\n InfoCardVariants,\n Progress,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { DateTime } from 'luxon';\n\nconst useStyles = makeStyles(theme => ({\n badgeLabel: {\n color: theme.palette.common.white,\n },\n badgeError: {\n margin: 0,\n backgroundColor: theme.palette.error.main,\n },\n badgeSuccess: {\n margin: 0,\n backgroundColor: theme.palette.success.main,\n },\n badgeUnknown: {\n backgroundColor: theme.palette.grey[500],\n },\n header: {\n padding: theme.spacing(2, 2, 2, 2.5),\n },\n action: {\n margin: 0,\n },\n lastAnalyzed: {\n color: theme.palette.text.secondary,\n },\n}));\n\n/** @public */\nexport type DuplicationRating = {\n greaterThan: number;\n rating: '1.0' | '2.0' | '3.0' | '4.0' | '5.0';\n};\n\nconst defaultDuplicationRatings: DuplicationRating[] = [\n { greaterThan: 0, rating: '1.0' },\n { greaterThan: 3, rating: '2.0' },\n { greaterThan: 5, rating: '3.0' },\n { greaterThan: 10, rating: '4.0' },\n { greaterThan: 20, rating: '5.0' },\n];\n\n/** @public */\nexport const SonarQubeCard = (props: {\n variant?: InfoCardVariants;\n duplicationRatings?: DuplicationRating[];\n missingAnnotationReadMoreUrl?: string;\n}) => {\n const {\n variant = 'gridItem',\n duplicationRatings = defaultDuplicationRatings,\n missingAnnotationReadMoreUrl,\n } = props;\n const { entity } = useEntity();\n const sonarQubeApi = useApi(sonarQubeApiRef);\n\n const { projectKey: projectTitle, projectInstance } = useProjectInfo(entity);\n\n const { value, loading } = useAsync(\n async () =>\n sonarQubeApi.getFindingSummary({\n componentKey: projectTitle,\n projectInstance: projectInstance,\n }),\n [sonarQubeApi, projectTitle],\n );\n\n const deepLink =\n !loading && value\n ? {\n title: 'View more',\n link: value.projectUrl,\n }\n : undefined;\n\n const classes = useStyles();\n let gateLabel = 'Not computed';\n let gateColor = classes.badgeUnknown;\n\n if (value?.metrics.alert_status) {\n const gatePassed = value.metrics.alert_status === 'OK';\n gateLabel = gatePassed ? 'Gate passed' : 'Gate failed';\n gateColor = gatePassed ? classes.badgeSuccess : classes.badgeError;\n }\n\n const qualityBadge = !loading && value && (\n <Chip\n label={gateLabel}\n classes={{ root: gateColor, label: classes.badgeLabel }}\n />\n );\n\n const duplicationRating = useMemo(() => {\n if (loading || !value || !value.metrics.duplicated_lines_density) {\n return '';\n }\n\n let rating = '';\n\n for (const r of duplicationRatings) {\n if (+value.metrics.duplicated_lines_density >= r.greaterThan) {\n rating = r.rating;\n }\n }\n\n return rating;\n }, [loading, value, duplicationRatings]);\n\n return (\n <InfoCard\n title=\"Code Quality\"\n deepLink={deepLink}\n variant={variant}\n headerProps={{\n action: qualityBadge,\n classes: {\n root: classes.header,\n action: classes.action,\n },\n }}\n >\n {loading && <Progress />}\n\n {!loading && !projectTitle && (\n <MissingAnnotationEmptyState\n annotation={SONARQUBE_PROJECT_KEY_ANNOTATION}\n readMoreUrl={missingAnnotationReadMoreUrl}\n />\n )}\n\n {!loading && projectTitle && !value && (\n <EmptyState\n missing=\"info\"\n title=\"No information to display\"\n description={`There is no SonarQube project with key '${projectTitle}'.`}\n />\n )}\n\n {!loading && value && (\n <>\n <Grid\n item\n container\n direction=\"column\"\n justifyContent=\"space-between\"\n alignItems=\"center\"\n style={{ height: '100%' }}\n spacing={0}\n >\n <Grid item container justifyContent=\"space-around\">\n <RatingCard\n titleIcon={<BugReport />}\n title=\"Bugs\"\n link={value.getIssuesUrl('BUG')}\n leftSlot={<Value value={value.metrics.bugs} />}\n rightSlot={<Rating rating={value.metrics.reliability_rating} />}\n />\n <RatingCard\n titleIcon={\n value.metrics.vulnerabilities === '0' ? (\n <Lock />\n ) : (\n <LockOpen />\n )\n }\n title=\"Vulnerabilities\"\n link={value.getIssuesUrl('VULNERABILITY')}\n leftSlot={<Value value={value.metrics.vulnerabilities} />}\n rightSlot={<Rating rating={value.metrics.security_rating} />}\n />\n <RatingCard\n titleIcon={\n value.metrics.code_smells === '0' ? (\n <SentimentVerySatisfied />\n ) : (\n <SentimentVeryDissatisfied />\n )\n }\n title=\"Code Smells\"\n link={value.getIssuesUrl('CODE_SMELL')}\n leftSlot={<Value value={value.metrics.code_smells} />}\n rightSlot={<Rating rating={value.metrics.sqale_rating} />}\n />\n {value.metrics.security_review_rating && (\n <RatingCard\n titleIcon={<Security />}\n title=\"Hotspots Reviewed\"\n link={value.getSecurityHotspotsUrl()}\n leftSlot={\n <Value\n value={\n value.metrics.security_hotspots_reviewed\n ? `${value.metrics.security_hotspots_reviewed}%`\n : '—'\n }\n />\n }\n rightSlot={\n <Rating rating={value.metrics.security_review_rating} />\n }\n />\n )}\n <div style={{ width: '100%' }} />\n <RatingCard\n link={value.getComponentMeasuresUrl('COVERAGE')}\n title=\"Coverage\"\n leftSlot={<Percentage value={value.metrics.coverage} />}\n rightSlot={\n <Value\n value={\n value.metrics.coverage !== undefined\n ? `${value.metrics.coverage}%`\n : '—'\n }\n />\n }\n />\n <RatingCard\n title=\"Duplications\"\n link={value.getComponentMeasuresUrl('DUPLICATED_LINES_DENSITY')}\n leftSlot={<Rating rating={duplicationRating} hideValue />}\n rightSlot={\n <Value value={`${value.metrics.duplicated_lines_density}%`} />\n }\n />\n </Grid>\n <Grid item className={classes.lastAnalyzed}>\n Last analyzed on{' '}\n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EAAA,cAAA;AAAA,UACN,IAAA,EAAM,KAAM,CAAA,uBAAA,CAAwB,0BAA0B,CAAA;AAAA,UAC9D,0BAAW,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAO,MAAQ,EAAA,iBAAA,EAAmB,WAAS,IAAC,EAAA,CAAA;AAAA,UACvD,SAAA,sCACG,KAAM,EAAA,EAAA,KAAA,EAAO,GAAG,KAAM,CAAA,OAAA,CAAQ,wBAAwB,CAAK,CAAA,CAAA,EAAA,CAAA;AAAA,SAAA;AAAA,OAGlE,CAAA;AAAA,sBACC,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,IAAI,EAAA,IAAA,EAAC,SAAW,EAAA,OAAA,CAAQ,YAAc,EAAA,EAAA,kBAAA,EACzB,GAChB,EAAA,QAAA,CAAS,OAAQ,CAAA,KAAA,CAAM,YAAY,CAAE,CAAA,cAAA;AAAA,QACpC,QAAS,CAAA,YAAA;AAAA,OAEb,CAAA;AAAA,KAEJ,CAAA;AAAA,GAEJ,CAAA;AAEJ;;;;"}
@@ -0,0 +1,19 @@
1
+ import { makeStyles } from '@material-ui/core/styles';
2
+ import Typography from '@material-ui/core/Typography';
3
+ import React from 'react';
4
+
5
+ const useStyles = makeStyles((theme) => {
6
+ return {
7
+ value: {
8
+ fontSize: "1.5rem",
9
+ fontWeight: theme.typography.fontWeightMedium
10
+ }
11
+ };
12
+ });
13
+ const Value = (props) => {
14
+ const classes = useStyles();
15
+ return /* @__PURE__ */ React.createElement(Typography, { component: "span", className: classes.value }, props.value);
16
+ };
17
+
18
+ export { Value };
19
+ //# sourceMappingURL=Value.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Value.esm.js","sources":["../../../src/components/SonarQubeCard/Value.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { makeStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport React from 'react';\n\nconst useStyles = makeStyles(theme => {\n return {\n value: {\n fontSize: '1.5rem',\n fontWeight: theme.typography.fontWeightMedium,\n },\n };\n});\n\nexport const Value = (props: { value?: string }) => {\n const classes = useStyles();\n return (\n <Typography component=\"span\" className={classes.value}>\n {props.value}\n </Typography>\n );\n};\n"],"names":[],"mappings":";;;;AAoBA,MAAM,SAAA,GAAY,WAAW,CAAS,KAAA,KAAA;AACpC,EAAO,OAAA;AAAA,IACL,KAAO,EAAA;AAAA,MACL,QAAU,EAAA,QAAA;AAAA,MACV,UAAA,EAAY,MAAM,UAAW,CAAA,gBAAA;AAAA,KAC/B;AAAA,GACF,CAAA;AACF,CAAC,CAAA,CAAA;AAEY,MAAA,KAAA,GAAQ,CAAC,KAA8B,KAAA;AAClD,EAAA,MAAM,UAAU,SAAU,EAAA,CAAA;AAC1B,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,SAAU,EAAA,MAAA,EAAO,WAAW,OAAQ,CAAA,KAAA,EAAA,EAC7C,MAAM,KACT,CAAA,CAAA;AAEJ;;;;"}
@@ -0,0 +1,2 @@
1
+ export { SonarQubeCard } from './SonarQubeCard.esm.js';
2
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import { Content, ContentHeader, SupportButton } from '@backstage/core-components';
2
+ import { useEntity, MissingAnnotationEmptyState } from '@backstage/plugin-catalog-react';
3
+ import React from 'react';
4
+ import { SonarQubeCard } from '../SonarQubeCard/SonarQubeCard.esm.js';
5
+ import { isSonarQubeAvailable, SONARQUBE_PROJECT_KEY_ANNOTATION } from '@backstage-community/plugin-sonarqube-react';
6
+
7
+ const SonarQubeContentPage = (props) => {
8
+ const { entity } = useEntity();
9
+ const { title, supportTitle, missingAnnotationReadMoreUrl } = props;
10
+ return isSonarQubeAvailable(entity) ? /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(ContentHeader, { title: title ?? "SonarQube Dashboard" }, supportTitle && /* @__PURE__ */ React.createElement(SupportButton, null, supportTitle)), /* @__PURE__ */ React.createElement(
11
+ SonarQubeCard,
12
+ {
13
+ missingAnnotationReadMoreUrl
14
+ }
15
+ )) : /* @__PURE__ */ React.createElement(
16
+ MissingAnnotationEmptyState,
17
+ {
18
+ annotation: SONARQUBE_PROJECT_KEY_ANNOTATION,
19
+ readMoreUrl: missingAnnotationReadMoreUrl
20
+ }
21
+ );
22
+ };
23
+
24
+ export { SonarQubeContentPage };
25
+ //# sourceMappingURL=SonarQubeContentPage.esm.js.map