UNPKG

@openshift-assisted/ui-lib

Version:

React component library for the Assisted Installer UI

63 lines 6.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const react_core_1 = require("@patternfly/react-core"); const React = tslib_1.__importStar(require("react")); const wizardTransition_1 = require("./wizardTransition"); const common_1 = require("../../../common"); const helpers_1 = require("../helpers"); const helpers_2 = require("./helpers"); const constants_1 = require("./constants"); const wizardTransition_2 = require("./wizardTransition"); const use_translation_wrapper_1 = require("../../../common/hooks/use-translation-wrapper"); const ClusterDeploymentWizardContext_1 = require("./ClusterDeploymentWizardContext"); const ValidationSection_1 = require("./components/ValidationSection"); const ClusterDeploymentReviewStep = ({ agentClusterInstall, agents, onFinish, clusterDeployment, clusterImages, infraEnv, }) => { var _a, _b, _c, _d, _e, _f, _g, _h; const { addAlert, clearAlerts } = (0, common_1.useAlerts)(); const { activeStep, goToPrevStep, goToStepByName, close } = (0, react_core_1.useWizardContext)(); const { syncError } = React.useContext(ClusterDeploymentWizardContext_1.ClusterDeploymentWizardContext); const [isSubmitting, setSubmitting] = React.useState(false); const cdName = (_a = clusterDeployment.metadata) === null || _a === void 0 ? void 0 : _a.name; const cdNamespace = (_b = clusterDeployment.metadata) === null || _b === void 0 ? void 0 : _b.namespace; const cpuArchitecture = (0, helpers_1.getClusterDeploymentCpuArchitecture)(clusterDeployment, infraEnv); const clusterAgents = React.useMemo(() => agents.filter((a) => (0, helpers_2.isAgentOfCluster)(a, cdName, cdNamespace)), [agents, cdName, cdNamespace]); const canContinue = (0, wizardTransition_1.canNextFromReviewStep)(agentClusterInstall, clusterAgents); const { t } = (0, use_translation_wrapper_1.useTranslation)(); const onNext = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { clearAlerts(); setSubmitting(true); try { yield onFinish(); } catch (err) { const error = err; addAlert({ title: error.message || t('ai:An error occured while starting installation.') }); } finally { setSubmitting(false); } }); const footer = (React.createElement(react_core_1.WizardFooter, { activeStep: activeStep, onNext: onNext, isNextDisabled: isSubmitting || !canContinue || !!syncError, nextButtonText: t('ai:Install cluster'), nextButtonProps: { isLoading: isSubmitting }, onBack: goToPrevStep, onClose: close })); (0, react_core_1.useWizardFooter)(footer); const openShiftVersion = (0, helpers_1.getSelectedVersion)(clusterImages, agentClusterInstall); const cluster = React.useMemo(() => (0, helpers_1.getAICluster)({ clusterDeployment, agentClusterInstall, agents: clusterAgents }), [clusterDeployment, agentClusterInstall, clusterAgents]); return (React.createElement(react_core_1.Grid, { hasGutter: true }, React.createElement(react_core_1.GridItem, null, React.createElement(common_1.ClusterWizardStepHeader, null, "Review and create")), React.createElement(react_core_1.GridItem, null, React.createElement(common_1.DetailList, null, React.createElement(common_1.DetailItem, { title: t('ai:Cluster address'), value: `${((_c = clusterDeployment.metadata) === null || _c === void 0 ? void 0 : _c.name) || ''}.${((_d = clusterDeployment.spec) === null || _d === void 0 ? void 0 : _d.baseDomain) || ''}`, testId: "cluster-address" }), React.createElement(common_1.DetailItem, { title: t('ai:OpenShift version'), value: openShiftVersion, testId: "openshift-version" }), React.createElement(common_1.DetailItem, { title: t('ai:CPU architecture'), value: cpuArchitecture, testId: "cpu-architecture" }), React.createElement(common_1.DetailItem, { title: t('ai:API IP'), value: ((_e = agentClusterInstall === null || agentClusterInstall === void 0 ? void 0 : agentClusterInstall.status) === null || _e === void 0 ? void 0 : _e.apiVIP) || ((_f = agentClusterInstall === null || agentClusterInstall === void 0 ? void 0 : agentClusterInstall.spec) === null || _f === void 0 ? void 0 : _f.apiVIP), testId: "api-vip" }), React.createElement(common_1.DetailItem, { title: t('ai:Ingress IP'), value: ((_g = agentClusterInstall === null || agentClusterInstall === void 0 ? void 0 : agentClusterInstall.status) === null || _g === void 0 ? void 0 : _g.ingressVIP) || ((_h = agentClusterInstall === null || agentClusterInstall === void 0 ? void 0 : agentClusterInstall.spec) === null || _h === void 0 ? void 0 : _h.ingressVIP), testId: "ingress-vip" }), React.createElement(common_1.DetailItem, { title: t('ai:Cluster summary'), testId: "cluster-summary", value: React.createElement(common_1.ReviewHostsInventory, { hosts: cluster.hosts }) }), React.createElement(common_1.DetailItem, { title: t('ai:Cluster validations'), value: React.createElement(common_1.ClusterValidations, { validationsInfo: cluster.validationsInfo, setCurrentStepId: goToStepByName, wizardStepNames: (0, constants_1.wizardStepNames)(t), wizardStepsValidationsMap: wizardTransition_2.wizardStepsValidationsMap }), testId: "cluster-validations" }), React.createElement(common_1.DetailItem, { title: t('ai:Host validations'), value: React.createElement(common_1.HostsValidations, { hosts: cluster.hosts, setCurrentStepId: goToStepByName, wizardStepNames: (0, constants_1.wizardStepNames)(t), allClusterWizardSoftValidationIds: wizardTransition_2.allClusterWizardSoftValidationIds, wizardStepsValidationsMap: wizardTransition_2.wizardStepsValidationsMap }), testId: "host-validations" }))), syncError && (React.createElement(react_core_1.GridItem, null, React.createElement(ValidationSection_1.ValidationSection, { currentStepId: 'review', hosts: [] }, React.createElement(react_core_1.Alert, { variant: react_core_1.AlertVariant.danger, title: t('ai:An error occured'), isInline: true }, syncError)))))); }; exports.default = ClusterDeploymentReviewStep; //# sourceMappingURL=ClusterDeploymentReviewStep.js.map