UNPKG

@hawtio/react

Version:

A Hawtio reimplementation based on TypeScript + React.

61 lines (46 loc) 2.66 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _chunkTM6OCU7Kjs = require('./chunk-TM6OCU7K.js'); require('./chunk-ZYPGXT7Q.js'); // src/plugins/console-status/ConsoleStatus.tsx var _react = require('react'); var _reactcore = require('@patternfly/react-core'); var _jsxruntime = require('react/jsx-runtime'); var ConsoleStatus = () => { const timerRef = _react.useRef.call(void 0, null); const [errors, setErrors] = _react.useState.call(void 0, []); const [loading, setLoading] = _react.useState.call(void 0, true); _react.useEffect.call(void 0, () => { const waitLoading = async () => { const hasErrors = await _chunkTM6OCU7Kjs.workspace.hasErrors(); if (hasErrors) { const errors2 = [...await _chunkTM6OCU7Kjs.workspace.getErrors()]; errors2.reverse(); setErrors(errors2); } setLoading(false); }; timerRef.current = setTimeout(waitLoading, 1e3); return () => { if (timerRef.current) clearTimeout(timerRef.current); }; }, []); if (loading) { return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.PageSection, { variant: _reactcore.PageSectionVariants.light, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.Panel, { children: [ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.PanelHeader, { children: "Waiting workspace to load ..." }), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.PanelMain, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.PanelMainBody, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkTM6OCU7Kjs.HawtioLoadingCard, {}) }) }) ] }) }); } const hasCause = (error) => { if (!error || !error.cause) return false; return error.cause instanceof Error; }; return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.PageSection, { variant: _reactcore.PageSectionVariants.light, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Card, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.CardBody, { children: [ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Alert, { variant: "warning", title: "Application returned no mbeans" }), errors.map((error, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Alert, { variant: "danger", title: error.message, className: "console-alert", children: hasCause(error) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { children: [ "Cause: ", error.cause.message ] }) }, index)) ] }) }) }); }; exports.ConsoleStatus = ConsoleStatus; //# sourceMappingURL=ui-AHTQTGFA.js.map