UNPKG

@jfvilas/plugin-kwirth-log

Version:

Frontend plugin for viewing real-time Kubernetes logs in Backstage

61 lines (58 loc) 3.37 kB
import React from 'react'; import { CodeSnippet } from '@backstage/core-components'; import { Grid, Typography, Button } from '@material-ui/core'; import KwirthComponentNotFound from '../../assets/kwirth-log-component-not-found.svg'; import { ANNOTATION_KWIRTH_LOCATION } from '@jfvilas/plugin-kwirth-common'; var ErrorType = /* @__PURE__ */ ((ErrorType2) => { ErrorType2[ErrorType2["NO_PODS"] = 0] = "NO_PODS"; ErrorType2[ErrorType2["NO_CLUSTERS"] = 1] = "NO_CLUSTERS"; return ErrorType2; })(ErrorType || {}); const KUBERNETES_YAML = `apiVersion: apps/v1 kind: Deployment metadata: name: '$entityName' description: '$entityDescription' labels: ${ANNOTATION_KWIRTH_LOCATION}: '$entityName' spec: selector: matchLabels: app: '$entityName' template: metadata: name: '$entityName'-pod labels: app: '$entityName' ${ANNOTATION_KWIRTH_LOCATION}: '$entityName' spec: containers: - name: '$entityName' image: your-OCI-image ...`; const ComponentNotFound = (props) => { var text = ""; var content = /* @__PURE__ */ React.createElement( CodeSnippet, { text: KUBERNETES_YAML.replaceAll("$entityName", props.entity.metadata.name).replaceAll("$entityDescription", props.entity.metadata.description), language: "yaml", showLineNumbers: true, highlightedNumbers: [7, 17], customStyle: { background: "inherit" } } ); var nopodsMsg = `Although this component is well tagged, and we have found some clusters configured in Backstage, we were unable to find "${props.entity.metadata.name}" running on any pod. Maybe you need to tag Kubernetes objects (deployment and pod templates).`; var noclustersMsg = `Although this component has a correct 'kubernetes-id' in the ${props.entity.metadata.name} Component YAML, we couldn't find any cluster. Maybe you need to tag Kubernetes objects (deployments and pod templates).`; switch (props.error) { case 0 /* NO_PODS */: text = nopodsMsg; break; case 1 /* NO_CLUSTERS */: text = noclustersMsg; break; } return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Grid, { container: true, direction: "row", justifyContent: "flex-start", alignItems: "flex-start", spacing: 2 }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: 6, md: 6 }, /* @__PURE__ */ React.createElement(Grid, { container: true, direction: "column" }, /* @__PURE__ */ React.createElement(Grid, { item: true, xs: true }, /* @__PURE__ */ React.createElement(Typography, { variant: "h5" }, "Component not found")), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: true }, /* @__PURE__ */ React.createElement(Typography, { variant: "body1" }, text)), /* @__PURE__ */ React.createElement(Grid, { item: true, xs: true }, content))), /* @__PURE__ */ React.createElement("img", { src: KwirthComponentNotFound, style: { left: "10%", marginTop: "10%", width: "30%", position: "relative" } })), /* @__PURE__ */ React.createElement(Button, { variant: "contained", color: "primary", target: "_blank", href: "https://backstage.io/docs/features/kubernetes/configuration#surfacing-your-kubernetes-components-as-part-of-an-entity" }, "READ MORE")); }; export { ComponentNotFound, ErrorType }; //# sourceMappingURL=ComponentNotFound.esm.js.map