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

56 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-05-11 20:16:52 +03:00
import React, { Component } from 'react';
import { graphql } from 'react-apollo';
import { Link } from 'react-router-dom';
import ServicesQuery from '@graphql/Services.gql';
2017-02-28 20:34:48 +02:00
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,
services,
loading,
error
} = this.props;
2017-05-11 20:16:52 +03:00
const serviceList =
loading ? <p>Loading...</p> :
error ? <p>Error!!!</p> :
services.map((service, index) =>
<p key={index}>
<Link
to={`${location.pathname}/${service.id}/instances`}
>
{service.name}
</Link>
</p>);
2017-03-22 18:50:21 +02:00
return (
2017-05-11 20:16:52 +03:00
<div>
<div>
<h2>Service List</h2>
</div>
{ serviceList }
</div>
);
}
}
2017-02-28 20:34:48 +02:00
2017-05-11 20:16:52 +03:00
const ServiceListWithData = graphql(ServicesQuery, {
options(props) {
return {
variables: {
deploymentGroupId: props.match.params.deploymentGroup
}
}
2017-02-28 20:34:48 +02:00
},
2017-05-11 20:16:52 +03:00
props: ({ data: { deploymentGroup, loading, error }}) => ({
services: deploymentGroup ? deploymentGroup.services : null,
loading,
error
})
})(ServiceList);
export default ServiceListWithData;