@adamlonsdale/backstage-plugin-armorcode
Version:
Welcome to the `backstage-plugin-armorcode` plugin for Backstage!
67 lines (64 loc) • 2.21 kB
JavaScript
import React from 'react';
import { Progress, EmptyState, Link, Table } from '@backstage/core-components';
import Alert from '@material-ui/lab/Alert';
import useAsync from 'react-use/lib/useAsync';
import LaunchSharp from '@material-ui/icons/LaunchSharp';
import { useApi } from '@backstage/core-plugin-api';
import { a as armorcodeApiRef } from './index-ccc0b497.esm.js';
import '@backstage/errors';
const DenseTable = ({ productList }) => {
const columns = [
{ title: "ID", field: "id" },
{ title: "Product Name", field: "name" },
{ title: "Component Version", field: "versionNumber" },
{ title: "Description", field: "description" },
{ title: "Team", field: "team" },
{ title: "Link", field: "link" }
];
const data = productList.map((item) => {
return {
id: item.id,
name: item.name,
versionNumber: item.versionNumber,
description: item.description,
team: item.team.name,
link: /* @__PURE__ */ React.createElement(Link, { to: item.id }, " ", /* @__PURE__ */ React.createElement(LaunchSharp, null), " ")
};
});
return /* @__PURE__ */ React.createElement(
Table,
{
title: "Critical Findings",
options: { search: false, paging: false },
columns,
data
}
);
};
const PageContent = () => {
const armorcodeApi = useApi(armorcodeApiRef);
const { value, loading, error } = useAsync(async () => {
const data = await armorcodeApi.getProducts();
return data;
}, []);
if (loading) {
return /* @__PURE__ */ React.createElement(Progress, null);
} else if (!value) {
return /* @__PURE__ */ React.createElement(
EmptyState,
{
missing: "info",
title: "No information to display",
description: "There are no Armorcode Products!"
}
);
} else if (error) {
return /* @__PURE__ */ React.createElement(Alert, { severity: "error" }, error.message);
}
return /* @__PURE__ */ React.createElement(DenseTable, { productList: value || [] });
};
const ArmorcodePageComponent = () => {
return /* @__PURE__ */ React.createElement(PageContent, null);
};
export { ArmorcodePageComponent };
//# sourceMappingURL=index-009f5424.esm.js.map