UNPKG

@backstage/plugin-techdocs

Version:

The Backstage plugin that renders technical documentation for your components

112 lines (109 loc) 3.71 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 { useTranslationRef } from '@backstage/core-plugin-api/alpha'; import { TechDocsBuildLogs } from './TechDocsBuildLogs.esm.js'; import { TechDocsNotFound } from './TechDocsNotFound.esm.js'; import { useTechDocsReader } from './TechDocsReaderProvider.esm.js'; import { techdocsTranslationRef } from '../../translation.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 { t } = useTranslationRef(techdocsTranslationRef); 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: t("stateIndicator.initialBuild.message") } ); } 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: t("stateIndicator.contentStaleRefreshing.message") } ); } if (state === "CONTENT_STALE_READY") { StateAlert = /* @__PURE__ */ jsx( Alert, { variant: "outlined", severity: "success", action: /* @__PURE__ */ jsx(Button, { color: "inherit", onClick: () => contentReload(), children: t("stateIndicator.contentStaleReady.refreshButton") }), classes: { root: classes.root }, children: t("stateIndicator.contentStaleReady.message") } ); } 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: [ t("stateIndicator.contentStaleError.message"), " ", 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: [ t("stateIndicator.contentStaleError.message"), " ", syncErrorMessage ] } ), /* @__PURE__ */ jsx(TechDocsNotFound, { errorMessage: contentErrorMessage }) ] }); } return StateAlert; }; export { TechDocsStateIndicator }; //# sourceMappingURL=TechDocsStateIndicator.esm.js.map