UNPKG

@openshift-assisted/ui-lib

Version:

React component library for the Assisted Installer UI

52 lines 4.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const react_core_1 = require("@patternfly/react-core"); const common_1 = require("../../../common"); const use_translation_wrapper_1 = require("../../../common/hooks/use-translation-wrapper"); const EnvironmentErrors_1 = require("../InfraEnv/EnvironmentErrors"); const DownloadIpxeScript_1 = tslib_1.__importDefault(require("../../../common/components/clusterConfiguration/DownloadIpxeScript")); const AddHostModal = ({ isOpen, onClose, infraEnv, agentClusterInstall, onSaveISOParams, docVersion, isIPXE, }) => { var _a, _b, _c, _d, _e, _f; const hasDHCP = ((_b = (_a = infraEnv.metadata) === null || _a === void 0 ? void 0 : _a.labels) === null || _b === void 0 ? void 0 : _b.networkType) !== 'static'; const sshPublicKey = ((_c = infraEnv.spec) === null || _c === void 0 ? void 0 : _c.sshAuthorizedKey) || ((_d = agentClusterInstall === null || agentClusterInstall === void 0 ? void 0 : agentClusterInstall.spec) === null || _d === void 0 ? void 0 : _d.sshPublicKey); const { httpProxy, httpsProxy, noProxy } = ((_e = infraEnv.spec) === null || _e === void 0 ? void 0 : _e.proxy) || {}; const imageType = ((_f = infraEnv.spec) === null || _f === void 0 ? void 0 : _f.imageType) || 'minimal-iso'; const [dialogType, setDialogType] = React.useState('config'); const { t } = (0, use_translation_wrapper_1.useTranslation)(); const handleIsoConfigSubmit = (values, formikActions) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { try { yield onSaveISOParams(values); setDialogType('download'); } catch (error) { formikActions.setStatus({ error: { title: t('ai:Failed to download the discovery Image'), message: error, // TODO(mlibra): parse it better!! }, }); } }); return (React.createElement(react_core_1.Modal, { "aria-label": t('ai:Add host dialog'), title: t('ai:Add host'), isOpen: isOpen, onClose: onClose, variant: react_core_1.ModalVariant.small, hasNoBodyWrapper: true, id: "add-host-modal" }, React.createElement(EnvironmentErrors_1.EnvironmentErrors, { infraEnv: infraEnv, docVersion: docVersion, inModal: true }, dialogType === 'config' && (React.createElement(common_1.DiscoveryImageConfigForm, { onCancel: onClose, handleSubmit: handleIsoConfigSubmit, hideDiscoveryImageType: isIPXE, imageType: imageType, sshPublicKey: sshPublicKey, httpProxy: httpProxy, httpsProxy: httpsProxy, noProxy: noProxy, hasDHCP: hasDHCP, isIPXE: isIPXE, allowEmpty: true, docVersion: docVersion })), dialogType === 'download' && (React.createElement(React.Fragment, null, isIPXE ? (React.createElement(GeneratingIPXEDownload, { onClose: onClose, infraEnv: infraEnv, onReset: agentClusterInstall ? () => setDialogType('config') : undefined })) : (React.createElement(GeneratingIsoDownload, { onClose: onClose, infraEnv: infraEnv, onReset: agentClusterInstall ? () => setDialogType('config') : undefined, hasDHCP: hasDHCP, docVersion: docVersion }))))))); }; const GeneratingIsoDownload = ({ infraEnv, onClose, onReset, hasDHCP, docVersion, }) => { var _a; const { t } = (0, use_translation_wrapper_1.useTranslation)(); return ((_a = infraEnv.status) === null || _a === void 0 ? void 0 : _a.isoDownloadURL) ? (React.createElement(common_1.DownloadIso, { onClose: onClose, downloadUrl: infraEnv.status.isoDownloadURL, onReset: onReset, hasDHCP: hasDHCP, docVersion: docVersion })) : (React.createElement(react_core_1.EmptyState, null, React.createElement(react_core_1.EmptyStateHeader, { icon: React.createElement(react_core_1.EmptyStateIcon, { icon: react_core_1.Spinner }) }), React.createElement(react_core_1.EmptyStateBody, null, t('ai:Generating discovery ISO')))); }; const GeneratingIPXEDownload = ({ infraEnv, onClose, onReset, }) => { var _a, _b; const { t } = (0, use_translation_wrapper_1.useTranslation)(); return ((_b = (_a = infraEnv.status) === null || _a === void 0 ? void 0 : _a.bootArtifacts) === null || _b === void 0 ? void 0 : _b.ipxeScript) ? (React.createElement(DownloadIpxeScript_1.default, { onClose: onClose, downloadUrl: infraEnv.status.bootArtifacts.ipxeScript, onReset: onReset })) : (React.createElement(react_core_1.EmptyState, null, React.createElement(react_core_1.EmptyStateHeader, { icon: React.createElement(react_core_1.EmptyStateIcon, { icon: react_core_1.Spinner }) }), React.createElement(react_core_1.EmptyStateBody, null, t('ai:Generating iPXE script')))); }; exports.default = AddHostModal; //# sourceMappingURL=AddHostModal.js.map