diff --git a/frontend/public/components/node.tsx b/frontend/public/components/node.tsx index b0ab9877cdd..353fe51e9c6 100644 --- a/frontend/public/components/node.tsx +++ b/frontend/public/components/node.tsx @@ -5,15 +5,14 @@ import * as React from 'react'; import { nodeStatus, makeNodeSchedulable, K8sResourceKind, referenceForModel } from '../module/k8s'; import { ResourceEventStream } from './events'; -import { ColHead, DetailsPage, List, ListHeader, ListPage, ResourceRow } from './factory'; +import { ColHead, List, ListHeader, ListPage, ResourceRow } from './factory'; import { configureUnschedulableModal } from './modals'; import { PodsPage } from './pod'; -import { Kebab, navFactory, LabelList, ResourceKebab, SectionHeading, ResourceLink, Timestamp, units, cloudProviderNames, cloudProviderID, pluralize } from './utils'; +import { Kebab, navFactory, LabelList, SectionHeading, ResourceLink, Timestamp, units, cloudProviderNames, cloudProviderID, pluralize } from './utils'; import { Line, requirePrometheus } from './graphs'; -import { MachineModel, NodeModel, NodeMaintenance } from '../models'; +import { MachineModel, NodeModel } from '../models'; import { CamelCaseWrap } from './utils/camel-case-wrap'; -import { NodeStatusWithMaintenanceConnected, maintenanceActions } from '../kubevirt/components/node/node'; -import { getResource } from 'kubevirt-web-ui-components'; +import { NodeStatusWithMaintenanceConnected, NodeMaintenanceKebab, NodeDetailsPageWithMaintenance } from '../kubevirt/components/node/node'; const MarkAsUnschedulable = (kind, obj) => ({ label: 'Mark as Unschedulable', @@ -28,9 +27,9 @@ const MarkAsSchedulable = (kind, obj) => ({ }); const { ModifyLabels, ModifyAnnotations, Edit } = Kebab.factory; -const menuActions = [MarkAsSchedulable, MarkAsUnschedulable, ModifyLabels, ModifyAnnotations, Edit, ...maintenanceActions]; +const menuActions = [MarkAsSchedulable, MarkAsUnschedulable, ModifyLabels, ModifyAnnotations, Edit]; -const NodeKebab = ({node}) => ; +const NodeKebab = ({node}) => ; const getMachine = (node: K8sResourceKind) => { const machine = _.get(node, 'metadata.annotations["machine.openshift.io/machine"]'); @@ -245,9 +244,8 @@ const pages = [ pods(({obj}) => ), events(ResourceEventStream), ]; -export const NodesDetailsPage = props => ; diff --git a/frontend/public/kubevirt/components/node/node.jsx b/frontend/public/kubevirt/components/node/node.jsx index 2cc76757b8d..543762386d6 100644 --- a/frontend/public/kubevirt/components/node/node.jsx +++ b/frontend/public/kubevirt/components/node/node.jsx @@ -1,13 +1,15 @@ import * as React from 'react'; +import { connect } from 'react-redux'; import { getResource, findNodeMaintenance, getDeletionTimestamp, NodeStatus } from 'kubevirt-web-ui-components'; import { k8sKill, nodeStatus } from '../../module/okdk8s'; import { NodeMaintenance } from '../../models'; -import { LoadingInline, StatusIcon, Timestamp } from '../utils/okdutils'; +import { LoadingInline, StatusIcon, Timestamp, ResourceKebab } from '../utils/okdutils'; import { startMaintenanceModal } from './node-maintenance-modal'; import { WithResources } from '../utils/withResources'; +import { DetailsPage } from '../factory/okdfactory'; -const statusResourceMap = { +const maintenanceResourceMap = { maintenances: { resource: getResource(NodeMaintenance), }, @@ -31,7 +33,7 @@ const StopMaintenanceAction = (kind, obj, actionArgs) => { export const maintenanceActions = [StartMaintenanceAction, StopMaintenanceAction]; export const NodeStatusWithMaintenanceConnected = ({node}) => ( - + ); @@ -43,3 +45,30 @@ const NodeStatusWithMaintenance = ({node, maintenances}) => { const maintenance = findNodeMaintenance(node, maintenances); return maintenance ? : ; }; + +const stateToProps = ({k8s}) => ({ + nodeMaintenanceExists: !!k8s.getIn(['RESOURCES', 'models', NodeMaintenance.kind]), +}); + +export const NodeDetailsPageWithMaintenance = connect(stateToProps)(({nodeMaintenanceExists, menuActions, ...rest}) => { + const resources = nodeMaintenanceExists ? [getResource(NodeMaintenance)] : null; + + const maintenanceMenuActions = nodeMaintenanceExists ? [...menuActions, ...maintenanceActions] : menuActions; + + return ( + + ); +}); + +const ConnectedNodeMaintenanceKebab = connect(stateToProps)(({nodeMaintenanceExists, actions, ...rest }) => { + const maintenanceMenuActions = nodeMaintenanceExists ? [...actions, ...maintenanceActions] : actions; + const resources = nodeMaintenanceExists ? [getResource(NodeMaintenance)] : []; + + return ; +}); + +export const NodeMaintenanceKebab = props => ;