"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExpandComponent = ExpandComponent;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const common_1 = require("../../../common");
const AdditionaNTPSourceDialogToggle_1 = require("./AdditionaNTPSourceDialogToggle");
const usePagination_1 = require("../../../common/components/hosts/usePagination");
const use_hosts_table_1 = require("./use-hosts-table");
const HostsTable_1 = tslib_1.__importDefault(require("../../../common/components/hosts/HostsTable"));
const HostsTableEmptyState_1 = tslib_1.__importDefault(require("../hosts/HostsTableEmptyState"));
const HostRowDetail_1 = require("../../../common/components/hosts/HostRowDetail");
const UpdateDay2ApiVipDialogToggle_1 = require("./UpdateDay2ApiVipDialogToggle");
const use_translation_wrapper_1 = require("../../../common/hooks/use-translation-wrapper");
const HostsTableDetailContext_1 = require("../../../common/components/hosts/HostsTableDetailContext");
const react_table_1 = require("@patternfly/react-table");
const ClusterWizardContext_1 = require("../clusterWizard/ClusterWizardContext");
function ExpandComponent({ obj: host }) {
    const { onDiskRole, canEditDisks, updateDiskSkipFormatting } = (0, HostsTableDetailContext_1.useHostsTableDetailContext)();
    return (React.createElement(HostRowDetail_1.HostDetail, { host: host, AdditionalNTPSourcesDialogToggleComponent: AdditionaNTPSourceDialogToggle_1.AdditionalNTPSourcesDialogToggle, hideNTPStatus: true, onDiskRole: onDiskRole, canEditDisks: canEditDisks, updateDiskSkipFormatting: updateDiskSkipFormatting }));
}
const ClusterHostsTable = ({ cluster, skipDisabled }) => {
    const { wizardPerPage, setWizardPerPage } = React.useContext(ClusterWizardContext_1.ClusterWizardContext) || {};
    const _a = (0, use_hosts_table_1.useHostsTable)(cluster), { onEditHost, onEditRole, actionChecks, onDiskRole, actionResolver, updateDiskSkipFormatting } = _a, modalProps = tslib_1.__rest(_a, ["onEditHost", "onEditRole", "actionChecks", "onDiskRole", "actionResolver", "updateDiskSkipFormatting"]);
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    const content = React.useMemo(() => [
        (0, common_1.hostnameColumn)(t, onEditHost, undefined, actionChecks.canEditHostname),
        (0, common_1.roleColumn)(t, actionChecks.canEditRole, onEditRole, (0, common_1.selectSchedulableMasters)(cluster), cluster.kind),
        (0, common_1.statusColumn)(t, cluster.status, AdditionaNTPSourceDialogToggle_1.AdditionalNTPSourcesDialogToggle, onEditHost, UpdateDay2ApiVipDialogToggle_1.UpdateDay2ApiVipDialogToggle),
        (0, common_1.discoveredAtColumn)(t),
        (0, common_1.cpuCoresColumn)(t),
        (0, common_1.memoryColumn)(t),
        (0, common_1.disksColumn)(t),
    ], [t, onEditHost, actionChecks, onEditRole, cluster]);
    const hosts = cluster.hosts || [];
    const paginationProps = (0, usePagination_1.usePagination)(hosts.length, wizardPerPage, setWizardPerPage);
    return (React.createElement(React.Fragment, null,
        React.createElement(HostsTableDetailContext_1.HostsTableDetailContextProvider, { canEditDisks: actionChecks.canEditDisks, onDiskRole: onDiskRole, updateDiskSkipFormatting: updateDiskSkipFormatting },
            React.createElement(HostsTable_1.default, Object.assign({ hosts: hosts, skipDisabled: skipDisabled, ExpandComponent: ExpandComponent, content: content, actionResolver: actionResolver, variant: react_table_1.TableVariant.compact }, paginationProps),
                React.createElement(HostsTableEmptyState_1.default, { isSingleNode: (0, common_1.isSNO)(cluster) }))),
        React.createElement(use_hosts_table_1.HostsTableModals, Object.assign({ cluster: cluster }, modalProps))));
};
exports.default = ClusterHostsTable;
//# sourceMappingURL=ClusterHostsTable.js.map