From c9ea9117f0e45f8ac64537d38c56b41b6b639448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Tue, 10 Jan 2017 14:58:00 +0000 Subject: [PATCH] extract service item to it's own component --- .../service-item/index.js} | 33 +++++++++++++------ frontend/src/containers/services/index.js | 4 +-- ui/src/components/list/view.js | 24 +++++++------- 3 files changed, 38 insertions(+), 23 deletions(-) rename frontend/src/{containers/services/service.js => components/service-item/index.js} (71%) diff --git a/frontend/src/containers/services/service.js b/frontend/src/components/service-item/index.js similarity index 71% rename from frontend/src/containers/services/service.js rename to frontend/src/components/service-item/index.js index c6fd4e5a..2680f894 100644 --- a/frontend/src/containers/services/service.js +++ b/frontend/src/components/service-item/index.js @@ -1,12 +1,13 @@ const React = require('react'); -// const ReactRouter = require('react-router'); +const ReactRouter = require('react-router'); +const Anchor = require('@ui/components/anchor'); const List = require('@ui/components/list'); const PropTypes = require('@root/prop-types'); -// const { -// Link -// } = ReactRouter; +const { + Link +} = ReactRouter; const { ListItem, @@ -21,15 +22,16 @@ const { ListItemHeader } = List; -const Service = ({ +const ServiceItem = ({ org = '', project = '', service = {} }) => { - // const to = `/${org}/projects/${project}/services/${service.id}`; + const to = `/${org}/projects/${project}/services/${service.id}`; const childs = service.services.map((service) => ( 1} @@ -62,10 +64,21 @@ const Service = ({ ); return ( - + - {service.name} + + + {Anchor.fn( + + {service.name} + + )} + + {service.instances} instance @@ -75,10 +88,10 @@ const Service = ({ ); }; -Service.propTypes = { +ServiceItem.propTypes = { org: React.PropTypes.string, project: React.PropTypes.string, service: PropTypes.service }; -module.exports = Service; +module.exports = ServiceItem; diff --git a/frontend/src/containers/services/index.js b/frontend/src/containers/services/index.js index 94fcfe90..cc0c1c78 100644 --- a/frontend/src/containers/services/index.js +++ b/frontend/src/containers/services/index.js @@ -3,7 +3,7 @@ const ReactRedux = require('react-redux'); const EmptyServices = require('@components/empty/services'); const PropTypes = require('@root/prop-types'); -const Service = require('./service'); +const ServiceItem = require('@components/service-item'); const selectors = require('@state/selectors'); const { @@ -26,7 +26,7 @@ const Services = ({ ); const serviceList = services.map((service) => ( - props.headed && !props.fromHeader ? remcalc(47) : remcalc(0); -const display = (props) => props.headed && !props.fromHeader && props.collapsed - ? 'none' - : 'flex'; - const StyledView = styled(Row)` flex: 1; margin: 0; height: 100%; padding-top: ${paddingTop}; - display: ${display}; `; -const View = (props) => ( - - {props.children} - -); +const View = (props) => { + const hide = props.headed && !props.fromHeader && props.collapsed; + + return hide ? null : ( + + {props.children} + + ); +}; View.propTypes = { - children: React.PropTypes.node + children: React.PropTypes.node, + collapsed: React.PropTypes.bool, + fromHeader: React.PropTypes.bool, + headed: React.PropTypes.bool }; module.exports = transferProps([