joyent-portal/frontend/src/containers/services/list.js

87 lines
2.0 KiB
JavaScript
Raw Normal View History

2017-05-11 20:16:52 +03:00
import React, { Component } from 'react';
2017-05-19 00:04:29 +03:00
import { compose, graphql } from 'react-apollo';
import { connect } from 'react-redux';
import styled from 'styled-components';
// import { Link } from 'react-router-dom';
import PortalQuery from '@graphql/Portal.gql';
2017-05-11 20:16:52 +03:00
import ServicesQuery from '@graphql/Services.gql';
2017-02-28 20:34:48 +02:00
2017-05-19 00:04:29 +03:00
import { processServices } from '@root/state/selectors';
import { LayoutContainer } from '@components/layout';
import { ServiceListItem } from '@components/services';
const StyledContainer = styled.div`
position: relative;
`;
2017-05-11 20:16:52 +03:00
class ServiceList extends Component {
render() {
2017-05-11 20:16:52 +03:00
const {
2017-05-11 20:16:52 +03:00
location,
2017-05-19 00:04:29 +03:00
deploymentGroup,
2017-05-11 20:16:52 +03:00
services,
loading,
error
} = this.props;
2017-05-19 00:04:29 +03:00
console.log('services = ', services);
if(loading || error) {
return (
<p>Loading OR error</p>
);
}
const serviceList = services.map((service) => (
<ServiceListItem
key={service.uuid}
onQuickActions={null /*onQuickActions*/}
deploymentGroup={deploymentGroup.slug}
service={service}
uiTooltip={null /* uiTooltip */}
/>
));
2017-03-22 18:50:21 +02:00
return (
2017-05-19 00:04:29 +03:00
<LayoutContainer>
<StyledContainer>
<div>
{ /* <div ref={this.ref('container')}> */ }
{serviceList}
{ /* <ServicesTooltip {...uiTooltip} onBlur={handleTooltipBlur} /> */ }
</div>
</StyledContainer>
</LayoutContainer>
);
}
}
2017-02-28 20:34:48 +02:00
2017-05-19 00:04:29 +03:00
const PortalGql = graphql(PortalQuery, {});
const ServicesGql = graphql(ServicesQuery, {
2017-05-11 20:16:52 +03:00
options(props) {
return {
variables: {
2017-05-17 21:02:35 +03:00
deploymentGroupSlug: props.match.params.deploymentGroup
2017-05-11 20:16:52 +03:00
}
}
2017-02-28 20:34:48 +02:00
},
2017-05-11 20:16:52 +03:00
props: ({ data: { deploymentGroup, loading, error }}) => ({
2017-05-19 00:04:29 +03:00
deploymentGroup,
services: deploymentGroup ?
processServices(deploymentGroup.services, null) : null,
2017-05-11 20:16:52 +03:00
loading,
error
})
2017-05-19 00:04:29 +03:00
});
const ServiceListWithData = compose(
PortalGql,
ServicesGql
)(ServiceList);
2017-05-11 20:16:52 +03:00
export default ServiceListWithData;