@backstage-community/plugin-stackstorm
Version:
A Backstage plugin that integrates towards StackStorm
40 lines (37 loc) • 1.16 kB
JavaScript
import { jsx } from 'react/jsx-runtime';
import { Progress, ResponseErrorPanel, Table } from '@backstage/core-components';
import useAsync from 'react-use/esm/useAsync';
import { useApi } from '@backstage/core-plugin-api';
import { stackstormApiRef } from '../../api/types.esm.js';
import '@backstage/errors';
const DenseTable = ({ packs }) => {
const columns = [
{ title: "Name", field: "ref" },
{ title: "Description", field: "description" },
{ title: "Version", field: "version" }
];
return /* @__PURE__ */ jsx(
Table,
{
title: "Packs",
options: { search: true, paging: false },
columns,
data: packs
}
);
};
const PacksTable = () => {
const st2 = useApi(stackstormApiRef);
const { value, loading, error } = useAsync(async () => {
const data = await st2.getPacks();
return data;
}, []);
if (loading) {
return /* @__PURE__ */ jsx(Progress, {});
} else if (error) {
return /* @__PURE__ */ jsx(ResponseErrorPanel, { error });
}
return /* @__PURE__ */ jsx(DenseTable, { packs: value || [] });
};
export { DenseTable, PacksTable };
//# sourceMappingURL=PacksTable.esm.js.map