@openshift-assisted/ui-lib
Version:
React component library for the Assisted Installer UI
62 lines • 3.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNodePoolStatus = void 0;
const tslib_1 = require("tslib");
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 react_1 = tslib_1.__importDefault(require("react"));
const global_palette_green_500_1 = require("@patternfly/react-tokens/dist/js/global_palette_green_500");
const global_danger_color_100_1 = require("@patternfly/react-tokens/dist/js/global_danger_color_100");
const global_warning_color_100_1 = require("@patternfly/react-tokens/dist/js/global_warning_color_100");
const helpers_1 = require("../../helpers");
const agentStatus_1 = require("../../helpers/agentStatus");
const getNodePoolStatus = (nodePool, agents, t) => {
var _a, _b, _c;
if (!agents.length && nodePool.spec.replicas) {
return {
type: 'pending',
icon: react_1.default.createElement(in_progress_icon_1.InProgressIcon, null),
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
text: t('ai:Pending host assignment'),
};
}
const allAgentStatuses = (0, agentStatus_1.agentStatus)(t);
const agentStatuses = agents.map((a) => (0, helpers_1.getAgentStatus)(a, allAgentStatuses));
const hasErrorAgents = agentStatuses.some(({ status }) => status.key === 'error');
if (hasErrorAgents) {
return {
type: 'error',
icon: react_1.default.createElement(exclamation_circle_icon_1.ExclamationCircleIcon, { color: global_danger_color_100_1.global_danger_color_100.value }),
text: t('ai:Error'),
};
}
const hasWarningAgents = agentStatuses.some(({ status }) => [
'pending-for-input',
'insufficient',
'insufficient-unbound',
'disconnected-unbound',
'disconnected',
].includes(status.key));
if (hasWarningAgents) {
return {
type: 'warning',
icon: react_1.default.createElement(exclamation_circle_icon_1.ExclamationCircleIcon, { color: global_warning_color_100_1.global_warning_color_100.value }),
text: t('ai:Warning'),
};
}
return ((_c = (_b = (_a = nodePool.status) === null || _a === void 0 ? void 0 : _a.conditions) === null || _b === void 0 ? void 0 : _b.find(({ type }) => type === 'Ready')) === null || _c === void 0 ? void 0 : _c.status) === 'True'
? {
type: 'ok',
icon: react_1.default.createElement(check_circle_icon_1.CheckCircleIcon, { color: global_palette_green_500_1.global_palette_green_500.value }),
text: t('ai:Ready'),
}
: {
type: 'pending',
icon: react_1.default.createElement(in_progress_icon_1.InProgressIcon, null),
text: t('ai:Not ready'),
};
};
exports.getNodePoolStatus = getNodePoolStatus;
//# sourceMappingURL=status.js.map