Skip to content

Commit

Permalink
feat(xo-web/render-xo-item): implement HostItem component
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajaa-BARHTAOUI committed Aug 13, 2018
1 parent 5a32f90 commit bea9ac8
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion packages/xo-web/src/common/render-xo-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,31 @@ export const PoolItem = [

PoolItem.propTypes = XO_ITEM_PROP_TYPES

export const HostItem = [
connectStore(() => {
const getHost = createGetObject()
return {
host: getHost,
pool: createGetObject(createSelector(getHost, host => host.$pool)),
}
}),
({ host, pool, ...props }) => {
const { id, name_label: nameLabel } = host
return (
<XoItem item={host} to={id !== undefined && `hosts/${id}`} {...props}>
{() => (
<span>
<Icon icon={'host'} /> {`${nameLabel || id} `}
{pool && `(${pool.name_label || pool.id})`}
</span>
)}
</XoItem>
)
},
].reduceRight((value, decorator) => decorator(value))

HostItem.propTypes = XO_ITEM_PROP_TYPES

// ===================================================================

// Host, Network, VM-template.
Expand Down Expand Up @@ -232,7 +257,7 @@ const xoItemToRender = {

// Pool objects.
'VM-template': vmTemplate => <PoolObjectItem object={vmTemplate} />,
host: host => <PoolObjectItem object={host} />,
host: ({ id }) => <HostItem id={id} />,
network: network => <PoolObjectItem object={network} />,

// SR.
Expand Down

0 comments on commit bea9ac8

Please sign in to comment.