Skip to content

Commit

Permalink
Include cluster field in the host details view
Browse files Browse the repository at this point in the history
  • Loading branch information
arbulu89 committed Apr 29, 2022
1 parent 3ea6603 commit 4251e58
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
16 changes: 14 additions & 2 deletions assets/js/components/HostDetails/HostDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@ import Table from '@components/Table';

import HeartbeatPill from './HeartbeatPill';

import ClusterLink from '@components/ClusterLink';

import {
subscriptionsTableConfiguration,
sapInstancesTableConfiguration,
} from './tableConfigs';

import SuseLogo from '../../../static/suse_logo.svg';
import { getInstancesOnHost, getHost } from '@state/selectors';
import {
getInstancesOnHost,
getClusterByHost,
getHost,
} from '@state/selectors';

const HostDetails = () => {
const { hostID } = useParams();
const host = useSelector(getHost(hostID));
const cluster = useSelector(getClusterByHost(hostID));
const sapSystems = useSelector(getInstancesOnHost(hostID));

// eslint-disable-next-line no-undef
Expand All @@ -41,7 +48,12 @@ const HostDetails = () => {
orientation="vertical"
data={[
{ title: 'Name', content: host.hostname },
{ title: 'Cluster', content: host.cluster && host.cluster.name },
{
title: 'Cluster',
content: (
<ClusterLink cluster={cluster}>{cluster?.name}</ClusterLink>
),
},
{ title: 'Agent version', content: host.agent_version },
]}
/>
Expand Down
5 changes: 5 additions & 0 deletions assets/js/state/selectors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ const enrichInstances = (instances, sapSystemId, state) =>
};
});

export const getClusterByHost = (hostId) => (state) => {
const host = state.hostsList.hosts.find((host) => host.id === hostId);
return state.clustersList.clusters.find(isIdByKey('id', host?.cluster_id));
};

export const getInstancesOnHost = (hostId) => (state) => {
const { databaseInstances, applicationInstances } = state.sapSystemsList;

Expand Down

0 comments on commit 4251e58

Please sign in to comment.