"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hardwareStatusColumn = void 0;
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const common_1 = require("../../../common");
const wizardTransition_1 = require("../clusterWizard/wizardTransition");
const AdditionaNTPSourceDialogToggle_1 = require("./AdditionaNTPSourceDialogToggle");
const utils_1 = require("../../../common/utils");
const use_translation_wrapper_1 = require("../../../common/hooks/use-translation-wrapper");
const DELETE_MODAL_STATUS_Z_INDEX = 500;
const HardwareStatus = (props) => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    const hardwareStatus = (0, common_1.getWizardStepHostStatus)('host-discovery', wizardTransition_1.wizardStepsValidationsMap, props.host);
    const status = (0, common_1.hostStatus)(t)[hardwareStatus];
    const validationsInfo = (0, common_1.getWizardStepHostValidationsInfo)(props.validationsInfo, 'host-discovery', wizardTransition_1.wizardStepsValidationsMap);
    const sublabel = (0, common_1.areOnlySoftValidationsOfWizardStepFailing)(validationsInfo, 'host-discovery', wizardTransition_1.wizardStepsValidationsMap)
        ? 'Some validations failed'
        : undefined;
    return (react_1.default.createElement(common_1.HostStatus, Object.assign({}, props, { zIndex: props.isWithinModal ? DELETE_MODAL_STATUS_Z_INDEX : undefined, status: Object.assign(Object.assign({}, status), { sublabel }), validationsInfo: validationsInfo, AdditionalNTPSourcesDialogToggleComponent: AdditionaNTPSourceDialogToggle_1.AdditionalNTPSourcesDialogToggle, openshiftVersion: props.openshiftVersion })));
};
const hardwareStatusColumn = ({ onEditHostname, isWithinModal, openshiftVersion, }) => {
    return {
        header: {
            title: 'Status',
            props: {
                id: 'col-header-hwstatus',
            },
            sort: true,
        },
        cell: (host) => {
            const validationsInfo = (0, utils_1.stringToJSON)(host.validationsInfo) || {};
            const editHostname = onEditHostname ? () => onEditHostname(host) : undefined;
            return {
                title: (react_1.default.createElement(HardwareStatus, { host: host, onEditHostname: editHostname, validationsInfo: validationsInfo, isWithinModal: isWithinModal, openshiftVersion: openshiftVersion })),
                props: { 'data-testid': 'host-hw-status' },
                sortableValue: status,
            };
        },
    };
};
exports.hardwareStatusColumn = hardwareStatusColumn;
exports.default = { HardwareStatus, hardwareStatusColumn: exports.hardwareStatusColumn };
//# sourceMappingURL=HardwareStatus.js.map