UNPKG

@openshift-assisted/ui-lib

Version:

React component library for the Assisted Installer UI

84 lines 4.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const connected_icon_1 = require("@patternfly/react-icons/dist/js/icons/connected-icon"); const common_1 = require("../../../common"); const helpers_1 = require("../helpers"); const AdditionalNTPSourcesDialogToggle_1 = require("./AdditionalNTPSourcesDialogToggle"); const tableUtils_1 = require("../Agent/tableUtils"); const HostsTable_1 = tslib_1.__importDefault(require("../../../common/components/hosts/HostsTable")); const HostRowDetail_1 = require("../../../common/components/hosts/HostRowDetail"); const tableUtils_2 = require("../../../common/components/hosts/tableUtils"); const usePagination_1 = require("../../../common/components/hosts/usePagination"); const use_translation_wrapper_1 = require("../../../common/hooks/use-translation-wrapper"); const agentStatus_1 = require("../helpers/agentStatus"); const ExpandComponentContext = React.createContext({ onSetInstallationDiskId: undefined, agents: [], }); const ExpandComponent = ({ obj }) => { const { onSetInstallationDiskId, agents } = React.useContext(ExpandComponentContext); return (React.createElement(HostRowDetail_1.HostDetail, { host: obj, AdditionalNTPSourcesDialogToggleComponent: AdditionalNTPSourcesDialogToggle_1.AdditionalNTPSourcesDialogToggle, canEditDisks: () => true, onDiskRole: onSetInstallationDiskId ? (hostID, diskID, role) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { const agent = agents.find((a) => { var _a; return ((_a = a.metadata) === null || _a === void 0 ? void 0 : _a.uid) === obj.id; }); if (agent && diskID && role === 'install') { yield (onSetInstallationDiskId === null || onSetInstallationDiskId === void 0 ? void 0 : onSetInstallationDiskId(agent, diskID)); } }) : undefined })); }; const ClusterDeploymentHostsNetworkTable = // eslint-disable-next-line react/display-name React.memo(({ clusterDeployment, agentClusterInstall, agents, onEditHost, onEditRole, onSetInstallationDiskId, }) => { const { t } = (0, use_translation_wrapper_1.useTranslation)(); const agentStatuses = (0, agentStatus_1.agentStatus)(t); const cluster = React.useMemo(() => (0, helpers_1.getAICluster)({ clusterDeployment, agentClusterInstall, agents }), [clusterDeployment, agentClusterInstall, agents]); const [hosts, hostActions, actionResolver] = (0, tableUtils_1.useAgentsTable)({ agents }, { onEditHost, onEditRole, onSetInstallationDiskId, }); const isSNOCluster = (0, helpers_1.getIsSNOCluster)(agentClusterInstall); const content = React.useMemo(() => isSNOCluster ? [ (0, tableUtils_2.hostnameColumn)(t, hostActions.onEditHost, hosts), (0, tableUtils_1.agentStatusColumn)({ agents, agentStatuses, onEditHostname: onEditHost, wizardStepId: 'networking', t, }), (0, tableUtils_2.activeNICColumn)(cluster, t), ] : [ (0, tableUtils_2.hostnameColumn)(t, hostActions.onEditHost, hosts), (0, tableUtils_2.roleColumn)(t, hostActions.canEditRole, hostActions.onEditRole), (0, tableUtils_1.agentStatusColumn)({ agents, agentStatuses, onEditHostname: onEditHost, wizardStepId: 'networking', t, }), (0, tableUtils_2.activeNICColumn)(cluster, t), ], [ isSNOCluster, t, hostActions.onEditHost, hostActions.canEditRole, hostActions.onEditRole, hosts, agents, agentStatuses, onEditHost, cluster, ]); const paginationProps = (0, usePagination_1.usePagination)(hosts.length); return (React.createElement(ExpandComponentContext.Provider, { value: { onSetInstallationDiskId, agents } }, React.createElement(HostsTable_1.default, Object.assign({ testId: "networking-host-table", hosts: hosts, ExpandComponent: ExpandComponent, content: content, actionResolver: actionResolver }, paginationProps), React.createElement(common_1.EmptyState, { icon: connected_icon_1.ConnectedIcon, title: t('ai:Waiting for hosts...'), content: t('ai:Hosts may take a few minutes to appear here after booting.') })))); }); exports.default = ClusterDeploymentHostsNetworkTable; //# sourceMappingURL=ClusterDeploymentHostsNetworkTable.js.map