fix(my-joy-beta): don't require proceeded to deploy

# Conflicts:
#	packages/my-joy-beta/src/containers/create-instance/index.js
#	packages/my-joy-beta/src/containers/create-instance/tags.js
#	yarn.lock
This commit is contained in:
Sérgio Ramos 2018-02-21 16:22:30 +00:00
parent 234a481c32
commit 929fcf0ab4
14 changed files with 381 additions and 317 deletions

View File

@ -46,6 +46,7 @@
"lodash.reverse": "^4.0.1", "lodash.reverse": "^4.0.1",
"lodash.sortby": "^4.7.0", "lodash.sortby": "^4.7.0",
"lodash.uniqby": "^4.7.0", "lodash.uniqby": "^4.7.0",
"lodash.values": "^4.3.0",
"lunr": "^2.1.5", "lunr": "^2.1.5",
"normalized-styled-components": "^1.0.18", "normalized-styled-components": "^1.0.18",
"param-case": "^2.1.1", "param-case": "^2.1.1",

View File

@ -12,7 +12,6 @@ import { AffinityIcon, Button, H3, Divider, KeyValue } from 'joyent-ui-toolkit';
import Title from '@components/create-instance/title'; import Title from '@components/create-instance/title';
import { Rule, Header } from '@components/create-instance/affinity'; import { Rule, Header } from '@components/create-instance/affinity';
import Animated from '@containers/create-instance/animated';
import Description from '@components/description'; import Description from '@components/description';
const FORM_NAME_CREATE = 'CREATE-INSTANCE-AFFINITY-ADD'; const FORM_NAME_CREATE = 'CREATE-INSTANCE-AFFINITY-ADD';
@ -149,13 +148,19 @@ export const Affinity = ({
); );
export default compose( export default compose(
Animated, connect(({ values, form }, ownProps) => {
connect(({ values, form }, ownProps) => ({ const proceeded = get(values, 'create-instance-affinity-proceeded', false);
proceeded: get(values, 'create-instance-affinity-proceeded', false), const addOpen = get(values, 'create-instance-affinity-add-open', false);
addOpen: get(values, 'create-instance-affinity-add-open', false), const affinityRules = get(values, 'create-instance-affinity', []);
affinityRules: get(values, 'create-instance-affinity', []), const rule = get(form, `${FORM_NAME_CREATE}.values`, {});
rule: get(form, `${FORM_NAME_CREATE}.values`, {})
})), return {
proceeded: proceeded || affinityRules.length,
addOpen,
affinityRules,
rule,
};
}),
connect(null, (dispatch, { affinityRules = [], history }) => ({ connect(null, (dispatch, { affinityRules = [], history }) => ({
handleEdit: () => { handleEdit: () => {
return history.push(`/~create/affinity${history.location.search}`); return history.push(`/~create/affinity${history.location.search}`);

View File

@ -11,7 +11,6 @@ import punycode from 'punycode';
import { CnsIcon, H3, Button } from 'joyent-ui-toolkit'; import { CnsIcon, H3, Button } from 'joyent-ui-toolkit';
import Title from '@components/create-instance/title'; import Title from '@components/create-instance/title';
import Animated from '@containers/create-instance/animated';
import Cns, { Footer, AddServiceForm } from '@components/cns'; import Cns, { Footer, AddServiceForm } from '@components/cns';
import Description from '@components/description'; import Description from '@components/description';
import GetAccount from '@graphql/get-account.gql'; import GetAccount from '@graphql/get-account.gql';
@ -102,13 +101,13 @@ const CNSContainer = ({
); );
export default compose( export default compose(
Animated,
graphql(GetAccount, { graphql(GetAccount, {
props: ({ data: { account: { id = '<account-id>' } = [] } }) => ({ props: ({ data: { account: { id = '<account-id>' } = [] } }) => ({
id id
}) })
}), }),
connect(({ form, values }, { id }) => { connect(({ form, values }, { id }) => {
const proceeded = get(values, `${CNS_FORM}-proceeded`, false);
const instanceName = get( const instanceName = get(
form, form,
'create-instance-name.values.name', 'create-instance-name.values.name',
@ -154,7 +153,7 @@ export default compose(
return { return {
cnsEnabled: get(values, `${CNS_FORM}-enabled`, true), cnsEnabled: get(values, `${CNS_FORM}-enabled`, true),
instanceName, instanceName,
proceeded: get(values, `${CNS_FORM}-proceeded`, false), proceeded: proceeded || serviceNames.length,
hostnames, hostnames,
serviceNames serviceNames
}; };

View File

@ -19,7 +19,6 @@ import {
} from '@components/firewall'; } from '@components/firewall';
import Title from '@components/create-instance/title'; import Title from '@components/create-instance/title';
import Animated from '@containers/create-instance/animated';
import Description from '@components/description'; import Description from '@components/description';
import Empty from '@components/empty'; import Empty from '@components/empty';
import ListFwRules from '@graphql/list-fw-rules.gql'; import ListFwRules from '@graphql/list-fw-rules.gql';
@ -150,7 +149,6 @@ const Firewall = ({
); );
export default compose( export default compose(
Animated,
connect( connect(
({ form, values }, ownProps) => ({ ({ form, values }, ownProps) => ({
...ownProps, ...ownProps,

View File

@ -16,7 +16,6 @@ import { InstanceTypeIcon, StatusLoader, Button } from 'joyent-ui-toolkit';
import Image, { Preview, ImageType } from '@components/create-instance/image'; import Image, { Preview, ImageType } from '@components/create-instance/image';
import Title from '@components/create-instance/title'; import Title from '@components/create-instance/title';
import Animated from '@containers/create-instance/animated';
import Description from '@components/description'; import Description from '@components/description';
import imageData from '@data/images-map.json'; import imageData from '@data/images-map.json';
import GetImages from '@graphql/get-images.gql'; import GetImages from '@graphql/get-images.gql';
@ -122,14 +121,17 @@ const ImageContainer = ({
); );
export default compose( export default compose(
Animated,
connect( connect(
({ form, values }, ownProps) => { ({ form, values }, ownProps) => {
const proceeded = get(values, 'create-instance-image-proceeded', false);
const vms = get(form, 'create-instance-vms.values.vms', false);
const image = get(form, 'create-instance-image.values.image', null);
return { return {
...ownProps, ...ownProps,
proceeded: get(values, 'create-instance-image-proceeded', false), proceeded: proceeded || image,
vms: get(form, 'create-instance-vms.values.vms', false), vms,
image: get(form, 'create-instance-image.values.image', null) image
}; };
}, },
(dispatch, { history }) => ({ (dispatch, { history }) => ({

View File

@ -11,6 +11,7 @@ import intercept from 'apr-intercept';
import constantCase from 'constant-case'; import constantCase from 'constant-case';
import queryString from 'query-string'; import queryString from 'query-string';
import get from 'lodash.get'; import get from 'lodash.get';
import Values from 'lodash.values';
import omit from 'lodash.omit'; import omit from 'lodash.omit';
import uniqBy from 'lodash.uniqby'; import uniqBy from 'lodash.uniqby';
@ -131,61 +132,46 @@ export default compose(
const query = queryString.parse(location.search); const query = queryString.parse(location.search);
const FORM_NAME = 'create-instance-name'; const FORM_NAME = 'create-instance-name';
const step = get(match, 'params.step', 'name'); const step = get(match, 'params.step', 'name');
const nameFilled = get(form, `${FORM_NAME}.values.name`, '');
const disabled = ['name', 'image', 'package', 'networks'].some( const name = get(form, `${FORM_NAME}.values.name`, '');
step => const image = get(form, 'create-instance-image.values.image', '');
!get(values, `create-instance-${step}-proceeded`, false) || const pkg = get(form, 'create-instance-package.values.package', '');
!nameFilled.length const networks = get(form, 'CREATE-INSTANCE-NETWORKS.values', {});
const enabled = (
name.length &&
image.length &&
pkg.length &&
Values(networks).filter(Boolean).length
); );
if (disabled) { if (!enabled) {
return { return {
query, disabled: !enabled,
disabled,
step step
}; };
} }
const name = get(
form,
'create-instance-name.values.name',
'<instance-name>'
);
const firewall_enabled = get(
form,
'CREATE-INSTANCE-FIREWALL.values.enabled',
false
);
const image = get(
form,
'create-instance-image.values.image',
'<instance-image>'
);
const pkg = get(
form,
'create-instance-package.values.package',
'<instance-pkg>'
);
const networks = get(form, 'CREATE-INSTANCE-NETWORKS.values', {});
const metadata = get(values, 'create-instance-metadata', []); const metadata = get(values, 'create-instance-metadata', []);
const receivedTags = get(values, 'create-instance-tags', []); const receivedTags = get(values, 'create-instance-tags', []);
const affinity = get(values, 'create-instance-affinity', []); const affinity = get(values, 'create-instance-affinity', []);
const cns = get(values, 'create-instance-cns-enabled', true); const cns = get(values, 'create-instance-cns-enabled', true);
const cnsServices = get(values, 'create-instance-cns-services', null); const cnsServices = get(values, 'create-instance-cns-services', null);
const userScript = get(values, 'create-instance-user-script', {}); const userScript = get(values, 'create-instance-user-script', {});
const tags = receivedTags.map(a => omit(a, 'expanded')); const tags = receivedTags.map(a => omit(a, 'expanded'));
tags.push({ name: 'triton.cns.disable', value: !cns }); const firewall_enabled = get(form, 'CREATE-INSTANCE-FIREWALL.values.enabled', false);
tags.push({
name: 'triton.cns.disable',
value: !cns
});
if (cnsServices && cns) { if (cnsServices && cns) {
tags.push({ name: 'triton.cns.services', value: cnsServices.join(',') }); tags.push({
name: 'triton.cns.services',
value: cnsServices.join(',')
});
} }
return { return {
@ -200,7 +186,6 @@ export default compose(
tags, tags,
firewall_enabled, firewall_enabled,
networks, networks,
disabled,
step step
}; };
}), }),

View File

@ -12,7 +12,6 @@ import { MetadataIcon, Button, H3, Divider, KeyValue } from 'joyent-ui-toolkit';
import Editor from 'joyent-ui-toolkit/dist/es/editor'; import Editor from 'joyent-ui-toolkit/dist/es/editor';
import Title from '@components/create-instance/title'; import Title from '@components/create-instance/title';
import Animated from '@containers/create-instance/animated';
import Description from '@components/description'; import Description from '@components/description';
const FORM_NAME_CREATE = 'CREATE-INSTANCE-METADATA-ADD'; const FORM_NAME_CREATE = 'CREATE-INSTANCE-METADATA-ADD';
@ -145,12 +144,17 @@ export const Metadata = ({
); );
export default compose( export default compose(
Animated, connect(({ values }, ownProps) => {
connect(({ values }, ownProps) => ({ const proceeded = get(values, 'create-instance-metadata-proceeded', false);
proceeded: get(values, 'create-instance-metadata-proceeded', false), const addOpen = get(values, 'create-instance-metadata-add-open', false);
addOpen: get(values, 'create-instance-metadata-add-open', false), const metadata = get(values, 'create-instance-metadata', []);
metadata: get(values, 'create-instance-metadata', [])
})), return {
proceeded: proceeded || metadata.length,
addOpen,
metadata
};
}),
connect(null, (dispatch, { metadata = [], history }) => ({ connect(null, (dispatch, { metadata = [], history }) => ({
handleNext: () => { handleNext: () => {
dispatch( dispatch(

View File

@ -12,7 +12,6 @@ import punycode from 'punycode';
import { NameIcon, H3, Button } from 'joyent-ui-toolkit'; import { NameIcon, H3, Button } from 'joyent-ui-toolkit';
import Title from '@components/create-instance/title'; import Title from '@components/create-instance/title';
import Animated from '@containers/create-instance/animated';
import Name from '@components/create-instance/name'; import Name from '@components/create-instance/name';
import Description from '@components/description'; import Description from '@components/description';
import GetInstance from '@graphql/get-instance-small.gql'; import GetInstance from '@graphql/get-instance-small.gql';
@ -89,7 +88,6 @@ const NameContainer = ({
); );
export default compose( export default compose(
Animated,
graphql(GetRandomName, { graphql(GetRandomName, {
fetchPolicy: 'network-only', fetchPolicy: 'network-only',
props: ({ data }) => ({ props: ({ data }) => ({
@ -109,7 +107,7 @@ export default compose(
return { return {
...ownProps, ...ownProps,
proceeded, proceeded: proceeded || name.length,
randomizing, randomizing,
name name
}; };

View File

@ -6,13 +6,13 @@ import { connect } from 'react-redux';
import { Margin } from 'styled-components-spacing'; import { Margin } from 'styled-components-spacing';
import forceArray from 'force-array'; import forceArray from 'force-array';
import includes from 'lodash.includes'; import includes from 'lodash.includes';
import find from 'lodash.find';
import get from 'lodash.get'; import get from 'lodash.get';
import { NetworkIcon, Button, H3, StatusLoader } from 'joyent-ui-toolkit'; import { NetworkIcon, Button, H3, StatusLoader } from 'joyent-ui-toolkit';
import Title from '@components/create-instance/title'; import Title from '@components/create-instance/title';
import Network from '@components/create-instance/network'; import Network from '@components/create-instance/network';
import Animated from '@containers/create-instance/animated';
import Description from '@components/description'; import Description from '@components/description';
import ListNetworks from '@graphql/list-networks.gql'; import ListNetworks from '@graphql/list-networks.gql';
@ -24,6 +24,7 @@ export const Networks = ({
expanded = false, expanded = false,
proceeded = false, proceeded = false,
loading = false, loading = false,
initialValues,
setInfoExpanded, setInfoExpanded,
setMachinesExpanded, setMachinesExpanded,
handleNext, handleNext,
@ -64,6 +65,7 @@ export const Networks = ({
form={FORM_NAME} form={FORM_NAME}
destroyOnUnmount={false} destroyOnUnmount={false}
forceUnregisterOnUnmount={true} forceUnregisterOnUnmount={true}
initialValues={initialValues}
> >
{props => {props =>
!loading ? ( !loading ? (
@ -109,7 +111,6 @@ export const Networks = ({
); );
export default compose( export default compose(
Animated,
graphql(ListNetworks, { graphql(ListNetworks, {
props: ({ data }) => { props: ({ data }) => {
const { networks = [], loading = false, error = null, refetch } = data; const { networks = [], loading = false, error = null, refetch } = data;
@ -126,6 +127,12 @@ export default compose(
({ values, form }, { networks }) => { ({ values, form }, { networks }) => {
const selected = get(form, `${FORM_NAME}.values`, {}); const selected = get(form, `${FORM_NAME}.values`, {});
const empty = id => !includes(Object.keys(selected), id); const empty = id => !includes(Object.keys(selected), id);
const proceeded = get(values, 'create-instance-networks-proceeded', false);
const _public = find(networks, ['name', 'Joyent-SDC-Public']);
const initialValues = _public ? {
[_public.id]: true
} : {};
const _networks = networks.map(({ id, name, ...network }) => { const _networks = networks.map(({ id, name, ...network }) => {
if (empty(id) && name === 'Joyent-SDC-Public') { if (empty(id) && name === 'Joyent-SDC-Public') {
@ -154,8 +161,9 @@ export default compose(
}); });
return { return {
proceeded: get(values, 'create-instance-networks-proceeded', false), proceeded,
networks: _networks, networks: _networks,
initialValues,
selected: Object.keys(selected).filter(n => selected[n]) selected: Object.keys(selected).filter(n => selected[n])
}; };
}, },

View File

@ -22,7 +22,6 @@ import {
Overview Overview
} from '@components/create-instance/package'; } from '@components/create-instance/package';
import Animated from '@containers/create-instance/animated';
import Title from '@components/create-instance/title'; import Title from '@components/create-instance/title';
import Description from '@components/description'; import Description from '@components/description';
import getPackages from '@graphql/get-packages.gql'; import getPackages from '@graphql/get-packages.gql';
@ -134,7 +133,6 @@ const PackageContainer = ({
); );
export default compose( export default compose(
Animated,
graphql(getPackages, { graphql(getPackages, {
props: ({ data: { loading, packages = [] } }) => ({ props: ({ data: { loading, packages = [] } }) => ({
loading, loading,
@ -190,6 +188,7 @@ export default compose(
const vmSelected = get(form, 'create-instance-vms.values.vms', false); const vmSelected = get(form, 'create-instance-vms.values.vms', false);
const pkgSelected = get(form, `${FORM_NAME}.values.package`, null); const pkgSelected = get(form, `${FORM_NAME}.values.package`, null);
const selected = find(packages, ['id', pkgSelected]);
const sorted = sortBy(packages, [_sortBy]); const sorted = sortBy(packages, [_sortBy]);
@ -219,7 +218,7 @@ export default compose(
packages: _sortOrder === 'asc' ? filtered : reverse(filtered), packages: _sortOrder === 'asc' ? filtered : reverse(filtered),
hasVms: vmSelected, hasVms: vmSelected,
selected: find(packages, ['id', pkgSelected]), selected: find(packages, ['id', pkgSelected]),
proceeded proceeded: proceeded || selected
}; };
}, },
(dispatch, { history }) => ({ (dispatch, { history }) => ({

View File

@ -18,7 +18,7 @@ import {
} from 'joyent-ui-toolkit'; } from 'joyent-ui-toolkit';
import Title from '@components/create-instance/title'; import Title from '@components/create-instance/title';
import Animated from '@containers/create-instance/animated'; import KeyValue from '@components/key-value';
import Description from '@components/description'; import Description from '@components/description';
import Tag from '@components/tags'; import Tag from '@components/tags';
@ -127,12 +127,17 @@ export const Tags = ({
); );
export default compose( export default compose(
Animated, connect(({ values }, ownProps) => {
connect(({ values }, ownProps) => ({ const proceeded = get(values, 'create-instance-tags-proceeded', false);
proceeded: get(values, 'create-instance-tags-proceeded', false), const addOpen = get(values, 'create-instance-tags-add-open', false);
addOpen: get(values, 'create-instance-tags-add-open', false), const tags = get(values, 'create-instance-tags', []);
tags: get(values, 'create-instance-tags', [])
})), return {
proceeded: proceeded || tags.length,
addOpen,
tags
};
}),
connect(null, (dispatch, { tags = [], history }) => ({ connect(null, (dispatch, { tags = [], history }) => ({
handleNext: () => { handleNext: () => {
dispatch(set({ name: 'create-instance-tags-proceeded', value: true })); dispatch(set({ name: 'create-instance-tags-proceeded', value: true }));

View File

@ -11,7 +11,6 @@ import { ScriptIcon, Button, KeyValue } from 'joyent-ui-toolkit';
import Editor from 'joyent-ui-toolkit/dist/es/editor'; import Editor from 'joyent-ui-toolkit/dist/es/editor';
import Title from '@components/create-instance/title'; import Title from '@components/create-instance/title';
import Animated from '@containers/create-instance/animated';
import Description from '@components/description'; import Description from '@components/description';
const FORM_NAME = 'create-instance-user-script'; const FORM_NAME = 'create-instance-user-script';
@ -94,13 +93,14 @@ export const UserScript = ({
); );
export default compose( export default compose(
Animated,
connect( connect(
({ values }, ownProps) => { ({ values }, ownProps) => {
const formOpen = get(values, 'create-instance-user-script-open', false);
const script = get(values, 'create-instance-user-script', { const script = get(values, 'create-instance-user-script', {
name: 'user-script' name: 'user-script'
}); });
const formOpen = get(values, 'create-instance-user-script-open', false);
const proceeded = get( const proceeded = get(
values, values,
'create-instance-user-script-proceeded', 'create-instance-user-script-proceeded',
@ -109,7 +109,7 @@ export default compose(
return { return {
script, script,
proceeded, proceeded: proceeded || script.value,
create: !script.value, create: !script.value,
edit: script.value, edit: script.value,
formOpen formOpen

View File

@ -9,7 +9,7 @@ import paramCase from 'param-case';
const { const {
REACT_APP_GQL_PORT = window.location.port, REACT_APP_GQL_PORT = window.location.port,
REACT_APP_GQL_PROTOCOL = window.location.protocol.replace(/\:$/, ''), REACT_APP_GQL_PROTOCOL = window.location.protocol.replace(/:$/, ''),
REACT_APP_GQL_HOSTNAME = window.location.hostname REACT_APP_GQL_HOSTNAME = window.location.hostname
} = process.env; } = process.env;

526
yarn.lock

File diff suppressed because it is too large Load Diff