"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const react_core_1 = require("@patternfly/react-core");
const constants_1 = require("../../../common/config/constants");
const utils_1 = require("../../../common/components/clusterConfiguration/utils");
const use_translation_wrapper_1 = require("../../../common/hooks/use-translation-wrapper");
function getCardTitle(clusterStatus, t) {
    switch (clusterStatus) {
        case 'pending-for-input':
        case 'insufficient':
            return t('ai:The cluster is not ready for installation.');
        default:
            return t('ai:Cluster configured and ready for installation.');
    }
}
function getAlertVariant(clusterStatus) {
    switch (clusterStatus) {
        case 'pending-for-input':
        case 'insufficient':
            return react_core_1.AlertVariant.danger;
        default:
            return react_core_1.AlertVariant.success;
    }
}
function getContinueClusterConfigurationLinkLabel(clusterStatus, t) {
    switch (clusterStatus) {
        case 'pending-for-input':
        case 'insufficient':
            return t('ai:Continue cluster configuration');
        default:
            return t('ai:Go to cluster configuration to start the installation');
    }
}
const ClusterDeploymentValidationsOverview = ({ validationsInfo, clusterStatus, onContinueClusterConfiguration, }) => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    const [status] = clusterStatus;
    const title = getCardTitle(status, t);
    const filteredValidationsInfo = (0, utils_1.filterValidationsInfoByStatus)(validationsInfo);
    return (react_1.default.createElement(react_core_1.Alert, { isExpandable: ['pending-for-input', 'insufficient'].includes(status), isInline: true, variant: getAlertVariant(status), title: title, actionLinks: react_1.default.createElement(react_1.default.Fragment, null,
            react_1.default.createElement(react_core_1.AlertActionLink, { onClick: onContinueClusterConfiguration }, getContinueClusterConfigurationLinkLabel(status, t))) }, !!Object.entries(filteredValidationsInfo).length && (react_1.default.createElement(react_core_1.DescriptionList, null, Object.entries(filteredValidationsInfo).map(([group, validations]) => {
        const label = (0, constants_1.clusterValidationGroupLabels)(t)[group];
        return (react_1.default.createElement(react_core_1.DescriptionListGroup, { key: group },
            react_1.default.createElement(react_core_1.DescriptionListTerm, null, label),
            react_1.default.createElement(react_core_1.DescriptionListDescription, null, validations && (react_1.default.createElement(react_core_1.List, null, validations.map((validation) => (react_1.default.createElement(react_core_1.ListItem, { key: validation.id }, validation.message))))))));
    })))));
};
exports.default = ClusterDeploymentValidationsOverview;
//# sourceMappingURL=ClusterDeploymentValidationsOverview.js.map