UNPKG

@backstage/plugin-techdocs

Version:

The Backstage plugin that renders technical documentation for your components

109 lines (106 loc) 3.64 kB
import { jsx, jsxs, Fragment } from 'react/jsx-runtime'; import CircularProgress from '@material-ui/core/CircularProgress'; import Button from '@material-ui/core/Button'; import { makeStyles } from '@material-ui/core/styles'; import Alert from '@material-ui/lab/Alert'; import { TechDocsBuildLogs } from './TechDocsBuildLogs.esm.js'; import { TechDocsNotFound } from './TechDocsNotFound.esm.js'; import { useTechDocsReader } from './TechDocsReaderProvider.esm.js'; const useStyles = makeStyles((theme) => ({ root: { marginBottom: theme.spacing(2) }, message: { // `word-break: break-word` is deprecated, but gives legacy support to browsers not supporting `overflow-wrap` yet // https://developer.mozilla.org/en-US/docs/Web/CSS/word-break wordBreak: "break-word", overflowWrap: "anywhere" } })); const TechDocsStateIndicator = () => { let StateAlert = null; const classes = useStyles(); const { state, contentReload, contentErrorMessage, syncErrorMessage, buildLog } = useTechDocsReader(); if (state === "INITIAL_BUILD") { StateAlert = /* @__PURE__ */ jsx( Alert, { classes: { root: classes.root }, variant: "outlined", severity: "info", icon: /* @__PURE__ */ jsx(CircularProgress, { size: "24px" }), action: /* @__PURE__ */ jsx(TechDocsBuildLogs, { buildLog }), children: "Documentation is accessed for the first time and is being prepared. The subsequent loads are much faster." } ); } if (state === "CONTENT_STALE_REFRESHING") { StateAlert = /* @__PURE__ */ jsx( Alert, { variant: "outlined", severity: "info", icon: /* @__PURE__ */ jsx(CircularProgress, { size: "24px" }), action: /* @__PURE__ */ jsx(TechDocsBuildLogs, { buildLog }), classes: { root: classes.root }, children: "A newer version of this documentation is being prepared and will be available shortly." } ); } if (state === "CONTENT_STALE_READY") { StateAlert = /* @__PURE__ */ jsx( Alert, { variant: "outlined", severity: "success", action: /* @__PURE__ */ jsx(Button, { color: "inherit", onClick: () => contentReload(), children: "Refresh" }), classes: { root: classes.root }, children: "A newer version of this documentation is now available, please refresh to view." } ); } if (state === "CONTENT_STALE_ERROR") { StateAlert = /* @__PURE__ */ jsxs( Alert, { variant: "outlined", severity: "error", action: /* @__PURE__ */ jsx(TechDocsBuildLogs, { buildLog }), classes: { root: classes.root, message: classes.message }, children: [ "Building a newer version of this documentation failed.", " ", syncErrorMessage ] } ); } if (state === "CONTENT_NOT_FOUND") { StateAlert = /* @__PURE__ */ jsxs(Fragment, { children: [ syncErrorMessage && /* @__PURE__ */ jsxs( Alert, { variant: "outlined", severity: "error", action: /* @__PURE__ */ jsx(TechDocsBuildLogs, { buildLog }), classes: { root: classes.root, message: classes.message }, children: [ "Building a newer version of this documentation failed.", " ", syncErrorMessage ] } ), /* @__PURE__ */ jsx(TechDocsNotFound, { errorMessage: contentErrorMessage }) ] }); } return StateAlert; }; export { TechDocsStateIndicator }; //# sourceMappingURL=TechDocsStateIndicator.esm.js.map