@openshift-assisted/ui-lib
Version:
React component library for the Assisted Installer UI
56 lines • 3.19 kB
JavaScript
"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 global_palette_green_500_1 = require("@patternfly/react-tokens/dist/js/global_palette_green_500");
const check_circle_icon_1 = require("@patternfly/react-icons/dist/js/icons/check-circle-icon");
const utils_1 = require("../utils");
const use_translation_wrapper_1 = require("../../../../common/hooks/use-translation-wrapper");
const NodePoolsTable_1 = tslib_1.__importDefault(require("./NodePoolsTable"));
const getNodePoolsStatus = (agentMachines, hostedCluster, nodePools, agents, t) => {
const nodePoolMap = nodePools.reduce((acc, np) => {
var _a;
const nodePoolAgents = (0, utils_1.getNodepoolAgents)(np, agents, agentMachines, hostedCluster);
const status = (0, utils_1.getNodePoolStatus)(np, nodePoolAgents, t);
acc[((_a = np.metadata) === null || _a === void 0 ? void 0 : _a.uid) || ''] = {
agents: nodePoolAgents,
status,
};
return acc;
}, {});
const nodePoolsStatus = {
type: 'ok',
icon: React.createElement(check_circle_icon_1.CheckCircleIcon, { color: global_palette_green_500_1.global_palette_green_500.value }),
};
for (const property in nodePoolMap) {
const { status } = nodePoolMap[property];
if (status.type === 'error') {
nodePoolsStatus.type = 'error';
nodePoolsStatus.icon = status.icon;
break;
}
if (status.type === 'warning') {
nodePoolsStatus.type = 'warning';
nodePoolsStatus.icon = status.icon;
}
if (status.type === 'pending' && nodePoolsStatus.type !== 'warning') {
nodePoolsStatus.type = 'pending';
nodePoolsStatus.icon = React.createElement(react_core_1.Spinner, { size: "md" });
}
}
return nodePoolsStatus.icon;
};
const NodePoolsProgress = (_a) => {
var { nodePools, agentMachines, hostedCluster, agents } = _a, rest = tslib_1.__rest(_a, ["nodePools", "agentMachines", "hostedCluster", "agents"]);
const { t } = (0, use_translation_wrapper_1.useTranslation)();
const [isExpanded, setExpanded] = React.useState(true);
return (React.createElement(react_core_1.ProgressStep, { icon: getNodePoolsStatus(agentMachines, hostedCluster, nodePools, agents, t) },
React.createElement(react_core_1.Stack, { hasGutter: true },
React.createElement(react_core_1.StackItem, null,
React.createElement(react_core_1.ExpandableSectionToggle, { isExpanded: isExpanded, onToggle: setExpanded, className: "ai-progress-item__header" }, t('ai:Cluster nodepools'))),
isExpanded && (React.createElement(react_core_1.StackItem, { className: "ai-progress-item__body" },
React.createElement(NodePoolsTable_1.default, Object.assign({ nodePools: nodePools, agents: agents, hostedCluster: hostedCluster, agentMachines: agentMachines }, rest)))))));
};
exports.default = NodePoolsProgress;
//# sourceMappingURL=NodePoolsProgress.js.map