@veecode-platform/plugin-kong-service-manager
Version:
68 lines (65 loc) • 4.09 kB
JavaScript
import React from 'react';
import '../../../../../context/KongServiceManagerContext.esm.js';
import { useKongServiceManagerContext } from '../../../../../context/KongServiceManagerProvider.esm.js';
import { useRouteListTableStyles, StyledTableRow, StyledTableCell } from './styles.esm.js';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import { IconButton } from '@material-ui/core';
import '@backstage/core-components';
import '@backstage/plugin-catalog-react';
import '@material-ui/lab';
import '@material-ui/core/InputBase';
import '@material-ui/icons/Search';
import '../../../../shared/SearchBar/styles.esm.js';
import '../../../../shared/BoxComponent/styles.esm.js';
import 'react-router-dom';
import { ExpandIcon } from '../../../../shared/icons/Icons.esm.js';
import '../../../../shared/SelectComponent/Select.esm.js';
import '../../../../shared/HtmlTooltip/HtmlTooltip.esm.js';
import '../../../../shared/ButtonComponent/styles.esm.js';
import '../../../../shared/LoadingComponent/styles.esm.js';
import '../../../../shared/MissingAnnotation/styles.esm.js';
import '../../../../shared/Fields/Fields.esm.js';
import '../../../../shared/SkeletonComponent/styles.esm.js';
import { MethodLabel } from '../../../../shared/MethodLabel/MethodLabel.esm.js';
import { addRouteDetails } from '../state/routeDetailsState/actions.esm.js';
import { transformPath } from '../../../../../utils/helpers/transformPath.esm.js';
const createData = (id, method, name, path) => {
return { id, method, name, path };
};
const DefaultTable = (props) => {
const { root } = useRouteListTableStyles();
const { children } = props;
return /* @__PURE__ */ React.createElement(TableContainer, { className: root }, /* @__PURE__ */ React.createElement(Table, { sx: { minWidth: 700 }, "aria-label": "plugins table" }, /* @__PURE__ */ React.createElement(TableHead, null, /* @__PURE__ */ React.createElement(TableRow, null, /* @__PURE__ */ React.createElement(StyledTableCell, null, "Id"), /* @__PURE__ */ React.createElement(StyledTableCell, { align: "center" }, "Method"), /* @__PURE__ */ React.createElement(StyledTableCell, { align: "center" }, "Path"), /* @__PURE__ */ React.createElement(StyledTableCell, { align: "center" }, "Action"))), /* @__PURE__ */ React.createElement(TableBody, null, children)));
};
const RouteListTable = (props) => {
const { routes, loading, setRouteDetails } = props;
const { column } = useRouteListTableStyles();
const { setRouteId } = useKongServiceManagerContext();
const rows = routes && routes.length > 0 ? routes.map(
(route) => createData(
route.id,
route.methods?.[0] ?? "GET",
route.name,
route.paths?.[0] ?? "/"
)
) : [];
const handleSetRoute = (routeParams) => {
setRouteId(routeParams.id);
setRouteDetails(
addRouteDetails({
id: routeParams.id,
method: routeParams.method,
name: routeParams.name,
path: routeParams.path
})
);
};
return /* @__PURE__ */ React.createElement(DefaultTable, null, rows.map((row) => /* @__PURE__ */ React.createElement(StyledTableRow, { key: row.id }, /* @__PURE__ */ React.createElement(StyledTableCell, { component: "th", scope: "row" }, /* @__PURE__ */ React.createElement("div", { className: column }, row.id)), /* @__PURE__ */ React.createElement(StyledTableCell, { align: "center" }, /* @__PURE__ */ React.createElement(MethodLabel, { variant: row.method })), /* @__PURE__ */ React.createElement(StyledTableCell, { align: "center" }, transformPath(row.path)), /* @__PURE__ */ React.createElement(StyledTableCell, { align: "center" }, /* @__PURE__ */ React.createElement(IconButton, { onClick: () => handleSetRoute(row) }, /* @__PURE__ */ React.createElement(ExpandIcon, null))))));
};
var RouteListTable$1 = React.memo(RouteListTable);
export { RouteListTable$1 as default };
//# sourceMappingURL=RouteListTable.esm.js.map