@backstage-community/plugin-sonarqube
Version:
155 lines (152 loc) • 5.31 kB
JavaScript
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
import { Link } from '@backstage/core-components';
import { EntityPeekAheadPopover, EntityRefLink } from '@backstage/plugin-catalog-react';
import IconButton from '@material-ui/core/IconButton';
import LinkIcon from '@material-ui/icons/Link';
import Typography from '@material-ui/core/Typography';
import { QualityBadge, LastAnalyzedRatingCard, NoSonarQubeCard, BugReportRatingCard, VulnerabilitiesRatingCard, CodeSmellsRatingCard, HotspotsReviewed, CoverageRatingCard, DuplicationsRatingCard } from '../SonarQubeCard/MetricInsights.esm.js';
const EntityLink = ({
entityRef,
title,
url,
kind,
namespace
}) => {
return /* @__PURE__ */ jsxs(
Typography,
{
style: {
display: "flex",
alignItems: "center",
padding: "0",
margin: "0"
},
children: [
/* @__PURE__ */ jsx(EntityPeekAheadPopover, { entityRef, children: /* @__PURE__ */ jsx(
EntityRefLink,
{
entityRef: {
kind,
namespace,
name: entityRef.split("/")[1]
}
}
) }),
/* @__PURE__ */ jsx(Link, { to: url, title, target: "_blank", children: /* @__PURE__ */ jsx(
IconButton,
{
"aria-label": "link",
color: "inherit",
style: {
display: "flex",
alignItems: "center",
padding: "0",
paddingLeft: "10px",
margin: "0"
},
children: /* @__PURE__ */ jsx(LinkIcon, {})
}
) })
]
}
);
};
const getColumns = (t) => {
return [
{
title: t("sonarQubeTable.columnsTitle.component"),
field: "resolved.name",
type: "string",
highlight: true,
align: "center",
width: "25%",
cellStyle: {
wordBreak: "inherit",
padding: "10px 20px"
},
render: ({ resolved }) => {
if (!resolved?.name) {
return null;
}
const scoreCardComponentUrl = `/catalog/default/component/${resolved?.name}/${resolved?.isSonarQubeAnnotationEnabled ? "scorecard" : ""}`;
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
EntityLink,
{
entityRef: `component:default/${resolved?.name}`,
title: t("sonarQubeTable.entityLinkTitle"),
url: scoreCardComponentUrl,
kind: "component",
namespace: "default"
}
) });
}
},
{
title: t("sonarQubeTable.columnsTitle.qualityGate"),
field: "resolved?.findings?.metrics.alert_status",
type: "string",
align: "center",
sorting: false,
width: "35%",
render: ({ resolved, id }) => {
if (resolved?.findings?.metrics) {
return /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx(QualityBadge, { value: resolved?.findings }),
/* @__PURE__ */ jsx("br", {}),
/* @__PURE__ */ jsx(LastAnalyzedRatingCard, { value: resolved?.findings })
] });
}
return /* @__PURE__ */ jsx(NoSonarQubeCard, { value: resolved, sonarQubeComponentKey: id });
}
},
{
title: t("sonarQubeTable.columnsTitle.bugs"),
field: "resolved.findings.metrics.bugs",
align: "center",
type: "numeric",
width: "5%",
render: ({ resolved }) => resolved?.findings?.metrics && /* @__PURE__ */ jsx(BugReportRatingCard, { value: resolved?.findings })
},
{
title: t("sonarQubeTable.columnsTitle.vulnerabilities"),
field: "resolved.findings.metrics.vulnerabilities",
align: "center",
width: "5%",
type: "numeric",
render: ({ resolved }) => resolved?.findings?.metrics && /* @__PURE__ */ jsx(VulnerabilitiesRatingCard, { value: resolved?.findings })
},
{
title: t("sonarQubeTable.columnsTitle.codeSmells"),
field: "resolved.findings.metrics.code_smells",
align: "center",
type: "numeric",
width: "5%",
render: ({ resolved }) => resolved?.findings?.metrics && /* @__PURE__ */ jsx(CodeSmellsRatingCard, { value: resolved?.findings })
},
{
title: t("sonarQubeTable.columnsTitle.hotspotsReviewed"),
field: "resolved.findings.metrics.security_hotspots_reviewed",
align: "center",
type: "numeric",
width: "5%",
render: ({ resolved }) => resolved?.findings?.metrics && /* @__PURE__ */ jsx(HotspotsReviewed, { value: resolved?.findings })
},
{
title: t("sonarQubeTable.columnsTitle.coverage"),
field: "resolved.findings.metrics.coverage",
align: "center",
type: "numeric",
width: "10%",
render: ({ resolved }) => resolved?.findings?.metrics && /* @__PURE__ */ jsx(CoverageRatingCard, { value: resolved?.findings })
},
{
title: t("sonarQubeTable.columnsTitle.duplications"),
field: "resolved.findings.metrics.duplicated_lines_density",
type: "numeric",
width: "10%",
render: ({ resolved }) => resolved?.findings?.metrics && /* @__PURE__ */ jsx(DuplicationsRatingCard, { value: resolved?.findings })
}
];
};
export { getColumns };
//# sourceMappingURL=Columns.esm.js.map