UNPKG

@openshift-assisted/ui-lib

Version:

React component library for the Assisted Installer UI

62 lines 4.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CimConfigProgressAlert = exports.resetCimConfigProgressAlertSuccessStatus = void 0; const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const react_router_dom_v5_compat_1 = require("react-router-dom-v5-compat"); const react_core_1 = require("@patternfly/react-core"); const external_link_alt_icon_1 = require("@patternfly/react-icons/dist/js/icons/external-link-alt-icon"); const use_translation_wrapper_1 = require("../../../../common/hooks/use-translation-wrapper"); const utils_1 = require("../../../utils"); const utils_2 = require("./utils"); const LOCAL_STORAGE_ID_SUCCESS = 'cim-config-progress-alert'; const resetCimConfigProgressAlertSuccessStatus = () => { window.localStorage.setItem(LOCAL_STORAGE_ID_SUCCESS, ''); }; exports.resetCimConfigProgressAlertSuccessStatus = resetCimConfigProgressAlertSuccessStatus; const CimConfigProgressAlert = ({ agentServiceConfig, assistedServiceDeploymentUrl, }) => { var _a, _b; const { t } = (0, use_translation_wrapper_1.useTranslation)(); const navigate = (0, react_router_dom_v5_compat_1.useNavigate)(); const [hideSuccess, setHideSuccess] = React.useState(true); React.useEffect(() => { setHideSuccess(window.localStorage.getItem(LOCAL_STORAGE_ID_SUCCESS) === 'closed'); }, // eslint-disable-next-line react-hooks/exhaustive-deps undefined /* With every re-render */); if (!agentServiceConfig) { // missing return null; } // success if ((0, utils_2.isCIMConfigured)({ agentServiceConfig })) { if (hideSuccess) { return null; } const onCloseSuccess = () => { window.localStorage.setItem(LOCAL_STORAGE_ID_SUCCESS, 'closed'); setHideSuccess(true); }; return (React.createElement(react_core_1.Alert, { variant: react_core_1.AlertVariant.success, isInline: true, title: t('ai:Host inventory configured successfully.'), actionClose: React.createElement(react_core_1.AlertActionCloseButton, { onClose: onCloseSuccess }) })); } const assistedServiceDeploymentLink = (React.createElement(react_core_1.Button, { variant: react_core_1.ButtonVariant.link, isInline: true, key: "assisted-service-deployment", onClick: () => navigate(assistedServiceDeploymentUrl) }, t('ai:Troubleshoot in the assisted service deployment'), " ", React.createElement(external_link_alt_icon_1.ExternalLinkAltIcon, null))); // progressing if ((0, utils_2.isCIMConfigProgressing)({ agentServiceConfig })) { const actionLinks = [assistedServiceDeploymentLink]; return (React.createElement(react_core_1.Alert, { variant: react_core_1.AlertVariant.info, isInline: true, title: t('ai:Configuration may take a few minutes.'), actionLinks: actionLinks }, t('ai:If the configuration is taking longer than 5 minutes, you might need to troubleshoot.'))); } const deploymentsHealthyCondition = (0, utils_1.getConditionByType)(((_a = agentServiceConfig.status) === null || _a === void 0 ? void 0 : _a.conditions) || [], 'DeploymentsHealthy'); const reconcileCompletedCondition = (0, utils_1.getConditionByType)(((_b = agentServiceConfig.status) === null || _b === void 0 ? void 0 : _b.conditions) || [], 'ReconcileCompleted'); const actionLinks = [assistedServiceDeploymentLink]; return (React.createElement(react_core_1.Alert, { title: t('ai:Configuration is hanging for a long time.'), variant: react_core_1.AlertVariant.info, isInline: true, actionLinks: actionLinks }, t('ai:Last observed condition:'), ' ', (deploymentsHealthyCondition === null || deploymentsHealthyCondition === void 0 ? void 0 : deploymentsHealthyCondition.message) || (reconcileCompletedCondition === null || reconcileCompletedCondition === void 0 ? void 0 : reconcileCompletedCondition.message), React.createElement("br", null), t('ai:You can either wait or investigate. A common issue can be misconfigured storage. Once you fix the issue, you can delete AgentServiceConfig to try again.'))); }; exports.CimConfigProgressAlert = CimConfigProgressAlert; //# sourceMappingURL=CimConfigProgressAlert.js.map