From 77540223abb504a2d482da6d86efeb6956a24eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Tue, 3 Oct 2017 16:04:54 +0100 Subject: [PATCH] fix(my-joy-beta): adapt to cloudapi-gql breaking changes --- .../src/components/instances/item.js | 18 ++++++------------ .../src/containers/instances/firewall.js | 7 +++++-- .../src/containers/instances/metadata.js | 4 ++-- .../src/containers/instances/networks.js | 2 ++ .../src/containers/instances/tags.js | 4 ++-- .../my-joy-beta/src/graphql/get-instance.gql | 5 +---- .../src/graphql/list-firewall-rules.gql | 4 ++-- .../my-joy-beta/src/graphql/list-instances.gql | 8 ++------ .../my-joy-beta/src/graphql/list-metadata.gql | 6 +++++- .../my-joy-beta/src/graphql/list-networks.gql | 7 +++---- packages/my-joy-beta/src/graphql/list-tags.gql | 6 +++++- 11 files changed, 35 insertions(+), 36 deletions(-) diff --git a/packages/my-joy-beta/src/components/instances/item.js b/packages/my-joy-beta/src/components/instances/item.js index f0e529f0..dc62ca73 100644 --- a/packages/my-joy-beta/src/components/instances/item.js +++ b/packages/my-joy-beta/src/components/instances/item.js @@ -16,18 +16,12 @@ import { const { SmallOnly, Small } = QueryBreakpoints; const stateColor = { - provisioning: 'blue', - ready: 'blue', - active: 'green', - running: 'green', - stopping: 'grey', - stopped: 'grey', - offline: 'red', - destroyed: 'red', - failed: 'red', - deleted: 'secondaryActive', - incomplete: 'secondaryActive', - unknown: 'secondaryActive' + PROVISIONING: 'blue', + RUNNING: 'green', + STOPPING: 'grey', + STOPPED: 'grey', + DELETED: 'secondaryActive', + FAILED: 'red' }; export default ({ name, state, primaryIp, last, first }) => ( diff --git a/packages/my-joy-beta/src/containers/instances/firewall.js b/packages/my-joy-beta/src/containers/instances/firewall.js index cd25f0d8..6bf97440 100644 --- a/packages/my-joy-beta/src/containers/instances/firewall.js +++ b/packages/my-joy-beta/src/containers/instances/firewall.js @@ -11,6 +11,7 @@ import GetFirewallRules from '@graphql/list-firewall-rules.gql'; import { FirewallRule as InstanceFirewallRule } from '@components/instances'; const Firewall = ({ + // eslint-disable-next-line camelcase firewallEnabled = false, firewallRules = [], loading, @@ -63,9 +64,11 @@ export default compose( }), props: ({ data: { loading, error, variables, ...rest } }) => { const machine = find(get(rest, 'machines', []), ['name', variables.name]); - const firewallEnabled = get(machine, 'firewallEnabled', false); - const firewallRules = get(machine, 'firewallRules', []); + // eslint-disable-next-line camelcase + const firewallEnabled = get(machine, 'firewall_enabled', false); + const firewallRules = get(machine, 'firewall_rules', []); + // eslint-disable-next-line camelcase return { firewallEnabled, firewallRules, loading, error }; } }) diff --git a/packages/my-joy-beta/src/containers/instances/metadata.js b/packages/my-joy-beta/src/containers/instances/metadata.js index 607911a6..25afea7a 100644 --- a/packages/my-joy-beta/src/containers/instances/metadata.js +++ b/packages/my-joy-beta/src/containers/instances/metadata.js @@ -81,7 +81,7 @@ export default compose( [] ); - const metadata = Object.keys(values).reduce((all, name) => { + const metadata = values.reduce((all, { name, value }) => { const key = paramCase(name); return { @@ -90,7 +90,7 @@ export default compose( key, formName: `${key}-name`, formValue: `${key}-value`, - value: values[name], + value, name } }; diff --git a/packages/my-joy-beta/src/containers/instances/networks.js b/packages/my-joy-beta/src/containers/instances/networks.js index 126d571c..5204cf8e 100644 --- a/packages/my-joy-beta/src/containers/instances/networks.js +++ b/packages/my-joy-beta/src/containers/instances/networks.js @@ -15,6 +15,8 @@ const Networks = ({ networks = [], loading, error }) => { const _title = Networks; const _loading = !(loading && !values.length) ? null : ; + console.log(values); + const _networks = !_loading && values.map((network, i, all) => ( diff --git a/packages/my-joy-beta/src/containers/instances/tags.js b/packages/my-joy-beta/src/containers/instances/tags.js index d1c3bb0d..83891878 100644 --- a/packages/my-joy-beta/src/containers/instances/tags.js +++ b/packages/my-joy-beta/src/containers/instances/tags.js @@ -81,7 +81,7 @@ export default compose( [] ); - const tags = Object.keys(values).reduce((all, name) => { + const tags = values.reduce((all, { name, value }) => { const key = paramCase(name); return { @@ -90,7 +90,7 @@ export default compose( key, formName: `${key}-name`, formValue: `${key}-value`, - value: values[name], + value, name } }; diff --git a/packages/my-joy-beta/src/graphql/get-instance.gql b/packages/my-joy-beta/src/graphql/get-instance.gql index c4d737ad..7f2e0338 100644 --- a/packages/my-joy-beta/src/graphql/get-instance.gql +++ b/packages/my-joy-beta/src/graphql/get-instance.gql @@ -2,14 +2,11 @@ query Instance($name: String!) { machines(name: $name) { id name - brand state - image memory disk created updated - firewallEnabled - package + firewall_enabled } } diff --git a/packages/my-joy-beta/src/graphql/list-firewall-rules.gql b/packages/my-joy-beta/src/graphql/list-firewall-rules.gql index 67d3021b..b1e281d5 100644 --- a/packages/my-joy-beta/src/graphql/list-firewall-rules.gql +++ b/packages/my-joy-beta/src/graphql/list-firewall-rules.gql @@ -2,8 +2,8 @@ query Instance($name: String!) { machines(name: $name) { id name - firewallEnabled - firewallRules { + firewall_enabled + firewall_rules { id enabled global diff --git a/packages/my-joy-beta/src/graphql/list-instances.gql b/packages/my-joy-beta/src/graphql/list-instances.gql index 7887d43e..5fa0dbcb 100644 --- a/packages/my-joy-beta/src/graphql/list-instances.gql +++ b/packages/my-joy-beta/src/graphql/list-instances.gql @@ -2,13 +2,9 @@ query Instances { machines { id name - brand state - image - metadata - tags - firewallEnabled - primaryIp + firewall_enabled + primary_ip docker } } diff --git a/packages/my-joy-beta/src/graphql/list-metadata.gql b/packages/my-joy-beta/src/graphql/list-metadata.gql index 58d1960b..e34ff968 100644 --- a/packages/my-joy-beta/src/graphql/list-metadata.gql +++ b/packages/my-joy-beta/src/graphql/list-metadata.gql @@ -2,6 +2,10 @@ query Instance($name: String!) { machines(name: $name) { id name - metadata + metadata { + id + name + value + } } } diff --git a/packages/my-joy-beta/src/graphql/list-networks.gql b/packages/my-joy-beta/src/graphql/list-networks.gql index 502b6e98..d257269e 100644 --- a/packages/my-joy-beta/src/graphql/list-networks.gql +++ b/packages/my-joy-beta/src/graphql/list-networks.gql @@ -9,12 +9,11 @@ query Instance($name: String!) { fabric description subnet - provisionStartIp - provisionEndIp + provision_start_ip + provision_end_ip gateway resolvers - routes - internetNat + internet_nat } } } diff --git a/packages/my-joy-beta/src/graphql/list-tags.gql b/packages/my-joy-beta/src/graphql/list-tags.gql index 09a638e6..cd48f6cc 100644 --- a/packages/my-joy-beta/src/graphql/list-tags.gql +++ b/packages/my-joy-beta/src/graphql/list-tags.gql @@ -2,6 +2,10 @@ query Instance($name: String!) { machines(name: $name) { id name - tags + tags { + id + name + value + } } }