From 95b2c4f829ef9f8535719a86205af09f03d6d7f1 Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Fri, 13 Nov 2015 17:45:01 +0100 Subject: [PATCH] Take default topology option if missing in URL --- .../app/scripts/components/topology-options.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/client/app/scripts/components/topology-options.js b/client/app/scripts/components/topology-options.js index f0ef73179..a749317a5 100644 --- a/client/app/scripts/components/topology-options.js +++ b/client/app/scripts/components/topology-options.js @@ -13,11 +13,27 @@ const TopologyOptions = React.createClass({ renderOption: function(items) { let activeText; + let activeValue; const actions = []; const activeOptions = this.props.activeOptions; const topologyId = this.props.topologyId; + const option = items[0].option; + + // find active option value + if (activeOptions && activeOptions.has(option)) { + activeValue = activeOptions.get(option); + } else { + // get default value + items.forEach(function(item) { + if (item.default) { + activeValue = item.value; + } + }); + } + + // render active option as text, add other options as actions items.forEach(function(item) { - if (activeOptions && activeOptions.has(item.option) && activeOptions.get(item.option) === item.value) { + if (item.value === activeValue) { activeText = item.display; } else { actions.push(this.renderAction(item.value, item.option, topologyId));