"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 check_circle_icon_1 = require("@patternfly/react-icons/dist/js/icons/check-circle-icon");
const exclamation_circle_icon_1 = require("@patternfly/react-icons/dist/js/icons/exclamation-circle-icon");
const in_progress_icon_1 = require("@patternfly/react-icons/dist/js/icons/in-progress-icon");
const unknown_icon_1 = require("@patternfly/react-icons/dist/js/icons/unknown-icon");
const react_table_1 = require("@patternfly/react-table");
const use_translation_wrapper_1 = require("../../../../common/hooks/use-translation-wrapper");
require("./ConditionsTable.css");
const ignoredConditions = ['Progressing'];
const reversedConditions = ['Degraded'];
const ConditionsTable = ({ conditions, isDone }) => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    return (React.createElement(react_table_1.Table, { variant: "compact" },
        React.createElement(react_table_1.Thead, null,
            React.createElement(react_table_1.Tr, null,
                React.createElement(react_table_1.Th, { width: 25 }, t('ai:Condition')),
                React.createElement(react_table_1.Th, null, t('ai:Message')))),
        React.createElement(react_table_1.Tbody, null, conditions === null || conditions === void 0 ? void 0 : conditions.filter(({ type }) => !ignoredConditions.includes(type)).map((c) => {
            let icon = React.createElement(unknown_icon_1.UnknownIcon, null);
            const { okStatus, nokStatus } = reversedConditions.includes(c.type)
                ? { okStatus: 'False', nokStatus: 'True' }
                : { okStatus: 'True', nokStatus: 'False' };
            if (c.type.endsWith('Progressing')) {
                // progressing conditions have no error status
                icon =
                    c.status === okStatus ? (React.createElement(in_progress_icon_1.InProgressIcon, null)) : (React.createElement(react_core_1.Icon, { status: "success" },
                        React.createElement(check_circle_icon_1.CheckCircleIcon, null)));
            }
            else {
                if (c.status === okStatus) {
                    icon = (React.createElement(react_core_1.Icon, { status: "success" },
                        React.createElement(check_circle_icon_1.CheckCircleIcon, null)));
                }
                else if (c.status === nokStatus) {
                    icon = isDone ? (React.createElement(react_core_1.Icon, { status: "danger", size: "sm" },
                        React.createElement(exclamation_circle_icon_1.ExclamationCircleIcon, null))) : (React.createElement(in_progress_icon_1.InProgressIcon, null));
                }
            }
            return (React.createElement(react_table_1.Tr, { key: c.type, className: "ai-conditions-table__no-border" },
                React.createElement(react_table_1.Td, null,
                    React.createElement(react_core_1.Flex, { alignItems: { default: 'alignItemsCenter' }, spaceItems: { default: 'spaceItemsXs' } },
                        React.createElement(react_core_1.FlexItem, null, icon),
                        React.createElement(react_core_1.FlexItem, null, c.type))),
                React.createElement(react_table_1.Td, { span: 8 }, c.message || '-')));
        }))));
};
exports.default = ConditionsTable;
//# sourceMappingURL=ConditionsTable.js.map