Skip to content

Commit

Permalink
cmd/elwinator: fix changelog
Browse files Browse the repository at this point in the history
fixes #52
  • Loading branch information
Andrew O'Neill committed Dec 8, 2016
1 parent 077cd68 commit 312b48c
Show file tree
Hide file tree
Showing 29 changed files with 249 additions and 152 deletions.
2 changes: 2 additions & 0 deletions cmd/elwinator/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[ignore]
<PROJECT_ROOT>/node_modules/fbjs/.*
2 changes: 2 additions & 0 deletions cmd/elwinator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dependencies": {
"bootstrap": "3",
"classnames": "^2.2.5",
"flow-bin": "^0.36.0",
"node-uuid": "^1.4.7",
"react": "^15.3.2",
"react-bootstrap": "^0.30.6",
Expand All @@ -23,6 +24,7 @@
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"flow": "flow; test $? -eq 0 -o $? -eq 2",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
Expand Down
81 changes: 52 additions & 29 deletions cmd/elwinator/src/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
// @flow
import { v4 } from 'node-uuid';

/**
* entitiesLoaded is an action that merges all the entities from the elwin storage to the store.
* @param {Array} namespaces - an array of Namespaces.
* @param {Array} experiments - an array of experiments.
* @param {Array} params - an array of params.
* @param {Object} entities - entities object.
*/
export const entitiesLoaded = (namespaces, experiments, params) => ({
export const entitiesLoaded = (entities: any) => ({
type: 'ENTITIES_LOADED',
namespaces,
experiments,
params,
entities,
});

/**
* changesClear is an action that clears the changes listed from the change list.
* @param {Array} changes - list of namespaces to remove.
*/
export const changesClear = (changes: Array<string>) => ({
type: 'CHANGES_CLEAR',
changes,
});

/**
* namespaceAdd is an action that adds a namespace to the namespace list.
* @param {string} name - The name of the namespace.
*/
export const namespaceAdd = (name) => ({
export const namespaceAdd = (namespace: string) => ({
type: 'NAMESPACE_ADD',
id: v4(),
name,
namespace,
});

/**
* namespaceDelete is an action that marks a namespace to be deleted.
* @param {string} namespace - The namespace to delete.
*/
export const namespaceDelete = (namespace) => ({
export const namespaceDelete = (namespace: string) => ({
type: 'NAMESPACE_DELETE',
namespace,
});
Expand All @@ -38,7 +44,7 @@ export const namespaceDelete = (namespace) => ({
* publish it then decide to delete it.
* @param {string} namespace - The namespace you want to delete.
*/
export const namespaceLocalDelete = (namespace) => ({
export const namespaceLocalDelete = (namespace: string) => ({
type: 'NAMESPACE_LOCAL_DELETE',
namespace,
});
Expand All @@ -48,7 +54,7 @@ export const namespaceLocalDelete = (namespace) => ({
* @param {string} namespace - The original name of the namespace.
* @param {string} name - The new name of the namespace.
*/
export const namespaceName = (namespace, name) => ({
export const namespaceName = (namespace: string, name: string) => ({
type: 'NAMESPACE_NAME',
namespace,
name,
Expand All @@ -57,20 +63,20 @@ export const namespaceName = (namespace, name) => ({
/**
* namespaceToggleLabel is an action that toggles the specified label.
* @param {string} namespace - name of the namespace the label is in.
* @param {string} name - name of the label to toggle.
* @param {string} id - id of the label to toggle.
*/
export const namespaceToggleLabel = (namespace, name) => ({
export const namespaceToggleLabel = (namespace: string, id: string) => ({
type: 'NAMESPACE_TOGGLE_LABEL',
namespace,
name,
id,
})

/**
* namespaceAddLabel is an action that adds a label to an experiment.
* @param {string} namespace - The namespace for the label.
* @param {string} name - The name of the label to add.
*/
export const namespaceAddLabel = (namespace, name) => ({
export const namespaceAddLabel = (namespace: string, name: string) => ({
type: 'NAMESPACE_ADD_LABEL',
id: v4(),
namespace,
Expand All @@ -81,7 +87,7 @@ export const namespaceAddLabel = (namespace, name) => ({
* namespaceTogglePublish is an action that toggles a namespace for publishing.
* @param {string} namespace - The namespace to publish.
*/
export const namespaceTogglePublish = (namespace) => ({
export const namespaceTogglePublish = (namespace: string) => ({
type: 'NAMESPACE_TOGGLE_PUBLISH',
namespace,
});
Expand All @@ -91,7 +97,7 @@ export const namespaceTogglePublish = (namespace) => ({
* @param {string} namespace - The namespace for the experiment.
* @param {string} name - The name of the experiment to add to the namespace.
*/
export const experimentAdd = (namespace, name) => ({
export const experimentAdd = (namespace: string, name: string) => ({
type: 'EXPERIMENT_ADD',
id: v4(),
namespace,
Expand All @@ -103,57 +109,65 @@ export const experimentAdd = (namespace, name) => ({
* @param {string} namespace - The namespace the experiment is in.
* @param {string} experiment - The name of the experiment to delete.
*/
export const experimentDelete = (namespace, experiment) => ({
export const experimentDelete = (namespace: string, experiment: string) => ({
type: 'EXPERIMENT_DELETE',
namespace,
experiment,
});

/**
* experimentName is an action that sets the name in an experiment.
* @param {string} namespace - The experiment namespace.
* @param {string} experiment - The experiment's original name.
* @param {string} name - The experiment's new name.
*/
export const experimentName = (experiment, name) => ({
export const experimentName = (namespace: string, experiment: string, name: string) => ({
type: 'EXPERIMENT_NAME',
namespace,
experiment,
name,
});

/**
* experimentNumSegments is an action that sets the number of segments in an
* expermient.
* @param {string} namespace - The experiment namespace.
* @param {string} experiment - The experiment that is being changed.
* @param {Array} namespaceSegments - The segments claimed by the namespace.
* @param {number} numSegments - The number of segments the experiment
* should have.
*/
export const experimentNumSegments = (experiment, namespaceSegments, numSegments) => ({
export const experimentNumSegments = (namespace: string, experiment: string, namespaceSegments: Uint8Array, numSegments: number) => ({
type: 'EXPERIMENT_NUM_SEGMENTS',
namespace,
experiment,
namespaceSegments,
numSegments,
});

/**
* paramName is an action that sets the param name in an experiments param.
* @param {string} namespace - The param namespace.
* @param {string} param - The param's id.
* @param {string} name - The param's new name.
*/
export const paramName = (param, name) => ({
export const paramName = (namespace: string, param: string, name: string) => ({
type: 'PARAM_NAME',
namespace,
param,
name,
});

/**
* paramAdd is an action that adds a param to an experiment.
* @param {string} namespace - The namespace name.
* @param {string} experiment - The experiment id.
* @param {Object} param - The param you are adding.
*/
export const paramAdd = (experiment, name) => ({
export const paramAdd = (namespace: string, experiment: string, name:string) => ({
type: 'PARAM_ADD',
id: v4(),
namespace,
experiment,
name,
});
Expand All @@ -164,18 +178,20 @@ export const paramAdd = (experiment, name) => ({
* @param {string} experiment - The experiment that the param is in.
* @param {string} name - The name of the param to delete.
*/
export const paramDelete = (experiment, param) => ({
export const paramDelete = (namespace: string, experiment: string, param: string) => ({
type: 'PARAM_DELETE',
namespace,
experiment,
param,
});

/**
* paramToggleWeighted is an action that toggles whether a param is weighted or
* uniform.
* @param {string} namespace - The param namespace.
* @param {string} param - The name of the param.
*/
export const paramToggleWeighted = (param) => ({
export const paramToggleWeighted = (namespace: string, param: string) => ({
type: 'PARAM_TOGGLE_WEIGHTED',
param,
});
Expand All @@ -188,40 +204,47 @@ export const paramToggleWeighted = (param) => ({
* @param {string} param - The name of the param.
* @param {string} choice - The choice to add to the param.
*/
export const paramAddChoice = (param, choice) => ({
export const paramAddChoice = (namespace: string, param: string, choice: string) => ({
type: 'PARAM_ADD_CHOICE',
namespace,
param,
choice,
});

/**
* paramDeleteChoice is an action that deletes a choice from a param.
* @param {string} namespace - The param namespace.
* @param {string} param - The param name.
* @param {string} index - The index of the choice to delete.
*/
export const paramDeleteChoice = (param, index) => ({
export const paramDeleteChoice = (namespace: string, param: string, index: number) => ({
type: 'PARAM_DELETE_CHOICE',
namespace,
param,
index,
});

/**
* paramAddWeight is an action that adds a weight to a param. You should always
* call paramAddChoice before calling this.
* @param {string} namespace - The param namespace.
* @param {string} param - The name of the param.
* @param {string} weight - The weight to add to the param.
*/
export const paramAddWeight = (param, weight) => ({
export const paramAddWeight = (namespace: string, param: string, weight: number) => ({
type: 'PARAM_ADD_WEIGHT',
namespace,
param,
weight,
});

/**
* paramClearChoices is an action that removes all the choices and weights.
* @param {string} namespace - The namespace.
* @param {string} param - The name of the param.
*/
export const paramClearChoices = (param) => ({
export const paramClearChoices = (namespace: string, param: string) => ({
type: 'PARAM_CLEAR_CHOICES',
namespace,
param,
});
6 changes: 4 additions & 2 deletions cmd/elwinator/src/components/ChoiceList.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// @flow
import React from 'react';
import { connect } from 'react-redux';

import { paramDeleteChoice } from '../actions';

const ChoiceList = ({ paramID, choices, weights, dispatch }) => {
const ChoiceList = ({ namespace, paramID, choices, weights, dispatch }) => {
const choiceList = choices.map((c, i) =>
<tr key={c}>
<td>{i+1}</td>
<td>{c}</td>
<td>{ weights[i] || "uniform"}</td>
<td><button className="btn btn-default btn-xs" onClick={() => {
dispatch(paramDeleteChoice(paramID, i));
dispatch(paramDeleteChoice(namespace, paramID, i));
}}>&times;</button></td>
</tr>
);
Expand All @@ -32,6 +33,7 @@ const ChoiceList = ({ paramID, choices, weights, dispatch }) => {
};

ChoiceList.propTypes = {
namespace: React.PropTypes.string.isRequired,
paramID: React.PropTypes.string.isRequired,
choices: React.PropTypes.arrayOf(React.PropTypes.string),
weights: React.PropTypes.arrayOf(React.PropTypes.number),
Expand Down
1 change: 1 addition & 0 deletions cmd/elwinator/src/components/Experiment.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import React from 'react';
import { Link, browserHistory } from 'react-router';
import { connect } from 'react-redux';
Expand Down
1 change: 1 addition & 0 deletions cmd/elwinator/src/components/ExperimentList.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import React from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux';
Expand Down
1 change: 1 addition & 0 deletions cmd/elwinator/src/components/LabelList.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import classNames from 'classnames';
Expand Down
1 change: 1 addition & 0 deletions cmd/elwinator/src/components/Namespace.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import React from 'react';
import { Link, browserHistory } from 'react-router';
import { connect } from 'react-redux';
Expand Down
1 change: 1 addition & 0 deletions cmd/elwinator/src/components/NamespaceList.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import React from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux';
Expand Down
7 changes: 5 additions & 2 deletions cmd/elwinator/src/components/NewChoice.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import React, { PropTypes } from 'react';
import { browserHistory } from 'react-router';
import { connect } from 'react-redux';
Expand All @@ -6,6 +7,7 @@ import { paramAddChoice, paramAddWeight } from '../actions';
import { paramURL } from '../urls';

const NewChoice = ({
namespaceName,
paramID,
paramName,
isWeighted,
Expand All @@ -23,9 +25,9 @@ const NewChoice = ({
if (isWeighted && !weight.value.trim()) {
return;
}
dispatch(paramAddChoice(paramID, choice.value));
dispatch(paramAddChoice(namespaceName, paramID, choice.value));
if (isWeighted) {
dispatch(paramAddWeight(paramID, parseInt(weight.value, 10)));
dispatch(paramAddWeight(namespaceName, paramID, parseInt(weight.value, 10)));
}
if (!redirectOnSubmit) {
choice.value = '';
Expand Down Expand Up @@ -59,6 +61,7 @@ const NewChoice = ({
}

NewChoice.propTypes = {
namespaceName: PropTypes.string.isRequired,
paramID: PropTypes.string.isRequired,
paramName: PropTypes.string.isRequired,
isWeighted: PropTypes.bool.isRequired,
Expand Down
1 change: 1 addition & 0 deletions cmd/elwinator/src/components/NewExperiment.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import React from 'react';
import { connect } from 'react-redux';
import { browserHistory } from 'react-router';
Expand Down
4 changes: 3 additions & 1 deletion cmd/elwinator/src/components/NewLabel.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// @flow
import React, { PropTypes } from 'react';
import { browserHistory } from 'react-router';

import { namespaceURL } from '../urls';
import { namespaceAddLabel } from '../actions';

const NewLabel = ({ namespaceName, redirectOnSubmit, dispatch }) => {
const NewLabel = ({ namespaceName, redirectOnSubmit, dispatch }: {namespaceName: string, redirectOnSubmit: boolean, dispatch: Function}) => {
// namespaceName: string, redirectOnSubmit: boolean, dispatch: function
let label;
return (
<form onSubmit={e => {
Expand Down
1 change: 1 addition & 0 deletions cmd/elwinator/src/components/NewNamespace.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import React from 'react';
import { browserHistory } from 'react-router';
import { connect } from 'react-redux';
Expand Down

0 comments on commit 312b48c

Please sign in to comment.