Skip to content
This repository has been archived by the owner on Dec 2, 2019. It is now read-only.
/ joyent-portal Public archive

Commit

Permalink
fix(my-joy-beta): set fw initial values only after loading
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioramos committed Feb 5, 2018
1 parent 72d5c8b commit 6ad1796
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 135 deletions.
1 change: 1 addition & 0 deletions packages/my-joy-beta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"lodash.get": "^4.4.2",
"lodash.includes": "^4.3.0",
"lodash.isarray": "^4.0.0",
"lodash.isboolean": "^3.0.3",
"lodash.isfinite": "^3.3.2",
"lodash.isfunction": "^3.0.8",
"lodash.isstring": "^4.0.1",
Expand Down
9 changes: 5 additions & 4 deletions packages/my-joy-beta/src/containers/instances/firewall.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ReduxForm from 'declarative-redux-form';
import { SubmissionError } from 'redux-form';
import { Margin } from 'styled-components-spacing';
import remcalc from 'remcalc';
import isBoolean from 'lodash.isboolean';
import find from 'lodash.find';
import get from 'lodash.get';

Expand Down Expand Up @@ -36,7 +37,7 @@ import parseError from '@state/parse-error';
export const Firewall = ({
defaultRules = [],
tagRules = [],
enabled = false,
enabled,
inactive = false,
loading = false,
loadingError = null,
Expand Down Expand Up @@ -81,7 +82,7 @@ export const Firewall = ({
form="fw-enabled"
destroyOnUnmount={false}
forceUnregisterOnUnmount={true}
initialValues={{ enabled }}
{...{ initialValues: isBoolean(enabled) ? { enabled } : undefined }}
onSubmit={handleEnabledToggle}
>
{props =>
Expand Down Expand Up @@ -142,7 +143,7 @@ export default compose(
const { name } = variables;

const instance = find(get(rest, 'machines', []), ['name', name]);
const enabled = get(instance, 'firewall_enabled', false);
const enabled = get(instance, 'firewall_enabled');
const rules = get(instance, 'firewall_rules', []);

return {
Expand Down Expand Up @@ -175,7 +176,7 @@ export default compose(

return {
handleEnabledToggle: async ({ enabled }) => {
const mutation = enabled ? enableFirewall : disableFirewall;
const mutation = enabled ? disableFirewall : enableFirewall;

const [err] = await intercept(
mutation({
Expand Down
Loading

0 comments on commit 6ad1796

Please sign in to comment.