fix(my-joy-beta): order and check default networks

fixes #928
This commit is contained in:
Sara Vieira 2018-01-23 12:13:13 +01:00 committed by Sérgio Ramos
parent a33b586e42
commit bbfa427a92
3 changed files with 20 additions and 13 deletions

View File

@ -115,7 +115,7 @@ export const Expanded = ({
<CardHeader secondary={selected}> <CardHeader secondary={selected}>
<CardHeaderBox> <CardHeaderBox>
<FormGroup name={id} field={Field}> <FormGroup name={id} field={Field}>
<Checkbox noMargin /> <Checkbox noMargin checked={selected} />
</FormGroup> </FormGroup>
</CardHeaderBox> </CardHeaderBox>
<CardHeaderMeta paddingLeft={0}> <CardHeaderMeta paddingLeft={0}>

View File

@ -2663,7 +2663,7 @@ Array [
className="c7" className="c7"
> >
<div <div
checked={false} checked={true}
className="c8" className="c8"
disabled={false} disabled={false}
id="m" id="m"
@ -2671,7 +2671,7 @@ Array [
type="checkbox" type="checkbox"
> >
<input <input
checked={false} checked={true}
className="c9" className="c9"
disabled={false} disabled={false}
id="n" id="n"

View File

@ -117,12 +117,18 @@ export default compose(
connect( connect(
({ values, form }, { networks }) => { ({ values, form }, { networks }) => {
const selected = get(form, `${FORM_NAME}.values`, {}); const selected = get(form, `${FORM_NAME}.values`, {});
const empty = id => !Object.keys(selected).includes(id);
return { return {
proceeded: get(values, 'create-instance-networks-proceeded', false), proceeded: get(values, 'create-instance-networks-proceeded', false),
networks: networks.map(({ id, ...network }) => ({ networks: networks
.map(({ id, name, ...network }) => ({
...network, ...network,
selected: Boolean(selected[id]), name,
selected:
empty(id) && name === 'Joyent-SDC-Public'
? true
: Boolean(selected[id]),
infoExpanded: get( infoExpanded: get(
values, values,
`create-instance-networks-${id}-expanded`, `create-instance-networks-${id}-expanded`,
@ -130,6 +136,7 @@ export default compose(
), ),
id id
})) }))
.sort((a, b) => a.name < b.name)
}; };
}, },
(dispatch, { history }) => ({ (dispatch, { history }) => ({