From bbfa427a9236afde65aaca5fc9ef7dd914dd862e Mon Sep 17 00:00:00 2001 From: Sara Vieira Date: Tue, 23 Jan 2018 12:13:13 +0100 Subject: [PATCH] fix(my-joy-beta): order and check default networks fixes #928 --- .../src/components/create-instance/network.js | 2 +- .../__snapshots__/networks.spec.js.snap | 4 +-- .../containers/create-instance/networks.js | 27 ++++++++++++------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/packages/my-joy-beta/src/components/create-instance/network.js b/packages/my-joy-beta/src/components/create-instance/network.js index 767be4bd..446c0ebd 100644 --- a/packages/my-joy-beta/src/components/create-instance/network.js +++ b/packages/my-joy-beta/src/components/create-instance/network.js @@ -115,7 +115,7 @@ export const Expanded = ({ - + diff --git a/packages/my-joy-beta/src/containers/create-instance/__tests__/__snapshots__/networks.spec.js.snap b/packages/my-joy-beta/src/containers/create-instance/__tests__/__snapshots__/networks.spec.js.snap index 1c5d8db3..f072137a 100644 --- a/packages/my-joy-beta/src/containers/create-instance/__tests__/__snapshots__/networks.spec.js.snap +++ b/packages/my-joy-beta/src/containers/create-instance/__tests__/__snapshots__/networks.spec.js.snap @@ -2663,7 +2663,7 @@ Array [ className="c7" >
{ const selected = get(form, `${FORM_NAME}.values`, {}); + const empty = id => !Object.keys(selected).includes(id); return { proceeded: get(values, 'create-instance-networks-proceeded', false), - networks: networks.map(({ id, ...network }) => ({ - ...network, - selected: Boolean(selected[id]), - infoExpanded: get( - values, - `create-instance-networks-${id}-expanded`, - false - ), - id - })) + networks: networks + .map(({ id, name, ...network }) => ({ + ...network, + name, + selected: + empty(id) && name === 'Joyent-SDC-Public' + ? true + : Boolean(selected[id]), + infoExpanded: get( + values, + `create-instance-networks-${id}-expanded`, + false + ), + id + })) + .sort((a, b) => a.name < b.name) }; }, (dispatch, { history }) => ({