@hawtio/react
Version:
A Hawtio reimplementation based on TypeScript + React.
60 lines (46 loc) • 2.61 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});
var _chunkBJ6TSPQKjs = require('./chunk-BJ6TSPQK.js');
require('./chunk-BHIEXRGK.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 _chunkBJ6TSPQKjs.workspace.hasErrors();
if (hasErrors) {
const errors2 = [...await _chunkBJ6TSPQKjs.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, { hasBodyWrapper: false, 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, _chunkBJ6TSPQKjs.HawtioLoadingCard, {}) }) })
] }) });
}
const hasCause = (error) => {
if (!error || !error.cause) return false;
return error.cause instanceof Error;
};
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.PageSection, { hasBodyWrapper: false, 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-IFAXOQO3.js.map