Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a default list to topology options if previous options are missing #2490

Merged
merged 1 commit into from
May 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions client/app/scripts/components/topology-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ class TopologyOptions extends React.Component {
// The component builds an array of the next selected values that are sent to the action.
const opts = activeOptions.toJS();
const selected = selectedOption.get('id');
const isSelectedAlready = includes(opts[selected], value);
const selectedActiveOptions = opts[selected] || [];
const isSelectedAlready = includes(selectedActiveOptions, value);

if (isSelectedAlready) {
// Remove the option if it is already selected
nextOptions = opts[selected].filter(o => o !== value);
nextOptions = selectedActiveOptions.filter(o => o !== value);
} else {
// Add it to the array if it's not selected
nextOptions = opts[selected].concat(value);
nextOptions = selectedActiveOptions.concat(value);
}
// Since the user is clicking an option, remove the highlighting from the 'none' option,
// unless they are removing the last option. In that case, default to the 'none' label.
Expand Down