"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CimConfigurationFormFields = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const react_i18next_1 = require("react-i18next");
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 help_icon_1 = require("@patternfly/react-icons/dist/js/icons/help-icon");
const use_translation_wrapper_1 = require("../../../../common/hooks/use-translation-wrapper");
const common_1 = require("../../../../common");
const formik_1 = require("formik");
const persist_1 = require("./persist");
const CimConfigurationFormFields = ({ platform, docConfigUrl, docConfigAwsUrl, isEdit, isInProgressPeriod, configureLoadBalancerInitial, setConfigureLoadBalancerInitial, }) => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    const { setFieldValue, values } = (0, formik_1.useFormikContext)();
    React.useEffect(() => {
        const doItAsync = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
            if (platform === 'AWS') {
                if (!isEdit || (yield (0, persist_1.isIngressController)())) {
                    setFieldValue('configureLoadBalancer', true);
                    setConfigureLoadBalancerInitial(true);
                    return;
                }
            }
            setFieldValue('configureLoadBalancer', false);
            setConfigureLoadBalancerInitial(false);
        });
        void doItAsync();
    }, 
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [platform]);
    return (React.createElement(react_core_1.Form, null,
        React.createElement(react_core_1.Content, null,
            React.createElement(react_core_1.Content, { component: react_core_1.ContentVariants.h4, className: "pf-v5-u-font-weight-bold" },
                t('ai:Storage sizes'),
                ' ',
                React.createElement(common_1.PopoverIcon, { bodyContent: t('ai:The storage sizes will be used to store different files and data for cluster creation.'), footerContent: React.createElement("a", { href: docConfigUrl, target: "_blank", rel: "noreferrer" },
                        React.createElement(react_i18next_1.Trans, { t: t },
                            "ai:Learn more about storage sizes. ",
                            React.createElement(external_link_alt_icon_1.ExternalLinkAltIcon, null))), "aria-label": t('ai:More info for configure storage sizes'), noVerticalAlign: true },
                    React.createElement(react_core_1.Icon, null,
                        React.createElement(help_icon_1.HelpIcon, null)))),
            React.createElement(react_core_1.Content, null, t('ai:If there are many clusters, use higher values for the storage fields.'))),
        React.createElement(react_core_1.Flex, { justifyContent: { default: 'justifyContentSpaceBetween' } },
            React.createElement(react_core_1.FlexItem, null,
                React.createElement(react_core_1.FormGroup, { label: t('ai:Database storage'), labelHelp: React.createElement(common_1.PopoverIcon, { noVerticalAlign: true, bodyContent: t('ai:Specify how much storage is allocated for storing files such as database tables and database views for the clusters. Recommended is 10Gi or more. The value can not be updated later.'), "aria-label": t('ai:More info for database storage') },
                        React.createElement(react_core_1.Icon, null,
                            React.createElement(help_icon_1.HelpIcon, null))), isRequired: true },
                    React.createElement(react_core_1.InputGroup, null,
                        React.createElement(react_core_1.InputGroupItem, { isFill: true },
                            React.createElement(common_1.InputField, { type: "number", name: "dbVolSize", isRequired: true, isDisabled: isEdit, min: 0, style: { maxWidth: 'initial' } })),
                        React.createElement(react_core_1.InputGroupText, { isPlain: true }, "Gi")))),
            React.createElement(react_core_1.FlexItem, null,
                React.createElement(react_core_1.FormGroup, { label: t('ai:System storage'), labelHelp: React.createElement(common_1.PopoverIcon, { noVerticalAlign: true, bodyContent: t('ai:Specify how much storage is allocated for storing logs, manifests and "kubeconfig" files for the clusters. Recommended is 100Gi or more. The value can not be updated later.'), "aria-label": t('ai:More info for system storage') },
                        React.createElement(react_core_1.Icon, null,
                            React.createElement(help_icon_1.HelpIcon, null))), isRequired: true },
                    React.createElement(react_core_1.InputGroup, null,
                        React.createElement(react_core_1.InputGroupItem, { isFill: true },
                            React.createElement(common_1.InputField, { isRequired: true, isDisabled: isEdit, type: "number", name: "fsVolSize", min: 0, style: { maxWidth: 'initial' } })),
                        React.createElement(react_core_1.InputGroupText, { isPlain: true }, "Gi")))),
            React.createElement(react_core_1.FlexItem, null,
                React.createElement(react_core_1.FormGroup, { label: t('ai:Image storage'), labelHelp: React.createElement(common_1.PopoverIcon, { noVerticalAlign: true, bodyContent: t('ai:Specify how much storage to allocate for the images of the clusters. There must be 1G of image storage for each instance of Red Hat Enterprise Linux CoreOS that is running. Recommended is 50Gi or more. The value can not be updated later.'), "aria-label": t('ai:More info for image storage') },
                        React.createElement(react_core_1.Icon, null,
                            React.createElement(help_icon_1.HelpIcon, null))), isRequired: true },
                    React.createElement(react_core_1.InputGroup, null,
                        React.createElement(react_core_1.InputGroupItem, { isFill: true },
                            React.createElement(common_1.InputField, { isRequired: true, isDisabled: isEdit /* Not supported by backend */, type: "number", name: "imgVolSize", style: { maxWidth: 'initial' }, min: 0 })),
                        React.createElement(react_core_1.InputGroupText, { isPlain: true }, "Gi"))))),
        React.createElement(react_core_1.Stack, null,
            React.createElement(react_core_1.StackItem, null,
                React.createElement(common_1.CheckboxField, { name: "configureLoadBalancer", label: React.createElement(React.Fragment, null,
                        t('ai:Configure load balancer on Amazon Web Services for me.'),
                        ' ',
                        React.createElement(common_1.PopoverIcon, { noVerticalAlign: true, bodyContent: t("ai:If you're running your hub cluster of Amazon Web Services and want to enable the CIM service, we recommend you to configure your load balancer if it is not already configured. Learn more about enabling CIM on AWS."), footerContent: React.createElement("a", { href: docConfigAwsUrl, target: "_blank", rel: "noreferrer" },
                                React.createElement(react_i18next_1.Trans, { t: t },
                                    "ai:Learn more about enabling CIM on AWS ",
                                    React.createElement(external_link_alt_icon_1.ExternalLinkAltIcon, null))), "aria-label": t('ai:More info for load balancer on Amazon web services') },
                            React.createElement(react_core_1.Icon, null,
                                React.createElement(help_icon_1.HelpIcon, null)))), isDisabled: isInProgressPeriod || (isEdit && configureLoadBalancerInitial) })),
            React.createElement(react_core_1.StackItem, null,
                React.createElement(common_1.CheckboxField, { name: 'addCiscoIntersightURL', label: React.createElement(React.Fragment, null,
                        t('ai:Configure custom URL for Cisco Intersight'),
                        ' ',
                        React.createElement(common_1.PopoverIcon, { noVerticalAlign: true, bodyContent: t('ai:Configure a custom URL to add hosts from Cisco Intersight on disconnected environments.') },
                            React.createElement(react_core_1.Icon, null,
                                React.createElement(help_icon_1.HelpIcon, null)))), onChange: (checked) => {
                        if (!checked) {
                            setFieldValue('ciscoIntersightURL', '', false);
                        }
                    } }),
                values.addCiscoIntersightURL && (React.createElement(common_1.InputField, { name: 'ciscoIntersightURL', label: t('ai:Cisco Intersight URL'), isRequired: true, placeholder: "https://www.intersight.com/an/workflow/workflow-definitions/execute/AddServersFromISO", helperText: t('ai:Provide the complete URL, including the protocol and parameters.') }))))));
};
exports.CimConfigurationFormFields = CimConfigurationFormFields;
//# sourceMappingURL=CimConfigurationFormFields.js.map