Skip to content

Commit

Permalink
Merge pull request #2523 from dcos/ph/feature/DCOS-19657-add-type-to-…
Browse files Browse the repository at this point in the history
…constraint

DCOS-19657: add advanced type to constraints input
  • Loading branch information
Philipp Hinrichsen authored Nov 30, 2017
2 parents d1a90bb + ed3198a commit 08eed89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@ function processTransaction(state, { type, path, value }) {
let newState = state.slice();

if (type === ADD_ITEM) {
newState.push({ fieldName: null, operator: null, value: null });
let defaultValue = { fieldName: null, operator: null, value: null };

if (value != null && value.type != null) {
defaultValue = Object.assign({}, defaultValue, value);
}

newState.push(defaultValue);
}
if (type === REMOVE_ITEM) {
newState = newState.filter((item, index) => {
return index !== value;
});
}
if (type === SET && name === "type") {
newState[index].type = value;
}
if (
type === SET &&
CONSTRAINT_FIELDS.includes(name) &&
Expand Down
3 changes: 2 additions & 1 deletion src/js/components/PlacementConstraintsPartial.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ export default class PlacementSection extends Component {
<FormGroup className="column-12">
<AddButton
onClick={this.props.onAddItem.bind(this, {
path: "constraints"
path: "constraints",
value: { type: "default" }
})}
>
Add Placement Constraint
Expand Down

0 comments on commit 08eed89

Please sign in to comment.