From 2291666d81c8fb9c1873707568bf27ba5cbc1429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Wed, 27 Sep 2017 15:23:49 +0100 Subject: [PATCH] feat(my-joy-beta): show filter when loading machines --- packages/my-joy-beta/src/components/instances/item.js | 7 ++++++- packages/my-joy-beta/src/components/instances/list.js | 11 +++++++++-- packages/my-joy-beta/src/containers/instances/list.js | 10 ++++------ packages/my-joy-beta/src/graphql/list-instances.gql | 1 + 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/my-joy-beta/src/components/instances/item.js b/packages/my-joy-beta/src/components/instances/item.js index 36b8b694..350b4f99 100644 --- a/packages/my-joy-beta/src/components/instances/item.js +++ b/packages/my-joy-beta/src/components/instances/item.js @@ -30,7 +30,7 @@ const stateColor = { unknown: 'secondaryActive' }; -export default ({ name, state, last, first }) => ( +export default ({ name, state, primaryIp, last, first }) => ( @@ -40,6 +40,11 @@ export default ({ name, state, last, first }) => ( {name} + + + {primaryIp} + + {titleCase(state)} diff --git a/packages/my-joy-beta/src/components/instances/list.js b/packages/my-joy-beta/src/components/instances/list.js index 336aa4dc..6e9e6622 100644 --- a/packages/my-joy-beta/src/components/instances/list.js +++ b/packages/my-joy-beta/src/components/instances/list.js @@ -1,10 +1,10 @@ import React from 'react'; import forceArray from 'force-array'; -import { FormGroup, Input, FormLabel } from 'joyent-ui-toolkit'; +import { FormGroup, Input, FormLabel, ViewContainer, StatusLoader } from 'joyent-ui-toolkit'; import Item from './item'; -export default ({ instances, handleChange = () => null, handleSubmit }) => { +export default ({ instances, loading, handleChange = () => null, handleSubmit }) => { const _instances = forceArray(instances); const items = _instances.map((instance, i, all) => ( @@ -16,12 +16,19 @@ export default ({ instances, handleChange = () => null, handleSubmit }) => { /> )); + const _loading = (!items.length && loading) ? ( + + + + ) : null; + return (
handleSubmit(ctx => handleChange(ctx))}> Filter instances + {_loading} {items}
); diff --git a/packages/my-joy-beta/src/containers/instances/list.js b/packages/my-joy-beta/src/containers/instances/list.js index a6f3158a..86249bd9 100644 --- a/packages/my-joy-beta/src/containers/instances/list.js +++ b/packages/my-joy-beta/src/containers/instances/list.js @@ -17,11 +17,10 @@ const InstanceListForm = reduxForm({ form: `instance-list` })(InstanceList); -const List = ({ instances, loading, error }) => { +const List = ({ instances = [], loading = false, error }) => { const _title = Instances; const _instances = forceArray(instances); - const _loading = !(loading && !_instances.length) ? null : ; - const _list = _loading ? null : ; + const _loading = (!instances.length && loading); const _error = !error ? null : ( { ); return ( - + {_title} {!_loading && _error} - {_loading} - {_list} + ); }; diff --git a/packages/my-joy-beta/src/graphql/list-instances.gql b/packages/my-joy-beta/src/graphql/list-instances.gql index 2be72335..7887d43e 100644 --- a/packages/my-joy-beta/src/graphql/list-instances.gql +++ b/packages/my-joy-beta/src/graphql/list-instances.gql @@ -8,6 +8,7 @@ query Instances { metadata tags firewallEnabled + primaryIp docker } }