UNPKG

@openshift-assisted/ui-lib

Version:

React component library for the Assisted Installer UI

73 lines 6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.defaultNetworkSettings = void 0; 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 NetworkConfiguration_1 = tslib_1.__importDefault(require("./NetworkConfiguration")); const ClusterDeploymentHostsNetworkTable_1 = tslib_1.__importDefault(require("./ClusterDeploymentHostsNetworkTable")); const helpers_1 = require("../helpers"); const formik_1 = require("formik"); const helpers_2 = require("./helpers"); const use_translation_wrapper_1 = require("../../../common/hooks/use-translation-wrapper"); const react_i18next_1 = require("react-i18next"); // TODO(mlibra): So far a constant. Should be queried from somewhere. exports.defaultNetworkSettings = common_1.CLUSTER_DEFAULT_NETWORK_SETTINGS_IPV4; const ClusterDeploymentNetworkingForm = ({ clusterDeployment, agentClusterInstall, agents, onValuesChanged, infraEnvWithProxy, sameProxies, infraEnvsError, infraEnvsLoading, isPreviewOpen, onEditHost, onEditRole, onSetInstallationDiskId, isNutanix, }) => { const { values, touched, setFieldValue, setFieldTouched } = (0, formik_1.useFormikContext)(); React.useEffect(() => onValuesChanged === null || onValuesChanged === void 0 ? void 0 : onValuesChanged(values), [onValuesChanged, values]); const [editProxy, setEditProxy] = React.useState(false); const cluster = (0, helpers_1.getAICluster)({ clusterDeployment, agentClusterInstall, agents, }); const hostSubnets = React.useMemo(() => (0, common_1.getHostSubnets)(cluster), [cluster]); const { t } = (0, use_translation_wrapper_1.useTranslation)(); React.useEffect(() => { var _a, _b, _c, _d, _e, _f; if (!!infraEnvWithProxy && !touched.enableProxy) { setFieldValue('enableProxy', true, false); if (sameProxies) { setFieldValue('httpProxy', (_b = (_a = infraEnvWithProxy.spec) === null || _a === void 0 ? void 0 : _a.proxy) === null || _b === void 0 ? void 0 : _b.httpProxy, false); setFieldValue('httpsProxy', (_d = (_c = infraEnvWithProxy.spec) === null || _c === void 0 ? void 0 : _c.proxy) === null || _d === void 0 ? void 0 : _d.httpsProxy, false); setFieldValue('noProxy', (_f = (_e = infraEnvWithProxy.spec) === null || _e === void 0 ? void 0 : _e.proxy) === null || _f === void 0 ? void 0 : _f.noProxy, false); } } }, [infraEnvWithProxy, sameProxies, setFieldValue, touched.enableProxy, setFieldTouched]); let proxyConfig = React.createElement(common_1.ProxyFields, null); if (infraEnvWithProxy) { if (!sameProxies) { proxyConfig = (React.createElement(React.Fragment, null, React.createElement(react_core_1.TextContent, null, React.createElement(react_core_1.Text, { component: "h2" }, t('ai:Cluster-wide proxy')), React.createElement(react_core_1.Text, { component: react_core_1.TextVariants.p }, React.createElement(react_i18next_1.Trans, { t: t, components: { bold: React.createElement("strong", null) }, i18nKey: "ai:The hosts you selected are using different proxy settings. Configure a proxy that will be applied for these hosts. <bold>Configure at least one of the proxy settings below.</bold>" }))), React.createElement(common_1.ProxyInputFields, null))); } else { proxyConfig = (React.createElement(React.Fragment, null, React.createElement(react_core_1.Checkbox, { id: "edit-proxy", label: t('ai:Edit cluster-wide proxy settings'), onChange: (_event, value) => setEditProxy(value), isChecked: editProxy, body: editProxy && React.createElement(common_1.ProxyInputFields, null) }))); } } const gridSpans = (0, helpers_2.getGridSpans)(isPreviewOpen); return (React.createElement(react_core_1.Form, null, React.createElement(react_core_1.Stack, { hasGutter: true }, React.createElement(react_core_1.StackItem, null, React.createElement(react_core_1.Grid, { hasGutter: true }, React.createElement(react_core_1.GridItem, Object.assign({}, gridSpans), React.createElement(NetworkConfiguration_1.default, { cluster: cluster, hostSubnets: hostSubnets, isVipDhcpAllocationDisabled: true, defaultNetworkSettings: exports.defaultNetworkSettings, hideManagedNetworking: (0, helpers_1.getIsSNOCluster)(agentClusterInstall) || isNutanix })))), React.createElement(react_core_1.StackItem, null, infraEnvsError ? (React.createElement(react_core_1.Alert, { title: infraEnvsError, variant: "danger", isInline: true })) : infraEnvsLoading ? (React.createElement(react_core_1.Split, { hasGutter: true }, React.createElement(react_core_1.SplitItem, null, React.createElement(react_core_1.Spinner, { size: "md" })), React.createElement(react_core_1.SplitItem, null, t('ai:Loading proxy configuration')))) : (proxyConfig)), React.createElement(react_core_1.StackItem, null, React.createElement(common_1.SecurityFields, { clusterSshKey: cluster.sshPublicKey })), React.createElement(react_core_1.StackItem, null, React.createElement(react_core_1.TextContent, null, React.createElement(react_core_1.Text, { component: "h2" }, t('ai:Host inventory'))), React.createElement(ClusterDeploymentHostsNetworkTable_1.default, { clusterDeployment: clusterDeployment, agentClusterInstall: agentClusterInstall, agents: agents, onEditHost: onEditHost, onEditRole: onEditRole, onSetInstallationDiskId: onSetInstallationDiskId }))))); }; exports.default = ClusterDeploymentNetworkingForm; //# sourceMappingURL=ClusterDeploymentNetworkingForm.js.map