@openshift-assisted/ui-lib
Version:
React component library for the Assisted Installer UI
28 lines • 1.9 kB
JavaScript
"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 ShortCapacitySummary_1 = tslib_1.__importDefault(require("../ClusterDeployment/ShortCapacitySummary"));
const use_translation_wrapper_1 = require("../../../common/hooks/use-translation-wrapper");
const getHostCountWarningText = (hostsSelected, t) => {
switch (hostsSelected) {
case 0:
return t('ai:No host is selected.');
}
return t('ai:Only {{hostsSelected}} host is selected.', {
count: hostsSelected,
hostsSelected,
});
};
const AgentsSelectionHostCountAlerts = ({ matchingAgentsCount, selectedAgents, targetHostCount, }) => {
const selectedAgentsCount = selectedAgents.length;
const { t } = (0, use_translation_wrapper_1.useTranslation)();
return (react_1.default.createElement(react_core_1.AlertGroup, null,
selectedAgentsCount === targetHostCount && (react_1.default.createElement(react_core_1.Alert, { variant: react_core_1.AlertVariant.success, title: t('ai:{{selectedAgentsCount}} host selected out of {{matchingAgentsCount}} matching.', { count: selectedAgentsCount, selectedAgentsCount, matchingAgentsCount }), isInline: true },
react_1.default.createElement(ShortCapacitySummary_1.default, { selectedAgents: selectedAgents }))),
selectedAgentsCount < targetHostCount && (react_1.default.createElement(react_core_1.Alert, { variant: react_core_1.AlertVariant.warning, title: getHostCountWarningText(selectedAgentsCount, t), isInline: true },
react_1.default.createElement(ShortCapacitySummary_1.default, { selectedAgents: selectedAgents })))));
};
exports.default = AgentsSelectionHostCountAlerts;
//# sourceMappingURL=AgentsSelectionHostCountAlerts.js.map